Introduction

文本

图片

生成图片POST编辑图片POST

视频

CNTokensCNTokens
开始使用API 参考
GeminiNano Banana 2

Nano Banana 2 · 生成图片

图片 / Gemini / Nano Banana 2 / 生成图片

POST/v1/images/generations

请求参数

Authorization

在 Header 添加参数 Authorization,其值为 Bearer 之后拼接你的 API Key。

Authorization: Bearer ****************
Header 参数
Content-Typestring可选
application/json
Acceptstring可选
application/json
Body 参数application/json必填
modelstring必需
模型 ID,固定为 `gemini-3.1-flash-image`
promptstring必需
图像描述
ninteger可选
生成张数,默认 `1`
sizestring可选
分辨率,如 `1024x1024`
qualitystring可选
质量档位(模型支持时)
response_formatstring可选
返回格式。`url` 仅对支持的模型(如 DALL-E 系列)生效;OpenAI gpt-image 始终返 `b64_json` 并忽略此字段。
output_formatstring可选
输出图像编码格式(png / jpeg / webp);对 OpenAI gpt-image 模型生效。
output_compressioninteger可选
压缩等级 0–100;仅 jpeg / webp 生效。
backgroundstring可选
背景类型(transparent / opaque / auto);transparent 需搭配 png 或 webp。
moderationstring可选
内容审核严格度(auto / low);仍由上游审核。
userstring可选
客户端可选传入的最终用户标识,用于上游滥用检测。
示例
{  "model": "gemini-3.1-flash-image",  "prompt": "一只在雪地里奔跑的金毛犬",  "n": 1,  "size": "1024x1024",  "response_format": "b64_json"}

请求示例代码

curl https://api.hotrouter.ai/v1/images/generations \  -H "Authorization: Bearer $API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "gemini-3.1-flash-image",    "prompt": "一只在雪地里奔跑的金毛犬",    "n": 1,    "size": "1024x1024",    "response_format": "b64_json"  }'

返回响应

200 · 成功
createdinteger可选
创建时间戳(秒)
dataarray[object]必需
生成的图片列表
示例
{  "created": 1730000000,  "data": [    {      "b64_json": "<base64>"    }  ]}

On this page

请求参数请求示例代码返回响应
{
  "model": "gemini-3.1-flash-image",
  "prompt": "一只在雪地里奔跑的金毛犬",
  "n": 1,
  "size": "1024x1024",
  "response_format": "b64_json"
}
curl https://api.hotrouter.ai/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.1-flash-image",
    "prompt": "一只在雪地里奔跑的金毛犬",
    "n": 1,
    "size": "1024x1024",
    "response_format": "b64_json"
  }'
{
  "created": 1730000000,
  "data": [
    {
      "b64_json": "<base64>"
    }
  ]
}