curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-3.1-flash-image-official",
"prompt": "An ink wash painting of mountains and rivers, layered peaks with swirling mist",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "1K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "gemini-3.1-flash-image-official",
"prompt": "An ink wash painting of mountains and rivers, layered peaks with swirling mist",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "1K",
"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-3.1-flash-image-official',
prompt: 'An ink wash painting of mountains and rivers, layered peaks with swirling mist',
size: '16:9',
n: 1,
metadata: {
temperature: 1.0,
topP: 0.95,
resolution: '1K',
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-3.1-flash-image-official",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
gemini-3.1-flash-image-official
Gemini-3.1-Flash Official Image Generation
Generate images using Google Gemini 3.1 Flash official direct-connect model with thinking mode and extreme aspect ratios
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-3.1-flash-image-official",
"prompt": "An ink wash painting of mountains and rivers, layered peaks with swirling mist",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "1K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "gemini-3.1-flash-image-official",
"prompt": "An ink wash painting of mountains and rivers, layered peaks with swirling mist",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "1K",
"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-3.1-flash-image-official',
prompt: 'An ink wash painting of mountains and rivers, layered peaks with swirling mist',
size: '16:9',
n: 1,
metadata: {
temperature: 1.0,
topP: 0.95,
resolution: '1K',
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-3.1-flash-image-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.- Direct connection to Google Vertex AI using the Gemini 3.1 Flash Image native API
- Select the
gemini-3.1-flash-image-officialmodel via the model parameter - Nano Banana 2 aliases:
nano-banana-2-lite-officialandnano-banana-2-official - Supports text-to-image and image-to-image generation
- Supports native generation parameters like temperature, topP, and maxOutputTokens
- Supports resolution (1K/2K/4K), personGeneration, and imageOutputOptions image configuration
- Supports thinkingConfig thinking mode for improved complex scene generation
- Supports safetySettings for content safety control
- Supports extreme aspect ratios (4:1, 8:1)
- Asynchronous task management with task ID for result querying
Important Change: For better performance and cost control, we no longer support passing base64 image data directly in
image_urls. Please use the Upload Image endpoint to upload images first, then use the returned URL in this API.Authorizations
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
Body
string
default:"gemini-3.1-flash-image-official"
required
Image generation model nameExample:
"gemini-3.1-flash-image-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:94:1/8:1- Extreme widescreen ratios
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 no longer 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.0, default 1.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
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
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-3.1-flash-image-official",
"prompt": "An ink wash painting of mountains and rivers, layered peaks with swirling mist",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "1K",
"personGeneration": "ALLOW_ALL",
"thinkingConfig": {
"thinkingLevel": "HIGH"
}
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "gemini-3.1-flash-image-official",
"prompt": "An ink wash painting of mountains and rivers, layered peaks with swirling mist",
"size": "16:9",
"n": 1,
"metadata": {
"temperature": 1.0,
"topP": 0.95,
"resolution": "1K",
"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-3.1-flash-image-official',
prompt: 'An ink wash painting of mountains and rivers, layered peaks with swirling mist',
size: '16:9',
n: 1,
metadata: {
temperature: 1.0,
topP: 0.95,
resolution: '1K',
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-3.1-flash-image-official",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}