EccoAPIeccoapi
POST/api/v1/nanobanana2/generate

Generate Image (2)

High-quality image generation. Supports up to 14 reference images and Google Search grounding.

Request Parameters

ParameterTypeRequiredDescription
promptstringYesThe text prompt describing the image
imageSizestringNo"1K" (default), "2K", or "4K". See pricing table below.
aspectRatiostringNoImage 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.
useGoogleSearchbooleanNoEnable grounding with real-time Google Search data.
imageBase64arrayNoArray of base64-encoded reference images (up to 14).
imageUrlsarrayNoArray of reference image URLs (up to 14).
callbackUrlstringNoWebhook URL for async callback mode. Returns 202 immediately.
temperaturenumberNoControls randomness (0-2). Recommended: 1.0 for image generation.
thinkingConfigobjectNoEnables reasoning pass for better reference adherence. Example: {"includeThoughts": true}
mediaResolutionstringNoInput image fidelity: "MEDIA_RESOLUTION_LOW", "MEDIA_RESOLUTION_MEDIUM", or "MEDIA_RESOLUTION_HIGH".
responseModalitiesarrayNoResponse types. Default: ["TEXT", "IMAGE"].
safetySettingsarrayNoSafety filter thresholds. Allowed thresholds: BLOCK_LOW_AND_ABOVE, BLOCK_MEDIUM_AND_ABOVE, BLOCK_ONLY_HIGH.

Image Sizes & Pricing

Image SizeCost 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

CodeDescription
200Success - image generated
202Accepted - async job queued (when callbackUrl is provided)
400Bad request - invalid parameters
401Unauthorized - invalid or missing API key
402Payment required - insufficient credits
429Rate limited - too many requests
500Internal server error