api.foo
api.foo / Docs / Nano Banana API pricing and setup

Nano Banana API (October 2026): Nano Banana 2.1, 2 Lite and Pro Pricing, API Key and Python Examples

Updated · Tested on: macOS · Python google-genai 2.31.0 (request formats and error messages)
On this page

Short answer: "Nano Banana" is Google's name for Gemini's image generation models. Use Nano Banana 2.1 (gemini-nano-banana-2.1) for most work: about $0.034 per 1K image and $0.113 per 4K image. Use Nano Banana Pro (gemini-3-pro-image) for the hardest jobs: about $0.134 per 1K/2K image and $0.24 per 4K image. The Batch API halves both. There's no free tier for these models in the API. You need a Gemini API key from Google AI Studio with billing enabled.

Prices and model details below are from Google's Gemini API documentation on October 17, 2026. We ran the code examples against a test endpoint and recorded the real error messages.

The Nano Banana models

Name Model ID Best for Output sizes
Nano Banana 2.1 gemini-nano-banana-2.1 The default: fast generation and conversational editing, better text rendering 1K (default), 2K, 4K
Nano Banana 2 Lite gemini-3.1-flash-lite-image Lowest latency (under 2 seconds), high volume, simple edits 1K only
Nano Banana 2 gemini-3.1-flash-image Previous workhorse; Google recommends 2.1 for new projects 0.5K, 1K, 2K, 4K
Nano Banana Pro gemini-3-pro-image Complex scenes, world knowledge, localization, brand consistency 1K, 2K, 4K
Nano Banana (original) gemini-2.5-flash-image Legacy; Google suggests moving to 2 Lite

All generated images carry Google's invisible SynthID watermark.

Pricing

Google bills image output by tokens and publishes the equivalent price per image. Standard and Batch prices per image, in USD:

Model 0.5K 1K 2K 4K
Nano Banana 2.1 $0.0336 (Batch $0.0168) $0.0504 ($0.0252) $0.113 ($0.0567)
Nano Banana 2 Lite $0.0336 ($0.0168)
Nano Banana 2 $0.045 ($0.022) $0.067 ($0.034) $0.101 ($0.050) $0.151 ($0.076)
Nano Banana Pro $0.134 ($0.067) $0.134 ($0.067) $0.24 ($0.12)
Nano Banana (original) $0.039 ($0.0195)

Notes:

  • Nano Banana 2.1 is half the price of Nano Banana 2 at 1K and 2K while improving quality, so there's little reason to stay on 2.
  • Pro at 2K costs the same as at 1K, so if you use Pro, ask for 2K.
  • Text and image inputs are billed too, but they're small: Nano Banana 2.1 charges $1.50 per million input tokens. Its "thinking" is billed as text output at $7.50 per million tokens.
  • No free tier: the pricing page marks every Nano Banana model "Not available" on the free tier.

Example: 1,000 product shots at 1K with Nano Banana 2.1 cost about $33.60, or $16.80 through the Batch API. 100 4K hero images with Nano Banana Pro cost about $24.

Compared with other image APIs

Model Typical price per image
Nano Banana 2.1, 1K $0.034
OpenAI GPT Image 2, 1024×1024 $0.006 (low), $0.053 (medium), $0.211 (high)
xAI Grok Imagine $0.02 (grok-imagine-image), $0.04 (image 2.0), $0.05 (quality)
Nano Banana Pro, 1K/2K $0.134

Quality differs as much as price, so generate the same prompts on two or three models before committing. See our Grok API page for Grok Imagine details.

Get an API key

  1. Sign in to Google AI Studio and create an API key under Dashboard → API Keys. New users get a default project and key automatically.
  2. Enable billing. On the Projects page, click Set up billing for your project. New accounts prepay at least $5. When the prepaid balance reaches zero, requests fail with HTTP 402.
  3. Save the key as GEMINI_API_KEY. The official SDK reads it automatically.

Since May 28, 2026, keys created in AI Studio are authorization keys bound to a service account, and Google rejects unrestricted standard API keys. If you created an old-style key in the Google Cloud console, add an API restriction or create a new key in AI Studio. Also check Google's available regions list.

Interactions API or generateContent?

Google's image generation guide now uses the Interactions API, which became generally available in June 2026 and is recommended for new projects. The older generateContent API is now labelled legacy but remains fully supported, and two things still need it:

  • The Batch API (the 50% discount) isn't available through Interactions yet.
  • Most third-party gateways implement generateContent but not yet /v1beta/interactions.

Generate an image with the Interactions API

import base64
from google import genai

client = genai.Client()  # reads GEMINI_API_KEY
interaction = client.interactions.create(
    model="gemini-nano-banana-2.1",
    input="A glossy magazine cover with the words NANO BANANA in a serif font",
)
with open("cover.png", "wb") as f:
    f.write(base64.b64decode(interaction.output_image.data))

Generate an image with generateContent

from google import genai
from google.genai import types

