Choose Auto, TokenLab Verified, or Official for each request, with prices shown up front. See what's new

Nano Banana API Guide: Image Generation and Editing on TokenLab

·September 19, 2026·12 min read·Updated November 13, 2026·2492 views
#nano-banana#image-generation#image-editing#api-guide
Nano Banana API Guide: Image Generation and Editing on TokenLab

What you’ll learn

  • How much does a Nano Banana image cost on TokenLab?
  • Which Nano Banana model ID should I send for image-to-image requests?
  • Why did my image request return a task_id instead of an image?
  • Can I get base64 output from a Nano Banana model?
  • Is a failed image task charged?

Nano Banana models on TokenLab are priced per image. On 2026-11-11 the TokenLab price runs from $0.0168 for nano-banana-2.1 at 1k to $0.12 for nano-banana-pro at 4k. The expensive mistake is rarely the model choice. It is sending an edit request to the wrong endpoint, or retrying a create call that already made a task. This guide covers the exact IDs and prices, a text-to-image call, a reference-image call, async polling, expected errors, and how the charge is set. Prices were read on 2026-11-11. Confirm them again before you ship.

Key Takeaways

  • Send an exact ID: nano-banana, nano-banana-2, nano-banana-2-lite, nano-banana-2.1, or nano-banana-pro.
  • All five are priced per image. The price depends on the model and, for most of them, on the resolution (1k, 2k, or 4k).
  • Reference-image and edit work goes to POST /v1/images/generations with operation: "image-to-image" or "image-edit". It does not go to /v1/images/edits or /v1/chat/completions.
  • All five list async. Send async: true to get a task, or handle a task response when one comes back, and poll GET /v1/tasks/{id}.
  • A status read returns HTTP 200 even when the task failed. Branch on the task's status field, not on the HTTP code.
  • Final charges live in Usage and in billing_transaction_id, not in a copied price table.

Nano Banana models, resolutions, and prices

The table shows the TokenLab price, which is the Verified delivery price, and the Official price, which is the price of Official delivery. Both are USD per image, read on 2026-11-11 from the pricing API.

Model ID Resolution TokenLab price Official price
nano-banana No resolution field $0.0195 $0.039
nano-banana-2 1k $0.0335 $0.067
nano-banana-2 2k $0.0505 $0.101
nano-banana-2 4k $0.0755 $0.151
nano-banana-2.1 1k $0.0168 $0.0336
nano-banana-2.1 2k $0.0252 $0.0504
nano-banana-2.1 4k $0.0565 $0.113
nano-banana-2-lite 1k only $0.0168 $0.0336
nano-banana-pro 1k $0.067 $0.134
nano-banana-pro 2k $0.067 $0.134
nano-banana-pro 4k $0.12 $0.24

Operations: nano-banana lists text-to-image and image-edit. The other four list text-to-image, image-to-image, and image-edit. nano-banana takes aspect_ratio only. nano-banana-2-lite takes 1k only.

Send resolution yourself on the models that list it, so the price is the one you expect.

A rough budget is the price times the volume. These are estimates, not quotes:

100 images on At 1k At 4k
nano-banana 100 x $0.0195 = $1.95 Not available
nano-banana-2-lite 100 x $0.0168 = $1.68 Not available
nano-banana-2.1 100 x $0.0168 = $1.68 100 x $0.0565 = $5.65
nano-banana-2 100 x $0.0335 = $3.35 100 x $0.0755 = $7.55
nano-banana-pro 100 x $0.067 = $6.70 100 x $0.12 = $12.00

The Gemini-named image IDs are a different family. gemini-nano-banana-2.1, gemini-3.1-flash-image, gemini-3.1-flash-lite-image, and gemini-3-pro-image are priced per token, not per image. Their image-edit requests go to /v1/images/edits. The Create Image reference lists which ID uses which endpoint.

To list current image models, call the endpoint the image generation guide uses:

curl "https://api.tokenlab.sh/v1/models?recommended_for=image" \
  -H "Authorization: Bearer sk-your-api-key"

For one model's operations, fields, and lifecycle, use Get a Model. You can also browse the TokenLab model directory.

Send a text-to-image request

Create an API key in the TokenLab dashboard and export it:

export TOKENLAB_API_KEY="your-tokenlab-api-key"

Always send model. Image APIs have no default model, and a missing model returns a 400 with param: "model". This request uses nano-banana-2.1 at 1k:

curl -X POST "https://api.tokenlab.sh/v1/images/generations" \
  --max-time 120 \
  -H "Authorization: Bearer $TOKENLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2.1",
    "prompt": "A minimalist ceramic vase on a natural wooden table, studio lighting",
    "aspect_ratio": "1:1",
    "resolution": "1k",
    "response_format": "url"
  }'

The --max-time 120 flag follows the reference: high-resolution requests can take close to a minute or longer, so set your client timeout to at least 120 seconds. For Google image families, prefer aspect_ratio with resolution. A size of 1K, 2K, or 4K is sent as resolution.

