POST
/api/v1/nanobanana2/generateGenerate Image (2)
High-quality image generation. Supports up to 14 reference images and Google Search grounding.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | The text prompt describing the image |
imageSize | string | No | "1K" (default), "2K", or "4K". See pricing table below. |
aspectRatio | string | No | Image aspect ratio. On an edit (input image provided), omit this field or pass "auto" to inherit the input image aspect ratio. Text-to-image with no value defaults to "1:1". Supported: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9. |
useGoogleSearch | boolean | No | Enable grounding with real-time Google Search data. |
imageBase64 | array | No | Array of base64-encoded reference images (up to 14). |
imageUrls | array | No | Array of reference image URLs (up to 14). |
callbackUrl | string | No | Webhook URL for async callback mode. Returns 202 immediately. |
temperature | number | No | Controls randomness (0-2). Recommended: 1.0 for image generation. |
thinkingConfig | object | No | Enables reasoning pass for better reference adherence. Example: {"includeThoughts": true} |
mediaResolution | string | No | Input image fidelity: "MEDIA_RESOLUTION_LOW", "MEDIA_RESOLUTION_MEDIUM", or "MEDIA_RESOLUTION_HIGH". |
responseModalities | array | No | Response types. Default: ["TEXT", "IMAGE"]. |
safetySettings | array | No | Safety filter thresholds. Allowed thresholds: BLOCK_LOW_AND_ABOVE, BLOCK_MEDIUM_AND_ABOVE, BLOCK_ONLY_HIGH. |
Image Sizes & Pricing
| Image Size | Cost per Image |
|---|---|
| 1K (default) | $0.05 |
| 2K | $0.075 |
| 4K | $0.10 |
Supported Aspect Ratios
1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
Async Mode (Recommended)
Recommended for production
Image generation can take 15-90+ seconds. Use async mode with callbackUrl or job polling to avoid timeouts. The API returns a 202 response instantly, and results are delivered via webhook or the job status endpoint.
bash
curl -X POST https://eccoapi.com/api/v1/nanobanana2/generate \
-H "Authorization: Bearer nk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Ultra detailed mountain landscape at golden hour",
"aspectRatio": "16:9",
"imageSize": "4K",
"callbackUrl": "https://your-server.com/webhook"
}'Returns 202 Accepted with a jobId. Poll /api/v1/jobs/:jobId for status, or receive the result at your callbackUrl.
Sync Request
Sync mode waits for the image and returns it directly. Best for quick generations under 60 seconds.
bash
curl -X POST https://eccoapi.com/api/v1/nanobanana2/generate \
-H "Authorization: Bearer nk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Ultra detailed mountain landscape at golden hour",
"aspectRatio": "16:9",
"imageSize": "4K",
"useGoogleSearch": false
}'Response
json
{
"code": 200,
"msg": "Success",
"data": {
"assetUrl": "https://<signed-url>",
"candidates": [{
"content": {
"parts": [{
"inlineData": {
"mimeType": "image/png",
"assetUrl": "https://<signed-url>",
"assetKey": "user/<userId>/nanobanana2/....png"
}
}]
}
}]
},
"meta": {
"model": "nanobanana2",
"cost": 0.07,
"remaining_credits": 9.93,
"settings": {
"aspectRatio": "16:9",
"imageSize": "4K"
}
}
}Status Codes
| Code | Description |
|---|---|
200 | Success - image generated |
202 | Accepted - async job queued (when callbackUrl is provided) |
400 | Bad request - invalid parameters |
401 | Unauthorized - invalid or missing API key |
402 | Payment required - insufficient credits |
429 | Rate limited - too many requests |
500 | Internal server error |
