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.
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
| Version | Reference image limit | Use case |
|---|---|---|
| Standard | 14 | Standard text-to-image and edits |
| Official | 14 | When you need native generation parameter control and Google Search grounding |
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
Use model: "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
AuthorizationstringheaderrequiredAll endpoints require Bearer Token authentication
Get API Key: Visit the API Key Management page to obtain your API Key
Add to request headers:
Authorization: Bearer YOUR_API_KEYRequest Parameters
modelstringbodyrequireddefault: gemini-nano-banana-2.1-officialImage generation model name
Example: "gemini-nano-banana-2.1-official"
promptstringbodyrequiredText description for image generation
sizestringbodyImage aspect ratio
Supported 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
nintegerbodydefault: 1Number of images to generate
Fixed at 1
image_urlsstring[]bodyReference 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
Limits:
- Maximum 14 images
- Maximum file size per image: 10MB
- Supported formats: .jpeg, .jpg, .png, .webp
metadataobjectbodyVertex AI native extension parameters
Show metadata fields
temperaturenumberbodyGeneration temperature, controls output randomness
Range: 0.0 - 2.0
topPnumberbodyTop-P sampling parameter
Range: 0.0 - 1.0, default 0.95
maxOutputTokensintegerbodyMaximum output tokens
Default 32768
resolutionstringbodyOutput image resolution, automatically mapped to Vertex AI native imageSize
Options: 1K, 2K, 4K, default 1K
groundingstringbodydefault: noneGoogle 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
Billed per executed search query at $0.014 per query. A deposit for up to 4 queries is reserved when the request is submitted; unused queries are refunded at settlement.
personGenerationstringbodyPerson generation control
Options:
ALLOW_ALL- Allow generating all people (including adults and children)ALLOW_ADULT- Allow generating adults onlyALLOW_NONE- Disallow generating people
imageOutputOptionsobjectbodyImage output format configuration
imageOutputOptions fields
mimeTypestringbodyOutput image format
Options: image/png, image/jpeg, image/webp
compressionQualityintegerbodyCompression quality (JPEG only)
thinkingConfigobjectbodyThinking mode configuration. When enabled, the model reasons before generating images, improving results for complex scenes
thinkingConfig fields
thinkingBudgetintegerbodyThinking token budget, controls the depth of model reasoning
Range: 0 - 24576, default is determined by the model
thinkingLevelstringbodyThinking level
Options: LOW, MEDIUM, HIGH, MINIMAL
safetySettingsarraybodySafety settings array for content safety filtering
safetySettings elements
categorystringbodySafety category
Options: HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_HARASSMENT
thresholdstringbodyFiltering threshold
Options: OFF, BLOCK_LOW_AND_ABOVE, BLOCK_MEDIUM_AND_ABOVE, BLOCK_ONLY_HIGH
Response Fields
idstringUnique task identifier for querying task status
objectstringObject type, always generation.task
modelstringModel name used
statusstringTask status
queued- Queued for processingin_progress- Processingcompleted- Successfully completedfailed- Failed
progressintegerTask progress percentage (0-100)
created_atintegerTask creation timestamp (Unix timestamp)
metadataobjectTask metadata
requestExample
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}`);responseExample
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "gemini-nano-banana-2.1-official",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}Query Results
The id 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.