APIMODELSAPIMODELS
Documentação da API

apimodels.app

Docs/Image/Nano Banana 2.1 API

Nano Banana 2.1 API

Google's high-efficiency image model for generation and editing, model id nano-banana-2-1. Text-to-image and editing are the same model: a prompt alone generates, a prompt plus reference images (up to 10) edits or combines them. Fifteen aspect ratios, 1K / 2K / 4K output at $0.022 / $0.036 / $0.06 per image, charged only on success.

Autenticação

Every request carries your API key in the header:

Authorization: Bearer YOUR_API_KEY

Pricing (per image, by resolution)

resolutionPrice / imageNotas
1K$0.022Default tier
2K$0.036
4K$0.06Top tier

Price depends on resolution only — the number of reference images, the aspect ratio and the prompt length do not change it. Omitting resolution bills 1K. Failed requests are not charged. Examples: 100 images at 1K = $2.20, at 2K = $3.60, at 4K = $6.00.

Text-to-image

POST/v1/images/generations

Async contract: creating a task returns a taskId immediately; poll GET /v1/images/generations?task_id= until state is completed and read resultUrls, or pass a callback_url to receive a webhook. The request below is the one from our first test on 2026-10-07: 16:9 at 1K, about 20 seconds, delivered at 1376×768 with the sign text spelled correctly.

# Step 1: create the task (text-to-image) — returns a taskId right away
curl -X POST https://api.apimodels.app/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2-1",
    "prompt": "A cozy bookstore cafe on a rainy evening, warm window light, a hand-painted sign reading NANO BANANA 2.1 above the door, cinematic wide shot",
    "aspect_ratio": "16:9",
    "resolution": "1K"
  }'
# → { "code": 200, "data": { "taskId": "...", "state": "pending", "model": "nano-banana-2-1" } }

# Step 2: poll until state is "completed" (or "failed")
curl "https://api.apimodels.app/v1/images/generations?task_id=TASK_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"
# → { "code": 200, "data": { "state": "completed", "resultUrls": ["https://..."] } }

Editing · multi-reference

Same endpoint, same model id: include image (one) or image_urls (an array) and the request becomes an edit; the two together accept up to 10 images. Each can be a URL, a data URI or bare base64, in JPEG, PNG or WebP. Refer to them in the prompt as image 1, image 2 and so on.

# Edit one image — image accepts a URL, a data URI or bare base64
curl -X POST https://api.apimodels.app/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2-1",
    "prompt": "Keep the room and the lighting, replace the sofa with a dark green velvet one",
    "image": "https://example.com/living-room.jpg",
    "resolution": "2K"
  }'

# Combine several references — image_urls takes up to 10 (image + image_urls together: 10 max)
curl -X POST https://api.apimodels.app/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2-1",
    "prompt": "Put the character from image 1 into the street scene from image 2, wearing the jacket from image 3",
    "image_urls": [
      "https://example.com/character.png",
      "https://example.com/street.jpg",
      "https://example.com/jacket.jpg"
    ],
    "aspect_ratio": "4:5",
    "resolution": "2K"
  }'
# Poll GET ?task_id= exactly as in the text-to-image example.

Parâmetros da requisição

FieldRequiredTypeDescription
modelYesstringnano-banana-2-1
promptYesstringImage description or editing instruction, up to 20,000 characters
imageNostringOne reference image: URL, data URI or bare base64 (image_url / image_base64 also work)
image_urlsNostring[]Several reference images, up to 10 together with image; more than 10 returns a 400
aspect_ratioNostringauto, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1. Default auto
resolutionNostring1K (default) / 2K / 4K — sets the price
callback_urlNostringWebhook URL called when the task finishes, instead of polling

Task states

  • pending / processing: still generating — check again in 2–3 seconds
  • completed: data.resultUrls holds the image link
  • failed: data.failMsg gives the reason; the request is not charged

Choosing within the Nano Banana family

  • gemini-3.1-flash-image (Nano Banana 2, GA): $0.06 at 1K/2K, $0.10 at 4K, plus a 512 tier at $0.04. Every shared tier costs more than Nano Banana 2.1.
  • nanobanana2 (Nano Banana 2, preview channel): $0.05 at 1K/2K, $0.08 at 4K.
  • nanobanana-2-lite: flat $0.025, 1K only, also up to 10 reference images.
  • nanobananapro (Nano Banana Pro, Gemini 3 Pro Image): $0.068 at 1K/2K, $0.13 at 4K — for the highest fidelity and text-rendering ceiling.

All of them use the same endpoint and parameters, so switching is a one-string change to model.

Notas

  • One image per request; for several, send requests in parallel — each is billed and queried on its own.
  • An aspect_ratio outside the list above returns a 400 rather than being silently swapped for another ratio.
  • Result files are deleted after 30 days; download or re-host them in time.
  • Failed requests are never charged.

Try it in the Playground — pick the ratio and resolution and upload references without writing code.

Perguntas frequentes

How much does the Nano Banana 2.1 API cost?

Per image, by resolution only: $0.022 at 1K (the default), $0.036 at 2K and $0.06 at 4K. Reference images, aspect ratio and prompt length do not change the price, and failed requests are not charged.

How do I send reference images to Nano Banana 2.1?

Pass image for a single reference or image_urls for an array; together they accept up to 10 images, and more than 10 returns a 400. Each entry can be a URL, a data URI or bare base64 in JPEG, PNG or WebP. Use image_urls rather than images for the array — that is the field the image endpoint reads.

Which aspect ratios does Nano Banana 2.1 support?

Fifteen: auto (the default), 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, and the extreme 1:4, 4:1, 1:8 and 8:1 for banners and tall strips. Any other value returns a 400 instead of being swapped for a nearby ratio.