Nano Banana 2 API

google/gemini-3.1-flash-image-preview
Nano Banana 2 is a compact text-to-image model from Google optimized for fast image generation.
Context
128K tokens
Input
$0.325 / 1M tokens
Output
$78 / 1M tokens
Released
Feb 27, 2026

How to use Nano Banana 2 API

Install any OpenAI-compatible SDK, point it at api.aimlapi.com/v1, and set the model to google/gemini-3.1-flash-image-preview.
import requests

r = requests.post(
    "https://api.aimlapi.com/v1/images/generations",
    headers={"Authorization": "Bearer " + AIMLAPI_KEY},
    json={
      "model": "google/gemini-3.1-flash-image-preview",
      "prompt": "A cat holding a sign that says hello"
    },
)
print(r.json())
const r = await fetch("https://api.aimlapi.com/v1/images/generations", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.AIMLAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "google/gemini-3.1-flash-image-preview",
    "prompt": "A cat holding a sign that says hello"
  }),
});
console.log(await r.json());
curl -X POST https://api.aimlapi.com/v1/images/generations \
  -H "Authorization: Bearer $AIMLAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"google/gemini-3.1-flash-image-preview","prompt":"A cat holding a sign that says hello"}'

OpenAI-compatible — swap the base URL and it works with your existing SDK.

Nano Banana 2 API Pricing

TypePrice
Input
$0.325 / 1M tokens
Output
$78 / 1M tokens

Text input $0.325/1M · reasoning $1.95/1M · image output $78/1M. Free credits on signup.

Nano Banana 2 Benchmarks

BenchmarkScoreWhat it measuresSourceRetrieved
Text-to-Image Arena
1252 (Elo)
Human pairwise preference Elo for image generatorsSourceJuly 12, 2026

Nano Banana 2 vs other models

ModelInputOutputContextBest for
Nano Banana 2
This page
$0.325 / 1M tokens
$78 / 1M tokens
128K tokens
Image generation at scale
$6.5 / 1M tokens
$39 / 1M tokens
Image generation at scale
Image generation at scale
$0.0195 / MP (variable)
Image generation at scale

Frequently asked questions

Nano Banana 2 takes image, text as input and returns image.

Nano Banana 2 became available on February 27, 2026.

Nano Banana 2 is priced at input $0.325 / 1M tokens, output $78 / 1M tokens.

Nano Banana 2 is billed per token, charged separately for input and output.

Yes, Nano Banana 2 supports image editing as well as generation.

Yes, Nano Banana 2 accepts image input as well as a text prompt.

Nano Banana 2 was built by Google.

Send a request to https://api.aimlapi.com/v1/images/generations with google/gemini-3.1-flash-image-preview as the model id.

Yes. Nano Banana 2 is served through AI/ML API, so the same key and endpoint format used for other models applies.

Start building with Nano Banana 2

Get API Key
1000+ models, one API.