API Reference
Generate Images
API endpoint for generating images
Endpoint
POST /api/ai/nano-banana/generateGenerate images from text prompts with optional reference images.
Request
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer token with your API key: Bearer sk-xxxxx |
Content-Type | Yes | application/json or multipart/form-data |
Body Parameters
Prop
Type
Supported Aspect Ratios
| Ratio | Description | Use Case |
|---|---|---|
1:1 | Square | Social media posts, profile pictures |
2:3 | Portrait | Mobile wallpapers |
3:2 | Landscape | Photography style |
3:4 | Portrait | Product images |
4:3 | Landscape | Presentations |
9:16 | Vertical | Stories, TikTok, Reels |
16:9 | Widescreen | YouTube thumbnails, desktop wallpapers |
21:9 | Ultra-wide | Cinematic banners |
Response
Success Response (200)
{
"model": "nano-banana-2-4k",
"created": 1705123456,
"images": [
{
"url": "https://storage.example.com/generated-image.png"
}
]
}Response Fields
Prop
Type
Examples
Basic Text-to-Image
curl -X POST https://nano-banana-pro.net/api/ai/nano-banana/generate \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A serene Japanese garden with cherry blossoms, koi pond, and a traditional wooden bridge, golden hour lighting",
"size": "4k",
"aspectRatio": "16:9"
}'async function generateImage() {
const response = await fetch('https://nano-banana-pro.net/api/ai/nano-banana/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-your-api-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: 'A serene Japanese garden with cherry blossoms, koi pond, and a traditional wooden bridge, golden hour lighting',
size: '4k',
aspectRatio: '16:9',
}),
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
const data = await response.json();
console.log('Generated image URL:', data.images[0].url);
return data;
}import requests
def generate_image():
response = requests.post(
'https://nano-banana-pro.net/api/ai/nano-banana/generate',
headers={
'Authorization': 'Bearer sk-your-api-key',
'Content-Type': 'application/json',
},
json={
'prompt': 'A serene Japanese garden with cherry blossoms, koi pond, and a traditional wooden bridge, golden hour lighting',
'size': '4k',
'aspectRatio': '16:9',
}
)
response.raise_for_status()
data = response.json()
print('Generated image URL:', data['images'][0]['url'])
return dataImage-to-Image with Reference URL
Use a reference image to guide the generation:
curl -X POST https://nano-banana-pro.net/api/ai/nano-banana/generate \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Transform this image into a watercolor painting style",
"image": "https://example.com/my-photo.jpg",
"size": "2k"
}'const response = await fetch('https://nano-banana-pro.net/api/ai/nano-banana/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-your-api-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: 'Transform this image into a watercolor painting style',
image: 'https://example.com/my-photo.jpg',
size: '2k',
}),
});response = requests.post(
'https://nano-banana-pro.net/api/ai/nano-banana/generate',
headers={
'Authorization': 'Bearer sk-your-api-key',
'Content-Type': 'application/json',
},
json={
'prompt': 'Transform this image into a watercolor painting style',
'image': 'https://example.com/my-photo.jpg',
'size': '2k',
}
)Multiple Reference Images
Combine multiple images for complex compositions:
{
"prompt": "Combine these images into a cohesive landscape scene",
"image": [
"https://example.com/mountains.jpg",
"https://example.com/lake.jpg",
"https://example.com/sunset.jpg"
],
"size": "4k",
"aspectRatio": "21:9"
}Upload Image via Multipart Form
For uploading local images:
curl -X POST https://nano-banana-pro.net/api/ai/nano-banana/generate \
-H "Authorization: Bearer sk-your-api-key" \
-F "prompt=Make this photo look like a vintage film photograph" \
-F "size=2k" \
-F "image=@/path/to/your/image.jpg"const formData = new FormData();
formData.append('prompt', 'Make this photo look like a vintage film photograph');
formData.append('size', '2k');
formData.append('image', fileInput.files[0]); // File from input element
const response = await fetch('https://nano-banana-pro.net/api/ai/nano-banana/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-your-api-key',
// Don't set Content-Type - browser will set it with boundary
},
body: formData,
});with open('/path/to/your/image.jpg', 'rb') as f:
response = requests.post(
'https://nano-banana-pro.net/api/ai/nano-banana/generate',
headers={
'Authorization': 'Bearer sk-your-api-key',
},
data={
'prompt': 'Make this photo look like a vintage film photograph',
'size': '2k',
},
files={
'image': ('image.jpg', f, 'image/jpeg'),
}
)Error Responses
| Status | Error | Description |
|---|---|---|
400 | Bad Request | Invalid request parameters |
401 | Unauthorized | Missing or invalid API key |
402 | Payment Required | Insufficient credits |
500 | Internal Server Error | Generation failed |
Error Response Format
{
"error": "Error message describing what went wrong"
}Common Errors
Plan Limits
| Feature | Free | Standard | Pro |
|---|---|---|---|
| Max reference images | 3 | 8 | 14 |
| Concurrent generations | 1 | 5 | 10 |
| Max image size | 2.5MB | 2.5MB | 2.5MB |
| 4K generation | ✗ | ✓ | ✓ |
| API access | ✗ | ✓ | ✓ |
Tips for Better Results
Write detailed prompts
Be specific about what you want. Include details about style, lighting, composition, and mood.
// Good
"A cozy coffee shop interior with warm lighting, exposed brick walls,
vintage wooden furniture, steam rising from cups, morning sunlight
through large windows, photorealistic, 4K quality"
// Less effective
"coffee shop"Use style modifiers
Add quality and style keywords to improve results:
4K quality,highly detailed,photorealisticcinematic lighting,golden hour,soft shadowsoil painting style,watercolor,digital art
Choose appropriate aspect ratios
Match your aspect ratio to your intended use:
- Social posts:
1:1 - Phone wallpapers:
9:16 - Desktop wallpapers:
16:9 - Cinematic:
21:9
