Nano Banana 2.1 API
Complete API reference for Nano Banana 2.1 text-to-image and image editing models.
Model Variants
This API supports two model variants:
Quick Comparison
Supported Aspect Ratios
Both models support 14 aspect ratios:
16:9,9:16,1:1,3:2,2:3,3:4,4:3,5:4,4:5,21:9,1:4,4:1,1:8,8:1
Provide the ratio as separate numeric width and height values; for example, width: 16 and height: 9 select 16:9. These values describe a ratio, not output pixel dimensions.
Nano Banana 2.1 (Text-to-Image)
Endpoint
POST /api/v1/image/task
Authentication
Authorization: Bearer YOUR_API_KEY
Request Parameters
Required
Note: The width:height ratio must be one of: 16:9, 9:16, 1:1, 3:2, 2:3, 3:4, 4:3, 5:4, 4:5, 21:9, 1:4, 4:1, 1:8, 8:1.
Optional
Example Request
javascript
Nano Banana 2.1 Edit (Image Editing)
Endpoint
POST /api/v1/image/task
Request Parameters
Required
Note: The width:height ratio must be one of the 14 supported ratios listed above.
Optional
Single Image Edit Example
javascript
Multi-Image Composition Example
javascript
Billing Note: Reference images are charged per image from the first. Each enabled search option adds a separate fixed charge per generation, regardless of image count. See current pricing for rates.
Response Format
Initial Response
json
Polling Response
json
Successful Response
json
Status Values
submitted: Task acceptedprocessing: Task is runningsucceed: Task completed successfullyfailed: Task failed
Best Practices
Text-to-Image Tips
- Describe the Image: Include subject, lighting, and composition in the prompt.
- Choose a Resolution: Pass
1k,2k, or4kin every request. - Select an Aspect Ratio: Pass the matching
widthandheightvalues for one of the 14 supported ratios. - Choose Search Options: Omit either search flag for its default
falsevalue; set it totruewhen needed.
Image Editing Tips
- Provide Reference Images: Include one to 14 accessible image URLs in
image_url_list. - Describe the Edit: State what should change or be preserved in the prompt.
- Select Output Settings: Supply the required
resolution,width, andheightvalues. - Choose Search Options: Web search and image search can be enabled independently.