A synchronous success returns the finished image. The URL below is a placeholder:

{
  "created": 1700000000,
  "data": [
    { "url": "https://example.com/generated-image.png" }
  ]
}

Read the response in this order:

  1. If the body has task_id, status: "pending", or poll_url, you have a task, not an image. Go to the polling section.
  2. Otherwise read data[0].url. With response_format: "b64_json", read data[0].b64_json instead.
  3. created is a Unix timestamp. revised_prompt appears only when the model returns one, so do not require it.
  4. Store the image URL, your own job ID, the model, and the request_id from the response headers.

Result URLs stay valid for 30 days. Check media_retention.items for each item's status and expires_at, and copy the file to your own storage if you need it longer. See the data retention guide.

Edit an image with a reference URL

Imagine a catalog team that wants the same product shot on a clean studio background. The tempting move is /v1/images/edits. For Nano Banana it is the wrong endpoint. Reference-image requests for nano-banana-2, nano-banana-2.1, nano-banana-2-lite, and nano-banana-pro go to /v1/images/generations with operation: "image-to-image". Image-edit requests for the same four IDs also use that endpoint, with operation: "image-edit". A request sent to the wrong endpoint returns 400 unsupported_endpoint.

This request follows the image generation guide:

curl https://api.tokenlab.sh/v1/images/generations \
  -H "Authorization: Bearer $TOKENLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2",
    "operation": "image-to-image",
    "prompt": "Keep the product shape, change the background to a bright studio setup",
    "image_urls": ["https://example.com/input/product.png"],
    "aspect_ratio": "1:1"
  }'

Rules for this shape:

  • Use the documented reference fields. Send image_url, image_urls (up to 16), or reference_image_urls (up to 16) in JSON. Do not send top-level images[] or file_id. They belong to the edit flow and are not accepted here.
  • Use public URLs. They must be http or https, with no embedded credentials, no fragments, and no private network hosts. Avoid signed URLs that may expire before processing starts.
  • Use multipart for private sources. Send a multipart image file when the source is private or header-protected.
  • Match resolution to the model. nano-banana takes no resolution. nano-banana-2-lite takes 1k only.
  • Send only listed fields. Read GET /v1/models/{model} before you send fields such as a mask or a strength value. A field the model does not list can return 400 unsupported_parameter.

When an image request becomes a task, and how to poll it

An image create call is either synchronous or asynchronous, and the response tells you which. If it carries task_id, status: "pending", or poll_url, the data[] array is empty and the work is still running. Models that list async among their supported parameters accept "async": true, which asks for a task up front. All five Nano Banana IDs list it on 2026-11-11. A model that does not list it returns 400 unsupported_async_mode.

Imagine a browser refresh that re-sends the create call after a slow response. You now pay for two generations. The async jobs guide says most duplicate generations come from this retry. For a request that returns a task, an Idempotency-Key header makes the retry safe. Follow this order:

  1. Save IDs immediately. Store id or task_id, poll_url, the model, the endpoint, and your own job ID. id and task_id are the same value.
  2. Poll the URL. Use poll_url when present. Otherwise call the fixed route:
    curl "https://api.tokenlab.sh/v1/tasks/$TASK_ID" \
      -H "Authorization: Bearer $TOKENLAB_API_KEY"
    
  3. Poll every 3 to 5 seconds. The image task reference says that is enough while the status is pending or processing.
  4. Know the statuses. They are pending, processing, completed, and failed. A cancelled task shows failed with cancelled: true.
  5. Stop at a terminal status. On completed, read data[].url. Async image results are URLs only, never b64_json. On failed, read error and error_details.
  6. Handle timeouts safely. If a create call times out before you see a response, check the request_id and look for a task before you retry. If you stored a task ID, resume polling it. If a status poll fails, retry that poll with backoff and do not create again.

A status read returns HTTP 200 even for a failed task. Failed tasks may include error_details with status, type, code, message, param, and retryable. For example, error_details.status: 400 with param: "size" means the request needs correction. It does not mean the poll itself failed. Retrying a failed generation creates a new task and may create a new charge.

Errors to expect and what to do

Handle errors by HTTP status and code, never by message. The error handling guide says the message can change without notice. Chat Completions and Responses use an OpenAI-style error object, while Gemini and Anthropic formats keep their own shapes. Do not share one parser across all TokenLab APIs.

