Nanobanana Image Generation
- Nano Banana 2 (gemini-3.1-flash-image-preview) model supports text-to-image, image-to-image, image editing, and other generation modes
- Async processing mode — use the returned task ID to check task status
- Generated image links are valid for 24 hours; please save them promptly
Authorizations
All APIs require Bearer Token authentication
Add to request header:
Authorization: Bearer YOUR_API_KEY
Body
gemini-3.1-flash-image-preview: Supports text-to-image, image-to-image, and image editing
"gemini-3.1-flash-image-preview"
Image generation prompt
Notes:
- Text-to-image mode: describe the image content you want to generate
- Image editing mode: describe the editing instructions for the reference image
"A futuristic city skyline at dusk, cyberpunk style"
Output image aspect ratio
Model differences:
gemini-3.1-flash-image-preview: available values include1:1,1:4,1:8,2:3,3:2,3:4,4:1,4:3,4:5,5:4,8:1,9:16,16:9,21:9,match_input_imagegemini-3-pro-image-preview: available values include1:1,2:3,3:2,3:4,4:3,4:5,5:4,9:16,16:9,21:9,match_input_image
Notes:
match_input_imagemeans the output will try to match the input image's aspect ratio
"1:1"
Output image resolution
Model differences:
gemini-3.1-flash-image-preview: supports512,0.5K,1K,2K,4Kgemini-3-pro-image-preview: supports1K,2K,4K
Notes:
512and0.5Kboth represent half-size output1K: approximately 1MP2K: approximately 4MP4K: approximately 16MP
"512"
Reference/editing image list
Model differences:
gemini-3.1-flash-image-preview: supports image-to-image and image editinggemini-3-pro-image-preview: supports image editing
Notes:
- When provided, the mode automatically switches to image editing
- It is recommended to use publicly accessible image URLs
["https://example.com/photo.jpg"]Output format
Notes:
- Both models support this field
- Common values:
jpg,png,webp
Do not pass this parameter unless necessary.
"png"
Enable search for real-time information
Notes:
- Both
gemini-3.1-flash-image-previewandgemini-3-pro-image-previewsupport this field
Do not pass this parameter unless necessary.
true
Enable image search to assist generation
Model differences:
gemini-3.1-flash-image-preview: supportedgemini-3-pro-image-preview: not supported
Do not pass this parameter unless necessary.
true
Response
Task created successfully
Task creation timestamp
1757165031
Task ID
"task-unified-1757165031-uyujaw3d"
Actual model name used
Specific task type
image.generation.task Task progress percentage (0-100)
0 <= x <= 1000
Task status
pending, processing, completed, failed "pending"
Async task information
Task output type
image "image"