curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-vip",
"prompt": "将这张照片改为水彩画风格",
"size": "1:1",
"n": 1,
"image_urls": [
"https://example.com/photo.jpg"
],
"metadata": {
"resolution": "2K"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
}
)
response.raise_for_status()
task = response.json()
print(task["id"])
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
})
});
if (!response.ok) {
throw new Error(await response.text());
}
const task = await response.json();
console.log(task.id);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "gemini-nano-banana-2.1",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
Gemini Nano Banana 2.1
Gemini Nano Banana 2.1 图像生成
Gemini Nano Banana 2.1 普通版和 VIP 共用图片生成接口, 支持最多 14 张参考图和 1K, 2K, 4K 分辨率.
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-vip",
"prompt": "将这张照片改为水彩画风格",
"size": "1:1",
"n": 1,
"image_urls": [
"https://example.com/photo.jpg"
],
"metadata": {
"resolution": "2K"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
}
)
response.raise_for_status()
task = response.json()
print(task["id"])
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
})
});
if (!response.ok) {
throw new Error(await response.text());
}
const task = await response.json();
console.log(task.id);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "gemini-nano-banana-2.1",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
中国大陆用户请注意: 请使用
https://toapis.cn 作为 Base URL. 将以下示例中的 https://toapis.com 替换为 https://toapis.cn.模型选择
| 版本 | Model ID |
|---|---|
| 普通版 | gemini-nano-banana-2.1 |
| VIP | gemini-nano-banana-2.1-vip |
model 字段切换. 支持文生图和图生图. 请求异步执行, 提交成功后通过任务 ID 查询结果.
image_urls 只接收公开可访问的图片 URL, 不接收 base64 数据. 请先使用 上传图片接口 上传本地图片并获取 URL.认证
string
必填
所有请求均需要 Bearer Token. 请在 API Key 管理页面 获取 API Key.
Authorization: Bearer YOUR_API_KEY
请求参数
string
默认值:"gemini-nano-banana-2.1"
必填
模型名称. 使用
gemini-nano-banana-2.1 或 gemini-nano-banana-2.1-vip.string
必填
图像生成或编辑的文本描述.
string
输出图像的宽高比. 支持以下值:
1:13:2,2:34:3,3:416:9,9:165:4,4:521:91:4,4:11:8,8:1
integer
默认值:1
输出数量固定为数字
1, 不要使用字符串 "1".string[]
参考图片 URL 字符串数组, 用于图生图或图像编辑. 最多 14 张图片, 每个 URL 必须公开可访问. 参考图数量不代表输出图片数量.单张图片不超过 10MB. 支持 .jpeg, .jpg, .png, .webp.
["https://example.com/photo.jpg"]
响应字段
string
任务 ID, 用于查询任务状态和结果.
string
固定为
generation.task.string
请求中使用的模型 ID.
string
任务状态:
queued, in_progress, completed, failed.integer
任务进度百分比, 范围为 0-100.
integer
任务创建时间, Unix 时间戳, 单位为秒.
object
任务元数据.
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-vip",
"prompt": "将这张照片改为水彩画风格",
"size": "1:1",
"n": 1,
"image_urls": [
"https://example.com/photo.jpg"
],
"metadata": {
"resolution": "2K"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
}
)
response.raise_for_status()
task = response.json()
print(task["id"])
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"model": "gemini-nano-banana-2.1",
"prompt": "赛博朋克风格的城市夜景, 霓虹灯闪烁",
"size": "16:9",
"n": 1,
"metadata": {
"resolution": "2K"
}
})
});
if (!response.ok) {
throw new Error(await response.text());
}
const task = await response.json();
console.log(task.id);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "gemini-nano-banana-2.1",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
查询结果
提交响应中的id 是任务 ID. 使用 图片任务查询接口 获取任务状态和最终图片. 异步通知请参考 Webhook 回调.