client = genai.Client()  # reads GEMINI_API_KEY
response = client.models.generate_content(
    model="gemini-nano-banana-2.1",
    contents="A glossy magazine cover with the words NANO BANANA in a serif font",
    config=types.GenerateContentConfig(
        response_modalities=["TEXT", "IMAGE"],
        image_config=types.ImageConfig(aspect_ratio="3:4", image_size="2K"),
    ),
)
for part in response.parts:
    if part.inline_data is not None:
        part.as_image().save("cover.png")
    elif part.text:
        print(part.text)

Google's generateContent guide sets the size with response_format={"image": {...}}. The google-genai SDK (2.31.0, October 2026) rejects that with Extra inputs are not permitted [type=extra_forbidden …]. Use image_config=types.ImageConfig(...) as above.

Edit an image

Pass the source image along with the instruction in contents, for example contents=[Image.open("photo.png"), "Replace the background with a beach at sunset"]. Nano Banana 2.1 accepts up to 14 reference images and keeps up to 4 characters and 10 objects consistent across them, which makes it useful for product shots and character series. For several rounds of edits on the same image, use a chat session so the model keeps the previous result.

Options worth knowing

  • Aspect ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9 and 21:9, plus panoramic 1:4, 4:1, 1:8 and 8:1 on Nano Banana 2 and 2.1.
  • Resolution (image_size): 1K, 2K or 4K. Nano Banana 2 also offers 0.5K; 2 Lite supports 1K only.
  • Grounding with Google Search: Nano Banana 2 and 2.1 can look up web and image search results to draw real places, products or animals more accurately.
  • Thinking level on 2.1: minimal, medium (default) or high. Higher levels cost more text-output tokens.
  • Interleaved output: ask for an illustrated story or a step-by-step guide and you get text and images in one response.

Errors you'll actually see

Error Cause Fix
400 API key not valid. Please pass a valid API key. (API_KEY_INVALID) Wrong, revoked or unrestricted key Re-copy the key, or create a new one in AI Studio
Extra inputs are not permitted [type=extra_forbidden] (Python) response_format copied from Google's guide Use image_config
404 Invalid URL (POST /v1beta/interactions) The endpoint you're calling doesn't support the Interactions API Use generate_content
402 Payment Required Prepaid balance is used up Add credit or turn on auto-reload; don't retry
429 RESOURCE_EXHAUSTED Rate limit or spend-based limit for your tier Back off and retry; image models count images per minute
404 model not found Wrong model ID Check the IDs in the table above

Using Nano Banana through a gateway

If you already use another model provider's gateway, it may serve Nano Banana as well. api.foo, the service that publishes these docs, serves Gemini image models through the generateContent format: set http_options=types.HttpOptions(base_url="https://api.foo") in genai.Client and keep the rest of the generateContent example above. We confirmed with a test key that requests reach /v1beta/models/gemini-nano-banana-2.1:generateContent. It doesn't support the Interactions API yet, which returns 404. Its exact model names and per-image prices are on the api.foo pricing page. Some Gemini image model names there include a -preview suffix.

Sources

Gemini API documentation, checked October 17, 2026: Nano Banana image generation (Interactions), image generation with generateContent, Interactions API overview, pricing, model pages for Nano Banana 2.1, 2 Lite, 2 and Pro, API keys, billing and rate limits. OpenAI and xAI image prices from their pricing pages on the same date.

FAQ

How much does the Nano Banana API cost?

As of October 17, 2026, Nano Banana 2.1 (gemini-nano-banana-2.1) costs about $0.034 per 1K image, $0.050 per 2K image and $0.113 per 4K image. Nano Banana Pro (gemini-3-pro-image) costs about $0.134 per 1K or 2K image and $0.24 per 4K image. The Batch API halves these prices.

Is the Nano Banana API free?

No. Google's Gemini API pricing page lists no free tier for any Nano Banana model; they're available only on the paid tier, which needs a billing account and, for new accounts, at least $5 of prepaid credit.

What's the difference between Nano Banana 2.1 and Nano Banana Pro?

Nano Banana 2.1 is the fast, cheap workhorse for generation and conversational editing, with 1K, 2K and 4K output. Nano Banana Pro is the premium model for the most complex tasks, with more world knowledge and precise brand consistency, and costs about four times as much at 1K.

What's the model name for Nano Banana in the API?

gemini-nano-banana-2.1 for Nano Banana 2.1, gemini-3.1-flash-lite-image for Nano Banana 2 Lite, gemini-3.1-flash-image for Nano Banana 2, gemini-3-pro-image for Nano Banana Pro, and gemini-2.5-flash-image for the original Nano Banana.

Should I use the Interactions API or generateContent for Nano Banana?

Google recommends the Interactions API for new projects and uses it in its image generation guide. generateContent is now called legacy but remains fully supported, and it's the one you need for the Batch API and for most third-party gateways.

Why do I get "Extra inputs are not permitted" when setting the aspect ratio?

The Python snippet in Google's generateContent guide passes response_format, which the google-genai SDK (2.31.0) doesn't accept. Use config=types.GenerateContentConfig(image_config=types.ImageConfig(aspect_ratio="16:9", image_size="2K")) instead.

Found a mistake? Email [email protected].