curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-official",
"prompt": "A futuristic city skyline with neon lights, cyberpunk style",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "2K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-official",
"prompt": "Generate an infographic about today's A-share market trend",
"size": "3:4",
"n": 1,
"metadata": {
"resolution": "2K",
"grounding": "web_image"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "gemini-nano-banana-2.1-official",
"prompt": "A futuristic city skyline with neon lights, cyberpunk style",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "2K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-Toapis-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gemini-nano-banana-2.1-official',
prompt: 'A futuristic city skyline with neon lights, cyberpunk style',
size: '16:9',
n: 1,
metadata: {
temperature: 1.0,
topP: 0.95,
resolution: '2K',
personGeneration: 'ALLOW_ALL',
thinkingConfig: {
thinkingLevel: 'HIGH'
}
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "gemini-nano-banana-2.1-official",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
Gemini Nano Banana 2.1
Gemini Nano Banana 2.1 Official Image Generation
Gemini Nano Banana 2.1 Official supports text-to-image and image-to-image generation with up to 14 reference images, 1K-4K output, and optional Google Search grounding.
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-official",
"prompt": "A futuristic city skyline with neon lights, cyberpunk style",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "2K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-official",
"prompt": "Generate an infographic about today's A-share market trend",
"size": "3:4",
"n": 1,
"metadata": {
"resolution": "2K",
"grounding": "web_image"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "gemini-nano-banana-2.1-official",
"prompt": "A futuristic city skyline with neon lights, cyberpunk style",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "2K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-Toapis-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gemini-nano-banana-2.1-official',
prompt: 'A futuristic city skyline with neon lights, cyberpunk style',
size: '16:9',
n: 1,
metadata: {
temperature: 1.0,
topP: 0.95,
resolution: '2K',
personGeneration: 'ALLOW_ALL',
thinkingConfig: {
thinkingLevel: 'HIGH'
}
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "gemini-nano-banana-2.1-official",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
Note for users in mainland China: Please use
https://toapis.cn as the API endpoint (Base URL). Replace https://toapis.com with https://toapis.cn in the examples in this document.Version Options
The reference image count is the total number of input images; it does not represent the number of output images. The versions use different model IDs, so follow the parameters and examples on the corresponding page.
Current Version
Usemodel: "gemini-nano-banana-2.1-official" to select Official. It supports text-to-image and image-to-image generation or editing with up to 14 reference images and 1K, 2K, or 4K output.
It uses Google Vertex AI and supports native extension parameters such as temperature, topP, thinkingConfig, safetySettings, and Google Search grounding; see the fields below.
Requests run asynchronously. After submission, use the task ID to query the result.
image_urls accepts image URLs only, not base64 data. Use the Upload Image endpoint first to obtain an accessible URL.Authentication
string
required
All endpoints require Bearer Token authenticationGet API Key: Visit the API Key Management page to obtain your API KeyAdd to request headers:
Authorization: Bearer YOUR_API_KEY
Request Parameters
string
default:"gemini-nano-banana-2.1-official"
required
Image generation model nameExample:
"gemini-nano-banana-2.1-official"string
required
Text description for image generation
string
Image aspect ratioSupported formats:
1:1- Square3:2/2:33:4/4:34:5/5:49:16/16:921:9/9:211:4/4:11:8/8:1
integer
default:1
Number of images to generateFixed at 1
string[]
Reference image URL array for image-to-image generation or editing⚠️ Only URL format is supported (base64 is not supported)
- Publicly accessible image URLs (http:// or https://)
- Use the Upload Image endpoint to upload local images and get URLs
- Maximum 14 images
- Maximum file size per image: 10MB
- Supported formats: .jpeg, .jpg, .png, .webp
object
Vertex AI native extension parameters
Show Show metadata fields
Show Show metadata fields
number
Generation temperature, controls output randomnessRange:
0.0 - 2.0number
Top-P sampling parameterRange:
0.0 - 1.0, default 0.95integer
Maximum output tokensDefault
32768string
Output image resolution, automatically mapped to Vertex AI native imageSizeOptions:
1K, 2K, 4K, default 1Kstring
default:"none"
Google Search grounding. When enabled, the model searches Google before generating, and the result may include cited sources in the returned
grounding_metadata.Options:none- Disabled (default)web- Web searchimage- Image searchweb_image- Web + image search
string
Person generation controlOptions:
ALLOW_ALL- Allow generating all people (including adults and children)ALLOW_ADULT- Allow generating adults onlyALLOW_NONE- Disallow generating people
object
object
Thinking mode configuration. When enabled, the model reasons before generating images, improving results for complex scenes
array
Safety settings array for content safety filtering
Response Fields
string
Unique task identifier for querying task status
string
Object type, always
generation.taskstring
Model name used
string
Task status
queued- Queued for processingin_progress- Processingcompleted- Successfully completedfailed- Failed
integer
Task progress percentage (0-100)
integer
Task creation timestamp (Unix timestamp)
object
Task metadata
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-official",
"prompt": "A futuristic city skyline with neon lights, cyberpunk style",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "2K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-nano-banana-2.1-official",
"prompt": "Generate an infographic about today's A-share market trend",
"size": "3:4",
"n": 1,
"metadata": {
"resolution": "2K",
"grounding": "web_image"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "gemini-nano-banana-2.1-official",
"prompt": "A futuristic city skyline with neon lights, cyberpunk style",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "2K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-Toapis-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gemini-nano-banana-2.1-official',
prompt: 'A futuristic city skyline with neon lights, cyberpunk style',
size: '16:9',
n: 1,
metadata: {
temperature: 1.0,
topP: 0.95,
resolution: '2K',
personGeneration: 'ALLOW_ALL',
thinkingConfig: {
thinkingLevel: 'HIGH'
}
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "gemini-nano-banana-2.1-official",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
Query Results
Theid in the submission response is the task ID. Use the Image Task Status endpoint to retrieve the status and final images.
When grounding is enabled, the task result also returns grounding_metadata with search queries and cited sources.
Task status queries and Webhook callbacks follow the standard asynchronous image API conventions.