Best Practices
NanoBananaPro Native Google Format Aspect Ratio Output
Generate images with specified aspect ratios and resolutions using Google's native format API
Overview
Nano Banana Pro (gemini-3-pro-image-preview) supports various aspect ratios and resolution options, allowing you to precisely control the dimensions of generated images.
Supported Aspect Ratios
Nano Banana Pro supports the following aspect ratios:
- 1:1 - Square images
- 16:9 - Standard landscape
- 9:16 - Standard portrait
- 4:3 - Traditional landscape
- 3:4 - Traditional portrait
- 3:2 - Camera standard (landscape)
- 2:3 - Camera standard (portrait)
- 21:9 - Ultra-wide
- 5:4 - Display ratio (landscape)
- 4:5 - Display ratio (portrait)
Supported Resolutions
Each aspect ratio supports three resolution levels:
1K Resolution (Quick Preview)
| Aspect Ratio | Resolution |
|---|---|
| 1:1 | 1024×1024 |
| 16:9 | 1376×768 |
| 9:16 | 768×1376 |
| 4:3 | 1200×896 |
| 3:4 | 896×1200 |
| 3:2 | 1232×816 |
| 2:3 | 816×1232 |
| 21:9 | 1584×672 |
| 5:4 | 1136×896 |
| 4:5 | 896×1136 |
2K Resolution (Recommended)
| Aspect Ratio | Resolution |
|---|---|
| 1:1 | 2048×2048 |
| 16:9 | 2752×1536 |
| 9:16 | 1536×2752 |
| 4:3 | 2400×1792 |
| 3:4 | 1792×2400 |
| 3:2 | 2464×1632 |
| 2:3 | 1632×2464 |
| 21:9 | 3168×1344 |
| 5:4 | 2272×1792 |
| 4:5 | 1792×2272 |
4K Resolution (Ultra HD)
| Aspect Ratio | Resolution |
|---|---|
| 1:1 | 4096×4096 |
| 16:9 | 5504×3072 |
| 9:16 | 3072×5504 |
| 4:3 | 4800×3584 |
| 3:4 | 3584×4800 |
| 3:2 | 4928×3264 |
| 2:3 | 3264×4928 |
| 21:9 | 6336×2688 |
| 5:4 | 4544×3584 |
| 4:5 | 3584×4544 |
API Request Format
Basic Request Structure
{
"contents": [{
"parts": [
{"text": "Your image description"}
]
}],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {
"aspectRatio": "16:9",
"image_size": "2K"
}
}
}Parameter Description
- responseModalities: Must be set to
["IMAGE"]to return an image - aspectRatio: Aspect ratio, choose from the supported ratios above
- image_size: Resolution level, options are
"1K","2K","4K"
Example Code
cURL Example
curl -X POST "https://api.ai.soraliststudio.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \
-H "Authorization: Bearer sk-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts": [
{"text": "A cute kitten sitting in a garden, oil painting style, high definition, rich in detail"}
]
}],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {
"aspectRatio": "16:9",
"image_size": "2K"
}
}
}'Python Example
import requests
import base64
API_KEY = "sk-YOUR_API_KEY"
API_URL = "https://api.ai.soraliststudio.com/v1beta/models/gemini-3-pro-image-preview:generateContent"
payload = {
"contents": [{
"parts": [
{"text": "A cute kitten sitting in a garden, oil painting style, high definition, rich in detail"}
]
}],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {
"aspectRatio": "16:9",
"image_size": "2K"
}
}
}
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
response = requests.post(API_URL, headers=headers, json=payload, timeout=600)
if response.status_code == 200:
data = response.json()
image_base64 = data["candidates"][0]["content"]["parts"][0]["inlineData"]["data"]
# Save image
with open("output.png", "wb") as f:
f.write(base64.b64decode(image_base64))
print("Image saved as output.png")Performance Recommendations
Recommended Timeout Settings
Different resolutions require different processing times. Set appropriate timeout values:
- 1K Resolution: 360 seconds (6 minutes) - For quick previews
- 2K Resolution: 600 seconds (10 minutes) - Recommended for daily use
- 4K Resolution: 1200 seconds (20 minutes) - Ultra HD quality
Bandwidth Optimization
Since image data is transferred using base64 encoding, the data volume is large:
- Recommended to use metered high-speed bandwidth
- Avoid network congestion affecting upload and download speeds
- 4K image base64 data may exceed 10MB
Notes
- Higher resolution means longer generation time: Choose the appropriate resolution based on your actual needs
- Price impact: Different resolutions may have different prices, check the latest pricing
- Network stability: High-resolution image transfers require a stable network connection
- Reasonable timeout settings: Set sufficient timeout to avoid request interruption
How is this guide?