Google 的高效图像生成与编辑模型,模型名 nano-banana-2-1。文生图和改图是同一个模型:只给提示词就是生成,带上参考图(最多 10 张)就是编辑或融合。15 种画面比例,1K / 2K / 4K 三档输出,每张 $0.024 / $0.04 / $0.064,成功才扣费。
所有请求在 Header 携带 API Key:
Authorization: Bearer YOUR_API_KEY| resolution | 价格 / 张 | 说明 |
|---|---|---|
| 1K | $0.024 | 默认档 |
| 2K | $0.04 | |
| 4K | $0.064 | 最高档 |
价格只看分辨率:参考图张数、画面比例、提示词长短都不影响价格。不传 resolution 按 1K 计。失败不扣费。计费示例:1K 100 张 = $2.40,2K 100 张 = $4.00,4K 100 张 = $6.40。
/v1/images/generations异步契约:创建任务立即返回 taskId,再轮询 GET /v1/images/generations?task_id= 直到 state 为 completed 取 resultUrls,或者传 callback_url 接 webhook。下面这条正是我们 2026-10-07 首测用的请求:16:9、1K,约 20 秒出图,实得 1376×768,招牌文字拼写正确。
# Step 1: create the task (text-to-image) — returns a taskId right away
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-2-1",
"prompt": "A cozy bookstore cafe on a rainy evening, warm window light, a hand-painted sign reading NANO BANANA 2.1 above the door, cinematic wide shot",
"aspect_ratio": "16:9",
"resolution": "1K"
}'
# → { "code": 200, "data": { "taskId": "...", "state": "pending", "model": "nano-banana-2-1" } }
# Step 2: poll until state is "completed" (or "failed")
curl "https://api.apimodels.app/v1/images/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
# → { "code": 200, "data": { "state": "completed", "resultUrls": ["https://..."] } }同一端点、同一个模型名:传 image(单张)或 image_urls(数组)就进入编辑,两者合计最多 10 张。每张可以是 URL、data URI 或裸 base64,格式 JPEG / PNG / WebP。在提示词里按「图 1、图 2」指代参考图即可。
# Edit one image — image accepts a URL, a data URI or bare base64
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-2-1",
"prompt": "Keep the room and the lighting, replace the sofa with a dark green velvet one",
"image": "https://example.com/living-room.jpg",
"resolution": "2K"
}'
# Combine several references — image_urls takes up to 10 (image + image_urls together: 10 max)
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-2-1",
"prompt": "Put the character from image 1 into the street scene from image 2, wearing the jacket from image 3",
"image_urls": [
"https://example.com/character.png",
"https://example.com/street.jpg",
"https://example.com/jacket.jpg"
],
"aspect_ratio": "4:5",
"resolution": "2K"
}'
# Poll GET ?task_id= exactly as in the text-to-image example.| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | nano-banana-2-1 |
| prompt | 是 | string | 图片描述或编辑指令,最长 20,000 字符 |
| image | 否 | string | 单张参考图:URL、data URI 或裸 base64(也可用 image_url / image_base64) |
| image_urls | 否 | string[] | 多张参考图,与 image 合计最多 10 张;超过 10 张返回 400 |
| aspect_ratio | 否 | string | auto, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1。默认 auto |
| resolution | 否 | string | 1K(默认)/ 2K / 4K,决定价格 |
| callback_url | 否 | string | 任务完成后回调的 webhook 地址,可代替轮询 |
pending / processing:还在生成,隔 2–3 秒再查completed:data.resultUrls 里是结果图链接failed:data.failMsg 说明原因,这一单不扣费它们都走同一个端点、同一套参数,切换只改 model 一个字符串。
试一试:Playground(不写代码,在网页上选比例、分辨率、传参考图)。
按张计价,只看分辨率:1K(默认)$0.024、2K $0.04、4K $0.064。参考图张数、画面比例、提示词长短都不影响价格,失败不扣费。
单张用 image,多张用 image_urls 数组,两者合计最多 10 张,超过 10 张返回 400。每张可以是 URL、data URI 或裸 base64,格式 JPEG / PNG / WebP。数组字段请写 image_urls 而不是 images —— 图片端点读的是 image_urls。
15 种:auto(默认)、1:1、2:3、3:2、3:4、4:3、4:5、5:4、9:16、16:9、21:9,以及适合横幅和长条图的 1:4、4:1、1:8、8:1。传其它值返回 400,不会被悄悄换成相近的比例。