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 回調.