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": "A cyberpunk city at night with flickering neon lights",
"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": "Transform this photo into a watercolor painting",
"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": "A cyberpunk city at night with flickering neon lights",
"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": "A cyberpunk city at night with flickering neon lights",
"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 Image Generation
Generate images with Gemini Nano Banana 2.1 standard and VIP using up to 14 reference images and 1K, 2K, or 4K resolution.
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": "A cyberpunk city at night with flickering neon lights",
"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": "Transform this photo into a watercolor painting",
"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": "A cyberpunk city at night with flickering neon lights",
"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": "A cyberpunk city at night with flickering neon lights",
"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": {}
}
Note for users in mainland China: Use
https://toapis.cn as the Base URL. Replace https://toapis.com with https://toapis.cn in the examples below.Model Selection
| Version | Model ID |
|---|---|
| Standard | gemini-nano-banana-2.1 |
| VIP | gemini-nano-banana-2.1-vip |
model field. Text-to-image and image-to-image requests run asynchronously. Query results using the task ID returned after submission.
image_urls only accepts publicly accessible image URLs, not base64 data. Use the Upload Image API to upload local images and obtain URLs first.Authentication
string
required
All requests require a Bearer Token. Get your API Key from the API Key Management Page.
Authorization: Bearer YOUR_API_KEY
Request Parameters
string
default:"gemini-nano-banana-2.1"
required
Model name. Use
gemini-nano-banana-2.1 or gemini-nano-banana-2.1-vip.string
required
Text description for image generation or editing.
string
Output image aspect ratio. Supported values:
1:13:2,2:34:3,3:416:9,9:165:4,4:521:91:4,4:11:8,8:1
integer
default:1
The output count is fixed at the number
1. Do not use the string "1".string[]
Array of reference image URL strings for image-to-image generation or editing. Maximum 14 images. Each URL must be publicly accessible. The reference image count is not the output image count.Maximum 10MB per image. Supported formats: .jpeg, .jpg, .png, .webp.
["https://example.com/photo.jpg"]
object
Additional configuration options.
Show metadata
Show metadata
string
default:"1K"
Output image resolution. Supported values:
1K, 2K, 4K. Default: 1K. Use an uppercase K.Response Fields
string
Task ID used to query task status and results.
string
Always
generation.task.string
Model ID used in the request.
string
Task status:
queued, in_progress, completed, failed.integer
Task progress as a percentage from 0 to 100.
integer
Task creation time as a Unix timestamp in seconds.
object
Task metadata.
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": "A cyberpunk city at night with flickering neon lights",
"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": "Transform this photo into a watercolor painting",
"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": "A cyberpunk city at night with flickering neon lights",
"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": "A cyberpunk city at night with flickering neon lights",
"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": {}
}
Query Results
Theid in the submission response is the task ID. Use the Image Task Status API to retrieve task status and final images. See Task Webhooks for asynchronous notifications.