How To Use Nano Banana: A Step-by-Step Integration Guide (2026)

Modellix cover illustration for a step-by-step guide on how to use Nano Banana, Google's Gemini image model, from your own code

If you want to use Nano Banana from your own code, the short version is this: Nano Banana is Google’s name for Gemini’s native image generation, and you reach it one of two ways — Google’s official Gemini API, or a unified API such as Modellix that puts many image models behind one key. Either way the code path is the same shape: get an API key, send a request with your prompt, and get an image back. The one wrinkle most tutorials skip is that image generation is an asynchronous job — you submit a task, then poll for the result — and this guide walks that whole loop end to end.

Everything below is verified against the providers’ own docs on July 23, 2026. Model names and prices move, so treat the numbers as a dated snapshot and re-check the linked pages before you ship.

What Nano Banana actually is (30 seconds)

“Nano Banana” is a nickname, not a separate product. In Google’s own words, “Nano Banana is the name for Gemini’s native image generation capabilities.” So when you use Nano Banana, you are using a Gemini image model under the hood. Google is the model maker here; the API you call is just how you reach it.

The Nano Banana family maps to concrete Gemini model IDs:

Nano Banana name Underlying Gemini model ID Role
Nano Banana (base) gemini-2.5-flash-image (legacy) Original fast creative model, superseded by 2
Nano Banana 2 gemini-3.1-flash-image Generalist workhorse, fast text-to-image
Nano Banana 2 Lite gemini-3.1-flash-lite-image Cheapest/fastest, high-volume drafts
Nano Banana Pro gemini-3-pro-image Highest fidelity, complex compositions

For most integration work you will call Nano Banana 2 (gemini-3.1-flash-image), the balanced default. The rest of this guide uses it as the worked example.

Which family member should you call? A quick rule of thumb, taken from the models’ own routing notes: default to Nano Banana 2 for general fast text-to-image; drop to Nano Banana 2 Lite when cost and throughput matter more than peak quality (high-volume batches, drafts, thumbnails); step up to Nano Banana Pro for high-quality stylized art and complex compositions. For strict, high-end photorealism, none of the Nano Banana models is the ideal tool — the model’s own tips point to Google’s Imagen 4 series, but note Google has deprecated Imagen 4 with a shutdown date of August 17, 2026, so for new work weigh current options like Seedream or GPT Image instead (see our roundup of other text-to-image models). You do not have to commit up front: on a unified API the model is just a string in the URL path, so you can A/B two members with the same request body and compare.

Two ways to use Nano Banana: official API vs unified API

There are two legitimate access paths, and picking the right one matters more than any single line of code.

Path A — Google’s official Gemini API. You call Google directly. The base host is generativelanguage.googleapis.com, you authenticate with a Gemini API key, and you request an image model such as gemini-3.1-flash-image. Billing is token-based: for Nano Banana 2, Google charges about $0.50 per 1M input tokens and $60 per 1M output-image tokens, which works out to roughly $0.045–$0.151 per image depending on resolution.

Path B — a unified API (Modellix). Instead of integrating one provider at a time, you call one endpoint with one key and swap the model name in the path — Nano Banana today, a different image or video model tomorrow. Modellix is one such Model-as-a-Service layer; it is a distribution layer, not the model’s maker. Billing here is quoted per image rather than per token, and the interface is a uniform async task for every model.

Official Gemini API Unified API (Modellix)
You integrate One provider (Google) One key across many image/video models
Billing model Per token (per-image equivalent) Per image
Interface Gemini SDK / API Uniform submit-and-poll async task
Best when You only need Google’s models and want the source of truth You want to compare or mix providers without re-integrating

Both routes call the same Google model, so image quality is identical; which one is “better” depends only on whether you want a single provider or one key across many models — not on either platform being cheaper or exclusive. The steps below use the unified-API path because its request/response is fully documented and easy to reproduce; the same key-to-image logic applies to the official path.

How to use Nano Banana 2 via a unified API — step by step

Here is the full loop, from zero to a saved image.

Step 1 — Get an API key. Log in to the Modellix console and open “API Key” to create one (on the official Google path, you generate a key from the Google AI Studio API key page instead). The key is displayed only once after creation, so copy and store it immediately.

Step 2 — Pick the model and endpoint. Nano Banana 2 lives at POST /google/nano-banana-2. The full async submit URL is https://api.modellix.ai/api/v1/google/nano-banana-2/async.

Step 3 — Set your parameters. Only prompt is required.

