Nano 系列图像生成
Nano 系列覆盖 NanoBanana 模型家族。适合需要指定 Nano 模型档位,并使用 aspect_ratio 控制输出比例的场景。来源范围同时包含 OpenAI 兼容和 Gemini 兼容入口,新集成可以优先从通用异步图像任务流程开始。
支持模型
| 模型家族 | 示例 ID | 说明 |
|---|---|---|
| NanoBanana | NanoBanana | 基础 NanoBanana 模型。 |
| NanoBanana Pro | NanoBananaPro-* | Pro 档位变体。 |
| NanoBanana 2 | NanoBanana2-0.5K、NanoBanana2-1K | 按分辨率档位区分的 NanoBanana 2 变体。 |
实际可用模型取决于账号通道和模型价格配置。
推荐 Endpoint
POST /v1/images/tasks
GET /v1/images/tasks/{task_id}
Apifox 来源也提供 Nano 的 OpenAI 兼容图像接口:
POST /v1/images/generations
POST /v1/images/edits
并提供 Gemini 兼容格式给 Gemini 风格客户端使用。选择与客户端格式一致的入口即可,下方请求概念保持一致。
Authentication
Authorization: Bearer sk-***
Content-Type: application/json
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 具体 Nano 模型 ID,例如 NanoBanana2-0.5K。 |
prompt | string | 是 | 生成或编辑提示词。 |
task_type | string | 否 | text2image 或 image2image,也可以由图片输入推断。 |
image | string/object | 条件必填 | 编辑任务的单张参考图。 |
images | string[] | 条件必填 | 多张参考图 URL。 |
aspect_ratio | string | 否 | 推荐的比例控制字段,例如 1:1、16:9、9:16、4:3 或 3:4。 |
output_format | string | 否 | NanoBanana 支持 png、jpeg、webp;Pro 和 NanoBanana 2 变体在当前来源范围内支持 png 和 jpeg。 |
n | integer | 否 | 输出数量,默认 1;最大值取决于上游限制。 |
response_format | string | 否 | 生成资产建议使用 url。 |
文生图示例
curl -X POST "{BASE_URL}/v1/images/tasks" \
-H "Authorization: Bearer sk-***" \
-H "Content-Type: application/json" \
-d '{
"model": "NanoBanana2-0.5K",
"task_type": "text2image",
"prompt": "A small red cube on a clean white desk, minimal product photo, soft daylight",
"aspect_ratio": "1:1",
"output_format": "png",
"n": 1,
"response_format": "url"
}'
图生图示例
curl -X POST "{BASE_URL}/v1/images/tasks" \
-H "Authorization: Bearer sk-***" \
-H "Content-Type: application/json" \
-d '{
"model": "NanoBanana2-0.5K",
"task_type": "image2image",
"prompt": "Turn the reference image into a clean product render",
"image": "https://example.com/input.png",
"aspect_ratio": "16:9",
"output_format": "jpeg",
"n": 1,
"response_format": "url"
}'
查询任务状态
curl "{BASE_URL}/v1/images/tasks/task_xxx" \
-H "Authorization: Bearer sk-***"
{
"code": "success",
"message": "",
"data": {
"task_id": "task_xxx",
"status": "succeeded",
"progress": "100%",
"result_url": "https://example.com/result.png",
"metadata": {
"task_type": "text2image",
"result_count": 1
},
"error": null
}
}
计费说明
NanoBanana 系列按配置模型单价乘以 n 或实际返回结果数量计费。aspect_ratio 和 output_format 控制输出形态和格式,但在当前来源范围内不是独立计费维度。
常见错误
- 使用当前账号未启用的 Nano 模型 ID。
- 将
image、images和兼容图像字段混用。 - 把
size当作 Nano 的主要控制字段;Nano 优先使用aspect_ratio。 - 为所选 Nano 家族请求不支持的输出格式。
- 任务还没有创建成功就开始轮询。