Nano Banana 2 Text to Image API
Generate photorealistic and creative images from text prompts using Nano Banana 2 (Google Gemini 3.1 Flash Image model). Supports multiple resolutions up to 4K, flexible aspect ratios, and optional web search for current context.
Quick Start
Generate your first image in under a minute
Get Your API Key
Sign in to your account to get your API key and see it automatically filled in all code examples.
Don't have an account? Sign up for free
import requests
response = requests.post(
"https://netwrck.com/api/nano-banana",
json={
"api_key": "YOUR_API_KEY",
"prompt": "An action shot of a black lab swimming in an inground pool",
"aspect_ratio": "16:9",
"resolution": "1K"
}
)
result = response.json()
print(f"Image generated: {result['image_url']}")
print(f"Cost: ${result['cost']}")
fetch('https://netwrck.com/api/nano-banana', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
api_key: 'YOUR_API_KEY',
prompt: 'An action shot of a black lab swimming in an inground pool',
aspect_ratio: '16:9',
resolution: '1K'
})
})
.then(res => res.json())
.then(result => {
console.log('Image generated:', result.image_url);
console.log('Cost: $' + result.cost);
})
.catch(error => console.error('Error:', error));
curl -X POST https://netwrck.com/api/nano-banana \
-H 'Content-Type: application/json' \
-d '{
"api_key": "YOUR_API_KEY",
"prompt": "An action shot of a black lab swimming in an inground pool",
"aspect_ratio": "16:9",
"resolution": "1K"
}'
Interactive API Tester
Pricing & Credits
0.5K
7 credits
$0.07 per image
1K (default)
9 credits
$0.09 per image
2K
14 credits
$0.14 per image
4K
18 credits
$0.18 per image
Web Search: +2 credits per request when enable_web_search: true. Only successful generations are charged.
API Reference
POST /api/nano-banana
Generate images from text using Gemini 3.1 Flash Image model
Request Format
Send a POST request with a JSON body containing these parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | string | Required | Your API key for authentication. |
| prompt | string | Required | Text description of the image to generate. Be detailed for best results. |
| aspect_ratio | string | Optional |
Image aspect ratio. Default: "auto" (model decides based on prompt).Options: auto, 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, 9:16
|
| resolution | string | Optional |
Output resolution. Default: "1K".Options: 0.5K (7cr), 1K (9cr), 2K (14cr), 4K (18cr)
|
| num_images | integer | Optional | Number of images to generate. Default: 1. Credits multiply per image. |
| output_format | string | Optional | Output format. Default: "png". Options: jpeg, png, webp |
| safety_tolerance | string | Optional | Content moderation level. Default: "4". Range: 1 (strictest) to 6 (least strict). |
| seed | integer | Optional | Random seed for reproducible results. |
| enable_web_search | boolean | Optional | Allow the model to use web search for latest information. Adds +2 credits. Default: false. |
Response Examples
Success Response (200 OK)
{
"success": true,
"image_url": "https://netwrckstatic.netwrck.com/static/uploads/ai/nano-banana-example.png",
"images": ["https://netwrckstatic.netwrck.com/static/uploads/ai/nano-banana-example.png"],
"prompt_used": "An action shot of a black lab swimming in an inground pool",
"resolution_used": "1K",
"aspect_ratio": "auto",
"cost": "0.0900",
"credits_charged": 9
}
Error Responses
401 Unauthorized
{
"error": "Invalid API key",
"status": 401
}
402 Payment Required
{
"error": "Insufficient credits",
"status": 402
}
Pro Tips
Prompt Writing
- Be specific about subjects, setting, and lighting
- Include camera angle and composition details
- Mention style: "photorealistic", "cinematic", "illustration"
- Add mood descriptors for atmosphere
Best Practices
- Use
autoaspect ratio and let model decide - Start with 1K resolution, upgrade for final renders
- Enable web search for prompts about current events
- Save seeds for consistent character or style reproduction
Example Prompts
"A black lab swimming underwater in a suburban pool, split-level shot at the waterline, dog holding a tennis ball, paws visible underwater, photorealistic, golden afternoon light"
"Minimalist product shot of a glass perfume bottle on white marble, macro lens, soft shadows, commercial photography style"
"Aerial view of a misty mountain valley at sunrise, pine forests, winding river, cinematic color grading, 4K quality"
Netwrck