Nano Banana 2 1

Generate images from text or edit images using up to 14 references. Supports 1K, 2K, and 4K output in JPG or PNG format.

Model

Model NameOutputAspect Ratios
nano-banana-2-1Image (JPG/PNG)auto, 1:1, 2:3, 3:2, 1:4, 4:1, 3:4, 4:3, 4:5, 5:4, 1:8, 8:1, 9:16, 16:9, 21:9

Pricing

Per-image billing by output resolution:

ResolutionCreditsPrice
1K (default)6 credits$0.03
2K10 credits$0.05
4K16 credits$0.08

Your account pricing multiplier applies when configured. Credits are rounded to two decimal places. Reference images do not add a separate charge.

Create Task

curl -X POST https://api.aivideoapi.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2-1",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "A cute cat wearing sunglasses sitting on a beach, digital art style",
      "resolution": "1K",
      "aspect_ratio": "auto",
      "output_format": "jpg"
    }
  }'

Request Body

FieldTypeRequiredDescription
modelstringYesMust be nano-banana-2-1
inputobjectYesGeneration parameters below
callback_urlstringNoURL to receive task completion or failure notifications

Input Object

FieldTypeRequiredDescription
promptstringYesText description or editing instructions, up to 20,000 characters
image_urlsstring[]NoUp to 14 publicly accessible image URLs; JPEG, PNG, or WebP, up to 30 MB per image
aspect_ratiostringNoAny ratio listed above; default auto
resolutionstringNo1K (default), 2K, or 4K
output_formatstringNojpg (default) or png

Playground file uploads have a 10 MB limit per image. The API accepts public image URLs with the 30 MB limit above.

Example: Image Editing

{
  "model": "nano-banana-2-1",
  "input": {
    "prompt": "Replace the jacket with a yellow raincoat. Preserve the person's identity, pose, framing, and lighting.",
    "image_urls": ["https://example.com/portrait.jpg"],
    "resolution": "2K",
    "aspect_ratio": "auto",
    "output_format": "png"
  }
}

Response

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "397ce9f2-c04e-4244-ac33-3af19a7cc297"
  }
}

Query Task

curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
  -H "Authorization: Bearer sk-your-api-key"

Status transitions: pending → processing → completed or failed. Poll until the task reaches a final status, or use callback_url to receive the result.

Completed

{
  "id": "397ce9f2-c04e-4244-ac33-3af19a7cc297",
  "status": "completed",
  "model": "nano-banana-2-1",
  "created_at": 1791421200,
  "completed_at": 1791421220,
  "output": {
    "urls": ["https://file.aivideoapi.ai/images/example.png"]
  }
}

Read the generated images from output.urls.

Failed

{
  "id": "57c8772c-f834-46f3-9b7d-81f92e104050",
  "status": "failed",
  "model": "nano-banana-2-1",
  "created_at": 1791421200,
  "error": {
    "code": "upstream_error",
    "message": "Image generation failed"
  }
}

Pre-charged credits are refunded when a task fails. Completed tasks retain their charge. Duplicate notifications do not create additional charges or refunds.

Callback

Pass callback_url when creating the task to receive a POST notification after completion or failure. The notification uses the same response format as the task query.


Error Codes

When a request fails, the API returns a JSON error response:

{
  "error": {
    "code": "insufficient_credits",
    "message": "Your credit balance is too low. Please top up.",
    "type": "billing_error"
  }
}

Error Reference

HTTP StatusCodeTypeDescription
400invalid_requestinvalid_request_errorMissing or invalid parameters
401invalid_api_keyauthentication_errorAPI key is invalid, disabled, or deleted
402insufficient_creditsbilling_errorCredit balance too low, please top up
403ip_not_allowedpermission_errorRequest IP not in the key's allowlist
404model_not_foundinvalid_request_errorModel does not exist or is inactive
404task_not_foundinvalid_request_errorTask ID does not exist
429rate_limit_exceededrate_limit_errorToo many requests, please slow down
429spend_limit_exceededbilling_errorKey spend limit reached (hourly/daily/total)
500internal_errorapi_errorUnexpected server error
503upstream_errorupstream_errorUpstream AI provider returned an error

Common Scenarios

invalid_request (400)

Returned when required fields are missing or invalid.

{
  "error": {
    "code": "invalid_request",
    "message": "'model' is required.",
    "type": "invalid_request_error"
  }
}

insufficient_credits (402)

Your balance is too low. Check your balance with GET /v1/credits and top up in Dashboard > Billing.

invalid_api_key (401)

Possible causes:

  • The key does not start with sk-
  • The key has been disabled or deleted
  • The user account has been banned

upstream_error (503)

The upstream AI provider returned an error. This may happen when:

  • The input contains sensitive or prohibited content
  • The provider is temporarily unavailable
  • The request parameters are not supported by the provider

Credits are automatically refunded when a task fails due to upstream errors.