Nano Banana 2
Nano Banana 2
新一代图像生成与编辑,支持 Google 搜索、最多 14 张参考图和 4K 输出
- Endpoint
- POST /api/v1/images/generate
- model
- nano-banana-2
- Output
- Image
- Credits
- from 7
提交任务
/api/v1/images/generate参数
modelstring必需Must be "nano-banana-2"
typestring可选默认text-to-image"text-to-image" or "image-to-image" (default: text-to-image)
text-to-imageimage-to-imagepromptstring必需Text description of the image to generate. Supports up to 20,000 characters.
resolutionstring可选默认1K"1K", "2K", or "4K" (default: 1K)
1K2K4Kaspect_ratiostring可选"auto", "1:1", "16:9", "9:16", "4:3", "3:4", "1:4", "1:8", "4:1", "8:1", "21:9"
auto1:116:99:164:33:41:41:84:18:121:9image_urlsstring[]可选Input image URLs or base64 for image-to-image. Supports up to 14 images.
input_imagestring可选Deprecated. Alias for image_urls[0]
google_searchboolean可选Enable Google Search grounding for real-time information
truefalsegoogle_image_searchboolean可选Enable image search grounding. Requires google_search=true.
truefalseoutput_formatstring可选默认jpg"jpg" or "png" (default: jpg)
jpgpngnum_imagesnumber可选Must be 1
请求
curl -X POST https://www.bananapro.site/api/v1/images/generate \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-2",
"prompt": "A cinematic product photo of a transparent smart speaker on a glass table",
"resolution": "2K",
"aspect_ratio": "16:9"
}'响应200
{
"success": true,
"data": {
"task_id": "task_nb2_abc123",
"credits_used": 11,
"remaining_credits": 489,
"model": "nano-banana-2"
}
}示例中的 credits_used 数值仅供说明。实际消耗会在提交时计算,并由 API 返回。
查询任务
/api/v1/images/{task_id}status
pending- Accepted and waiting to start. Keep polling.
processing- Running. Keep polling.
completed- Finished. Read image_url; output holds the full result.
failed- Ended without a result. error_message says why and credits_refunded shows what was returned.
Poll every 5 to 10 seconds and stop at completed or failed, or register a webhook to be notified instead. Failed tasks are refunded automatically.
请求
curl https://www.bananapro.site/api/v1/images/task_abc123 \
-H "Authorization: Bearer sk-your-api-key"响应200
{
"success": true,
"data": {
"task_id": "task_abc123",
"model": "nano-banana-2",
"status": "completed",
"output": { "images": [{ "url": "https://..." }] },
"primary_url": "https://...",
"image_url": "https://...",
"error_message": null,
"credits_used": 11,
"credits_refunded": 0,
"created_at": "2026-10-04T10:00:00.000Z",
"updated_at": "2026-10-04T10:01:12.000Z",
"completed_at": "2026-10-04T10:01:12.000Z"
},
"request_id": "req_abc123"
}等待结果
TASK_ID=task_abc123
while true; do
TASK=$(curl -s https://www.bananapro.site/api/v1/images/$TASK_ID \
-H "Authorization: Bearer sk-your-api-key")
STATUS=$(echo "$TASK" | jq -r '.data.status')
if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
echo "$TASK" | jq
break
fi
sleep 10
done定价
| Resolution | Credits |
|---|---|
| 1K | 7 |
| 2K | 11 |
| 4K | 15 |
功能特性
- 文生图生成
- 图像到图像的转换
- Google 搜索增强
- 最多 14 张参考图
- 超宽高比与最高 4K 分辨率