Nano Banana 2 API
Complete API reference for Nano Banana 2 models powered by Google Gemini 3.1 Flash Image.
Model Variants
This API supports two model variants:
Quick Comparison
Supported Aspect Ratios
Both models support 11 aspect ratios:
16:9(default),9:16,1:1,3:2,2:3,4:3,3:4,4:5,5:4,21:9,9:21
Nano Banana 2 (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: "21:9", "9:21", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "1:1"
Example Request
javascript
Nano Banana 2 Edit (Image Editing)
Endpoint
POST /api/v1/image/task
Request Parameters
Required
Single Image Edit Example
javascript
Multi-Image Composition Example
javascript
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
- Be Specific: Include subject, style, lighting, composition details
- Choose Resolution Wisely: 2K is default and cost-effective
- Aspect Ratio Selection: Choose ratio based on your use case (16:9 for web, 9:16 for mobile)
- Prompt Quality: More detailed prompts generally produce better results
- Fast Iteration: Nano Banana 2's speed makes it ideal for rapid prototyping
Image Editing Tips
- Clear Instructions: Be specific about what to change
- Multi-Image Composition: Can combine up to 10 images in a single request
- Resolution Matching: Output resolution can differ from input
- Prompt Guidance: Describe the desired outcome, not just the changes
Key Advantages
- Cost-Effective: Up to 50% lower cost compared to Nano Banana Pro
- Lightning Fast: Optimized for rapid generation and iteration
- High Quality: Maintains professional-grade output quality up to 4K
- Flexible: Supports same aspect ratios and features as Pro version