gemini-2.5-flash-image接口文档(chat)
gemini-2.5-flash-image 模型价格为0.028一次,返回的格式是url。 gemini-2.5-flash-image-hd 模型返回的是4k高清图片,图片大小10-20m。 令牌分组选择default
gemini-2.5-flash-image和gemini-2.5-flash-image-hd模型的调用方式是一样的。只需要更换模型名字
1.chat接口
路径:https://api.rainboxs.com//v1/chat/completions 方法:POST 认证:Bearer Token 模型:gemini-2.5-flash-image、gemini-2.5-flash-image-hd
请求说明
所有请求都需要在 HTTP Header 中包含 Authorization 字段,用于身份认证。 Header参数示例:
Content-Type: application/json
Authorization: sk-2SiNPJ(这里换成平台生成的有效令牌)使用场景
场景一:文生图
根据文字描述生成图像。 请求 Body 示例:
{
"model": "gemini-2.5-flash-image",
"messages": [
{
"role": "user",
"content": "画一条狗"
}
],
"group": "default",
"stream": false
}场景二:图生图(Image to Image)
图片的url可以替换为base64,参数名称不变 请求 Body 示例:
{
"model": "gemini-2.5-flash-image",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "将这只狗的颜色改为绿色"
},
{
"type": "image_url",
"image_url": {
"url": "https://google.datas.systems/fileSystem/response_images/287/2025/09/22/1758540685369256927_6662.png"
}
}
]
}
],
"group": "default",
"stream": false
}场景三:多图合并(Image to Image)
图片的url可以替换为base64,参数名称不变 请求 Body 示例:
{
"model": "gemini-2.5-flash-image",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "让这两只狗面对面"
},
{
"type": "image_url",
"image_url": {
"url": "https://google.datas.systems/fileSystem/response_images/287/2025/09/22/1758540685369256927_6662.png"
}
},
{
"type": "image_url",
"image_url": {
"url": "https://google.datas.systems/fileSystem/response_images/287/2025/09/22/1758540685369256927_6662.png"
}
}
]
}
],
"group": "default",
"stream": false
}响应示例
{
"id": "chatcmpl-89DAH8mOJeAQebenu01j0qoQo1Lep",
"object": "chat.completion",
"created": 1758541477,
"model": "gemini-2.5-flash-image",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": ""
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 107,
"completion_tokens": 35,
"total_tokens": 142,
"prompt_tokens_details": {
"text_tokens": 100
},
"completion_tokens_details": {
"content_tokens": 35
}
}
}2.generations 接口
接口定义
路径:https://api.rainboxs.com//v1/images/generations 方法:POST 认证:Bearer Token 模型:gemini-2.5-flash-image、gemini-2.5-flash-image-hd
请求说明
所有请求都需要在 HTTP Header 中包含 Authorization 字段,用于身份认证。 Header参数示例:
Content-Type: application/json
Authorization: sk-2SiNPJ(这里换成平台生成的有效令牌)使用场景
场景一:文生图
根据文字描述生成图像。 请求 Body 示例:
{
"prompt": "画一只猪,我只要图片,不要有其他信息",
"model": "gemini-2.5-flash-image"
}场景二:图生图(Image to Image)
图片的url可以替换为base64,参数名称不变 请求 Body 示例:
{
"prompt": "https://google.datas.systems/fileSystem/response_images/287/2025/09/21/1758420613207028663_155.png 移除图片的背景,我只要图片,不要有其他信息",
"model": "gemini-2.5-flash-image"
}响应示例
{
"created": 1758420613,
"data": [
{
"revised_prompt": "Draw a pig, I only want the picture, no other information.: ",
"url": "https://google.datas.systems/fileSystem/response_images/287/2025/09/21/1758420613207028663_155.png"
}
],
"usage": {
"total_tokens": 4189,
"input_tokens": 14,
"output_tokens": 4175,
"input_tokens_details": {
"text_tokens": 14
}
}
}