Nano Banana 2 API

Image generation API focused on nano-banana-2

Call nano-banana-2 through the same in-site endpoint for text-to-image and image-to-image, with 1K, 2K, and 4K outputs.

nano-banana-2 highlights

  • Model-first setup: samples default to nano-banana-2.
  • Clear pricing: 20 credits at 1K, 30 at 2K, 50 at 4K.
  • Stronger image-to-image: up to 8 references via multipart upload.

Before you call

  • Endpoints are in-site Next APIs and require Authorization: Bearer YOUR_API_KEY.
  • This page focuses on nano-banana-2 integration. For all model options, see /nano-banana-api.
  • nano-banana-2 pricing: 20 credits (1K), 30 credits (2K), 50 credits (4K); failed jobs refund automatically.
  • Use multipart/form-data to send up to 8 reference images (<=10 MB each).

Generate image

POST /api/v1/image/nano-banana with payloads tuned for nano-banana-2 in this guide.

Method: POSTPath: /api/v1/image/nano-banana

Payload fields

  • prompt (required): description to generate.
  • model (required): recommended value is nano-banana-2.
  • mode (optional): text-to-image (default) or image-to-image; image mode needs at least one reference image.
  • aspectRatio (optional): default auto; accepts 1:1, 16:9, 9:16, etc.
  • imageSize (optional): default 1K; accepts 1K/2K/4K.
  • outputFormat (optional): default png.
  • isPublic (optional): default true.
  • imageFile (optional, FormData): upload reference files for image-to-image; up to 8 files, each <=10 MB.
  • imageUrl (optional): reference image URL(s); accepts string or string[], counts toward the 8-image cap.
  • imageData (optional, legacy): base64 data URL is accepted for compatibility, but multipart file upload is recommended.
Failure cases400: missing required fields / no reference image for image-to-image / invalid model / too many reference images.;401: not logged in.;402: insufficient credits.;500: service configuration or downstream error.

Sample request

curl -X POST https://nanobananapro.cloud/api/v1/image/nano-banana \
  -H "Authorization: Bearer api-key" \
  -F "prompt=A banana cat in a spacesuit on the moon" \
  -F "model=nano-banana-2" \
  -F "mode=image-to-image" \
  -F "aspectRatio=auto" \
  -F "imageSize=1K" \
  -F "outputFormat=png" \
  -F "isPublic=true" \
  -F "imageFile=@/path/to/ref.png" \
  -F "imageUrl=https://example.com/ref2.png"

Sample response

{
  "code": 0,
  "message": "ok",
  "data": {
    "id": "task-id-xxx",
    "results": [],
    "progress": 0,
    "status": "running",
    "failure_reason": null,
    "error": null,
    "credits_cost": 20
  }
}

Check result

POST /api/v1/image/nano-banana/result to fetch progress and image URLs; failed tasks auto-refund.

Method: POSTPath: /api/v1/image/nano-banana/result
Payload: taskId or id (string). Response fields mirror generation; when status=failed, credits are already refunded.
Failure cases400: missing task ID.;401: not logged in.;500: downstream query failure or service error.

Sample request

curl -X POST https://nanobananapro.cloud/api/v1/image/nano-banana/result \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer api-key" \
  -d '{
    "taskId": "task-id-xxx"
  }'

Sample response

{
  "code": 0,
  "message": "ok",
  "data": {
    "id": "task-id-xxx",
    "results": [
      {
        "url": "https://example.com/generated.png",
        "content": "A banana cat in a spacesuit on the moon"
      }
    ],
    "progress": 100,
    "status": "succeeded",
    "failure_reason": null,
    "error": null
  }
}

Start with nano-banana-2

Create your API key, then integrate nano-banana-2 with the samples on this page.