Status / code Likely cause What to do
400, param: "model" No explicit model Send model. List IDs with /v1/models?recommended_for=image.
400 unsupported_parameter A field the model does not list, such as resolution on nano-banana Remove the field or switch model. Do not repeat unchanged.
400 unsupported_endpoint The operation belongs on another endpoint Use /v1/images/generations for Nano Banana reference images and edits.
400 on a reference image Wrong endpoint, or a private or expired URL Use image_urls with a public, stable URL.
401 invalid_api_key or expired_api_key Missing, revoked, or expired key Replace the key.
402 insufficient_balance or quota_exceeded Balance too low, or the key hit its own limit Add funds, raise the key limit, or choose a lower-priced model.
403 model_not_allowed The key cannot use that model Update the key's model list.
404 model_not_found Unknown or unavailable ID Read /v1/models and use a current ID.
413 request_too_large or file_too_large An upload is over 50 MiB per file or 200 MiB for all inputs Reduce the input.
429 rate_limit_exceeded Too many requests in the window Wait for Retry-After, then retry.
500 to 504, all_channels_failed Service or supply problem Retry only when retryable is true. Respect retry_after and cap attempts.

A 503 all_channels_failed does not always mean an outage. If retryable is false and retry_after is missing, the operation has no supply in the selected Delivery tier. Repeating the request will not help, so check GET /v1/models first.

Task polling has its own failures:

  • 404 async_task_not_found: the task expired or is gone. Check the saved task_id and poll_url.
  • 403 task_not_owned: the task belongs to another workspace. Check which workspace the API key belongs to.
  • 503 async_task_owner_unavailable: the task cannot be read right now. Retry the poll with backoff.
  • A completed task with no media URL: treat it as failed. Keep the IDs and contact support.

When you contact support, send request_id, task_id, billing_transaction_id when present, endpoint, model, time, and field names. Never send keys, private media, or signed URLs.

How the charge for an image request is determined

All five Nano Banana IDs use the per_image unit, so the charge is the price of the model and resolution you requested. The billing guide adds the rules around it:

  • One result, one charge. Each completed request is charged once, for the delivery option that produced it. Verified uses the TokenLab price. Official uses the Official price. Auto tries Verified first, then Official.
  • Resolution sets the number. On nano-banana-2, nano-banana-2.1, and nano-banana-pro, a 4k image costs more than a 1k image. See the table above.
  • Tasks reserve first. An async task may reserve its estimated cost when accepted. A completed task is charged once, and a failed task releases or refunds the pending amount. A failed task is not charged.
  • A dash is not free. On the Models page, a dash in the TokenLab price column means no Verified offer is available right now.

To confirm a charge, use these places:

  1. GET /v1/models/:model/pricing or the Pricing API for the current price.
  2. Console, which shows the maximum estimate before you confirm paid generation.
  3. Usage for the final charge by model.
  4. billing_transaction_id in the response or task, and the X-Billing-Transaction-ID header.

If Usage does not show the final charge or the released amount after a task finishes, send the Request ID and task ID to hello@tokenlab.sh. Do not copy the prices in this article into your code. The billing guide says to read the current price when your application needs to display or compare costs.

FAQ

How much does a Nano Banana image cost on TokenLab?

On 2026-11-11 the TokenLab price runs from $0.0168 to $0.12 per image. nano-banana is $0.0195. nano-banana-2.1 is $0.0168, $0.0252, and $0.0565 at 1k, 2k, and 4k. nano-banana-pro is $0.067 at 1k and 2k, and $0.12 at 4k. Read the current price from the pricing API before you budget.

Which Nano Banana model ID should I send for image-to-image requests?

Send nano-banana-2, nano-banana-2.1, nano-banana-2-lite, or nano-banana-pro with operation: "image-to-image" and image_urls to /v1/images/generations. nano-banana lists text-to-image and image-edit. Run a small test on your own images to compare output.

Why did my image request return a task_id instead of an image?

The create call ran as an async task. Look for task_id, status: "pending", or poll_url in the response. Save those fields, then poll poll_url or GET /v1/tasks/{id} every 3 to 5 seconds until the status is completed or failed. Do not send a second create request while you wait.

Can I get base64 output from a Nano Banana model?

The response_format field accepts url or b64_json, and a synchronous request can return data[].b64_json. Async image results are URLs only, whatever format you asked for. Check the selected model's details, because fields differ by model. nano-banana-2-lite and nano-banana-pro do not list response_format.

Is a failed image task charged?

No. The billing guide says a failed task is not charged, and any pending reservation is released or refunded. Retrying a failed generation creates a new task and may create a new charge. Confirm the outcome in Usage using the billing_transaction_id and task_id.

Create a key in the TokenLab dashboard, send the text-to-image request above, and check the charge in Usage.

Sources

Prices checked 2026-11-11

Prepared by TokenLab's AI agents. Facts are checked against the linked primary sources on the date shown.

Related models

Recent model releases

Try the models from this article

Chat, create images, or make video with the same TokenLab balance.

Your first API call

Get your API key
curl https://api.tokenlab.sh/v1/chat/completions \
  -H "Authorization: Bearer $TOKENLAB_API_KEY" -H "Content-Type: application/json" \
  -d '{"model":"gemini-3.8-flash","messages":[{"role":"user","content":"Hello!"}]}'