Skip to content
RU

Nano Banana 2

Nano Banana 2 (google/gemini-3.1-flash-image-preview) is the refreshed Nano Banana with sharper details. Two endpoints: POST /v1/images/generations for text-to-image and POST /v1/images/edits for working from a reference image. The model is paid — generations are charged from your balance; there is no free quota for it.

Field Description
model google/gemini-3.1-flash-image-preview (or the short gemini-3.1-flash-image-preview)
prompt What to draw, required
n How many images, 1 to 4; each one is billed separately
aspect_ratio 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9; defaults to 1:1
resolution 1k, 2k or 4k; defaults to 1k
size Explicit WxH — an alternative to the aspect_ratio + resolution pair
quality The model has no such knob: passing the parameter returns 400

The model thinks in “aspect ratio + resolution” terms, and WxH is derived from them. Mappings for common combinations:

Aspect 1k 2k 4k
1:1 1000x1000 2000x2000 2828x2828
16:9 1332x750 2666x1500 3770x2120
9:16 750x1332 1500x2666 2120x3770

The full list of 30 allowed size values is the sizes field in the catalog; a value outside the list returns 400.

import base64
img = client.images.generate(
model="google/gemini-3.1-flash-image-preview",
prompt="Portrait of a barista grinding coffee, warm rim light, shallow depth of field",
extra_body={"aspect_ratio": "4:5", "resolution": "2k"},
)
with open("barista.png", "wb") as f:
f.write(base64.b64decode(img.data[0].b64_json))
{
"model": "google/gemini-3.1-flash-image-preview",
"prompt": "Night city from above: neighborhood lights, long exposure, photorealism",
"aspect_ratio": "21:9",
"resolution": "4k"
}

The model accepts reference images (references: true), so /v1/images/edits with multipart/form-data is available:

curl https://api.mixen.ai/v1/images/edits \
-H "Authorization: Bearer $MIXEN_API_KEY" \
-F model=google/gemini-3.1-flash-image-preview \
-F image=@portrait.png \
-F prompt="Replace the background with an amber sunset, keep the face and the light"

The answer always carries b64_json — files are not hosted. Both endpoints answer synchronously; set your HTTP client timeout to at least 120 seconds.

5.3477 ₽ ($0.06) per image — the flat catalog price. Current values — catalog.

  • Sharper details compared to the first Nano Banana — the model’s next generation.
  • Ten frame formats: from square 1:1 to panoramic 21:9, across three resolutions up to 4K.
  • Thirty fixed size values — one per “aspect + resolution” pair.
  • Editing from a reference via /v1/images/edits — the same key and syntax as generation.
  • Nano Banana 2 Lite (google/gemini-3.1-flash-lite-image-preview) — Google’s fastest, most cost-efficient image model: the same formats and resolutions at 3.3423 ₽ ($0.0375).
  • Balance only; no quality knob — a size outside the model’s table returns 400.

All models — in the catalog. The general image workflow — images guide.