Parameter Type Required Values
prompt string Yes Your image description
aspectRatio string No 14 options: 1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9
imageSize string No 512, 1K, 2K, 4K
Modellix Nano Banana 2 model page showing price $0.0403 to $0.1248 per image and the prompt, aspectRatio, and imageSize input parameters

The Nano Banana 2 model page on Modellix: the required prompt field plus optional aspectRatio (1:1 selected) and imageSize, next to the per-image price band $0.0403–$0.1248. Captured July 23, 2026.

Step 4 — Submit the task. Because generation is asynchronous, a successful POST does not return an image — it returns a task_id and a URL to fetch the result later, with an initial status of pending.

Step 5 — Poll for the result. Call GET /api/v1/tasks/{task_id} until the status is success, then read the image URL from data.result.resources[].url. If you would rather not poll, send an X-Webhook-URL header when you submit and Modellix will POST the result to your public HTTPS endpoint when the task finishes.

Step 6 — Save the image. Generated results are only kept for 7 days, so download and store the asset promptly.

Here is the whole loop in curl — submit, then poll:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 1) Submit the generation task
curl --request POST \
--url https://api.modellix.ai/api/v1/google/nano-banana-2/async \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"prompt": "A blue fiber-optic spool on a clean white studio backdrop, product photography",
"aspectRatio": "1:1",
"imageSize": "2K"
}'

# Response includes a task_id and a get_result URL:
# {
# "code": 0,
# "message": "success",
# "data": {
# "status": "pending",
# "task_id": "task-abc123",
# "get_result": {
# "method": "GET",
# "url": "https://api.modellix.ai/api/v1/tasks/task-abc123"
# }
# }
# }

# 2) Poll the task until status == "success"
# Replace task-abc123 below with the real task_id from the response above
curl --request GET \
--url https://api.modellix.ai/api/v1/tasks/task-abc123 \
--header 'Authorization: Bearer <YOUR_API_KEY>'

# On success, the image URL is in data.result.resources[].url
Modellix REST API docs showing a POST to the async endpoint returning a JSON response with status pending and task_id task-abc123

Modellix’s REST API docs: the POST .../async submit call (top box) returns a task_id — here task-abc123 with status pending — exactly the submit-then-poll loop the code above follows. Captured July 23, 2026.

To move this to a real service, wrap the two calls in a loop with exponential backoff on the poll (say 1s → 2s → 4s), or register a webhook and skip polling entirely. Swap nano-banana-2 in the path for nano-banana-2-lite or nano-banana-pro and the rest of the code is unchanged — that path-swap is the whole point of a unified API.

How much does it cost?

One line, because price deserves its own page. On the unified path, Nano Banana 2 is billed per image: $0.0403 at 512, $0.0575 at 1K, $0.0851 at 2K, and $0.1248 at 4K. On Google’s official path the same model is billed per token, which comes out to roughly $0.045 / $0.067 / $0.101 / $0.151 per image across the same sizes.

Those are snapshots that drift, and the full breakdown — every family member, batch discounts, size-by-size — belongs in the dedicated price write-ups. For the family overview see the Nano Banana price guide; for the “2” variant’s live per-image band, the Nano Banana 2 model page is the source of truth.

Common gotchas and tips

  • It’s asynchronous, not instant. The single most common surprise: your POST returns a task_id, not an image. You must poll the task URL or register a webhook.
  • A 400 means your prompt is missing or malformed. prompt is the only required field; a 400 is a parameter error you fix, not one you retry.
  • A 429 means you hit a rate or concurrency limit. Back off exponentially and check the X-RateLimit-Reset header for when to retry. 500 and 503 are also retryable with backoff; 401 (bad key) and 402 (insufficient balance) are not — fix the cause first.
  • Store the key on creation. It’s shown once. And top up before a batch run so you don’t hit a 402 mid-job.
  • Choose aspectRatio before you generate, so the composition matches its final channel, and iterate at 512 or 1K before spending on 2K/4K finals.
  • Download within 7 days. Results are purged after that; treat the returned URL as temporary.

FAQ

Is Nano Banana the same as Gemini? Effectively yes — Nano Banana is Google’s name for Gemini’s native image generation, so you’re always calling a Gemini image model.

Do I need Google Cloud to use Nano Banana? No. You need an API key — either an official Gemini API key from Google, or a key from a unified API like Modellix that fronts the same model.

Why don’t I get the image back immediately? Image generation runs as an asynchronous task. The submit call returns a task_id; you then poll GET /tasks/{task_id} or receive a webhook when it’s done.

What’s the only required parameter? prompt. Both aspectRatio (14 options) and imageSize (512/1K/2K/4K) are optional.

How long are generated images kept? On the unified API, results are stored for 7 days — download and persist them promptly.