API429 / gemini-3.1-flash-image

Nano Banana 2 API: settings, cost and integration

A practical Nano Banana 2 page for choosing a configuration and integrating the API. Published API429 rates, manufacturer specifications and client contract boundaries are presented separately. Start with a small control task and check the result before increasing volume.

Read in Russian

Published: · Updated:

Exact ID: gemini-3.1-flash-image. Check access for your key using GET /v1/models; a published model does not guarantee access for every account.

Prices and billing units

Direct request settingAPI429 price
Resolution 1K$0.0201 / 1 image
Resolution 2K$0.0303 / 1 image
Resolution 4K$0.0453 / 1 image

API429 catalog generated . The table shows direct request components; other general catalog metrics are not added here. Display prices are rounded to six decimal places; calculations use exact catalog rates. The calculator below follows the direct Images request contract. Sources checked: Oct 24, 2026.

Google Standard: $0.50 per 1M input tokens, $3 per 1M text/thinking output tokens and $60 per 1M image tokens. The calculator compares the output component; a complete native request may include additional components. Pricing sources are listed below. Batch, cache and special modes are kept separate from the base comparison.

Image generation budget

API429$2.01
Manufacturer: output component$6.72
Difference for the selected volume70.089286%API429 costs less for this component

Direct Images: one image per request. API429 bills by resolution and the number of returned files; general catalog token rows are not added to this method. The comparison covers Google’s output component; input and text/thinking output are charged separately in a native call. Cache, tools, taxes, fees and repeated calls are excluded. RUB results use only your entered rate; this is not a bank quote.

Specifications and compatibility boundaries

  • Native Google limits: 131,072 input tokens and 32,768 output tokens; these are separate limits, not a shared window or confirmed API429 limits.
  • Google describes 0.5K/1K/2K/4K output and text with images; the API429 client contract lists resolution 1K/2K/4K. Native grounding, thinking and Batch are not promised through this method.
  • Nano Banana 2 is the exact gemini-3.1-flash-image. Nano Banana Pro, Lite and 2.1 are other models; their properties cannot be transferred based on a family name.

Specification: Google, checked Oct 24, 2026. These are not verified effective API429 limits. Check native manufacturer parameters and capabilities separately for the client method.

Published capabilities for this exact ID: chat image_editing image_generation vision . A missing field is not evidence of a prohibition, but it does not establish compatibility.

Exact version and tasks for a control set

Nano Banana 2 is Google’s name for gemini-3.1-flash-image. Its first announcement was February 26, 2026, when the version was called Preview; the current manufacturer page labels it Stable. This is the model’s Google history rather than its API429 availability date. Use the exact ID from this page for integration. Nano Banana Pro, Lite and 2.1 designate other products: even a similar task does not make their parameters and billing interchangeable. A useful control set includes a product scene, several composition variants and an illustration with a short Russian caption. Define acceptance criteria in advance: text readability, object placement, unwanted objects and color accuracy. Manufacturer capabilities help choose tasks but do not establish results on your material. Save the prompt and settings with the generated file to make later comparisons meaningful.

Frame shape and resolution are separate settings

In API429 client documentation, size specifies the requested shape, while resolution sets the 1K, 2K or 4K billing class. The initial example uses a 1024x1024 square and explicit resolution=1K. For a larger result, change the class deliberately while retaining a clear shape request. Do not treat 2048x2048 alone as evidence of 2K pricing: check both parameters and actual response details. Google also describes 0.5K and additional aspect ratios, but the current API429 client table does not list them as equally supported. Do not transfer them automatically. Requested dimensions do not guarantee the exact saved file dimensions. If a response contains api429.outputs, check actual width, height and format; api429.parameter_mismatches requires review before placing the image in a production layout.

Budgeting an image series

For a direct Images request, API429 estimates output by resolution and the number of returned images. Separate general catalog token rates are not automatically added to this method. The calculator shows one image per request at the selected resolution and multiplies by request count. The manufacturer side calculates a comparable output component using Google’s published image token counts. The full native Google cost may additionally include input tokens and text or thinking output; these are separate from the image output component. The displayed difference therefore concerns output rather than all possible costs across different methods. A Chat Completions workflow needs a separate estimate: its token components are not a confirmed direct image generation price. Cache, search, fees, taxes and repeated paid attempts are excluded. Cache metrics in a general catalog do not establish native caching support for this model: Google states that it is absent. For a series, retain the resolution and accepted file count for each request to avoid paying again for already completed results.

Editing, results and expanding a series safely

Google describes image work and sequential editing, and the API429 catalog lists image_editing for the exact ID. This is reason to investigate the editing method, rather than a promise of all native modes. Start with the shown text request; adding references requires a separate check of the client multipart contract and permitted file sizes. The examples below save one synchronous result from data[0].b64_json. They identify PNG, JPEG or WebP from bytes rather than trusting an extension in advance. With response_format=url, the result may be an ordinary URL or data URI: identify the value type first. Check partial results and warnings before retrying. If a request times out, do not resend the entire series without checking: a missing response does not prove generation was neither completed nor charged. For large queues, limit concurrency in your application and retain each task’s state. Define in advance who reviews content, where the original response is saved and how retry decisions are recorded. This separates technically receiving a file from determining that it is ready to use.

Public model observations

Over the last 24 hours: mean successful response time — 64 s; service error rate — 4.6%. Data as of .

Source: public 24-hour statistics. The mean is neither a median nor a response time guarantee; it is not a quality assessment of the image.

First request: curl, Python, JavaScript

Set API429_API_KEY on the server and check the exact ID using GET https://gateway.api429.com/v1/models using the same Bearer key. Generation incurs a charge; there are no automatic retries. An uncertain timeout does not prove there was no charge.

The examples request one result and b64_json. curl saves JSON to image-response.json; Python and JavaScript decode the file after checking MIME by signature. When choosing url, first distinguish a hosted URL from a data URI. Check warnings, partial results, api429.outputs and api429.parameter_mismatches, if present.

curl

curl --fail-with-body https://gateway.api429.com/v1/images/generations \
  -H "Authorization: Bearer $API429_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gemini-3.1-flash-image","prompt":"A product photograph of a ceramic cup on a light table; soft daylight, no text.","n":1,"size":"1024x1024","response_format":"b64_json","resolution":"1K"}' \
  --output image-response.json

Python 3

import base64
import json
import os
import urllib.request
from pathlib import Path

key = os.environ["API429_API_KEY"]
base = "https://gateway.api429.com/v1"
headers = {"Authorization": "Bearer " + key, "Content-Type": "application/json"}
model = "gemini-3.1-flash-image"
with urllib.request.urlopen(urllib.request.Request(base + "/models", headers=headers), timeout=30) as response:
    available = {item["id"] for item in json.load(response)["data"]}
if model not in available:
    raise ValueError("Model unavailable to this key")
payload = json.loads("{\"model\":\"gemini-3.1-flash-image\",\"prompt\":\"A product photograph of a ceramic cup on a light table; soft daylight, no text.\",\"n\":1,\"size\":\"1024x1024\",\"response_format\":\"b64_json\",\"resolution\":\"1K\"}")
request = urllib.request.Request(base + "/images/generations",
    data=json.dumps(payload).encode("utf-8"), headers=headers, method="POST")
with urllib.request.urlopen(request, timeout=180) as response:
    result = json.load(response)
if result.get("warnings") or result.get("api429", {}).get("parameter_mismatches"):
    print("Inspect output warnings:", result.get("warnings"), result.get("api429"))
items = result.get("data", [])
if len(items) != 1 or not items[0].get("b64_json"):
    raise ValueError("Missing image or partial result; inspect before retrying")
raw = base64.b64decode(items[0]["b64_json"], validate=True)
if raw.startswith(b"\x89PNG\r\n\x1a\n"):
    extension = "png"
elif raw.startswith(b"\xff\xd8\xff"):
    extension = "jpg"
elif raw.startswith(b"RIFF") and raw[8:12] == b"WEBP":
    extension = "webp"
else:
    raise ValueError("Unknown image MIME; inspect before saving")
Path("image." + extension).write_bytes(raw)
print(result.get("api429", {}).get("outputs"))

JavaScript: Node.js 18+

import { writeFile } from "node:fs/promises";
const key = process.env.API429_API_KEY;
if (!key) throw new Error("Set API429_API_KEY");
const base = "https://gateway.api429.com/v1";
const headers = { Authorization: "Bearer " + key, "Content-Type": "application/json" };
const model = "gemini-3.1-flash-image";
const available = await fetch(base + "/models", { headers, signal: AbortSignal.timeout(30000) });
if (!available.ok) throw new Error("Models HTTP " + available.status);
if (!(await available.json()).data.some(item => item.id === model)) throw new Error("Model unavailable to this key");
const payload = {"model":"gemini-3.1-flash-image","prompt":"A product photograph of a ceramic cup on a light table; soft daylight, no text.","n":1,"size":"1024x1024","response_format":"b64_json","resolution":"1K"};
const response = await fetch(base + "/images/generations", {
 method: "POST", headers, body: JSON.stringify(payload), signal: AbortSignal.timeout(180000)
});
if (!response.ok) throw new Error("Generation HTTP " + response.status);
const result = await response.json();
if (result.warnings || result.api429?.parameter_mismatches) console.warn("Inspect warnings", result.warnings, result.api429);
if (result.data?.length !== 1 || !result.data[0].b64_json) throw new Error("Missing image or partial result; inspect before retrying");
const bytes = Buffer.from(result.data[0].b64_json, "base64");
const hex = bytes.subarray(0, 8).toString("hex");
const extension = hex === "89504e470d0a1a0a" ? "png" : hex.startsWith("ffd8ff") ? "jpg" : bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP" ? "webp" : undefined;
if (!extension) throw new Error("Unknown image MIME; inspect before saving");
await writeFile("image." + extension, bytes);
console.log(result.api429?.outputs);

The examples are checked offline against the client contract and public schema. No paid execution or result quality is claimed. A verified complete image jobs contract is not available here: asynchronous fields and polling are omitted.

n8n: HTTP Request and saving the result

  1. Check access to the exact ID using GET /v1/models.
  2. Create an HTTP Request with POST to https://gateway.api429.com/v1/images/generations; store the Bearer key in credentials.
  3. Send the JSON from curl with one result. Do not include the key in a workflow export.
  4. Parse JSON, check the data count and warnings; decode b64_json and check MIME before saving.

HTTP Request documentation. Compatibility with specialized AI nodes and native SDKs needs separate verification.

Three options for your own comparison

Compare identical tasks and acceptance criteria. These are image models, not a quality ranking; conditional rows apply to their own configurations and do not form an equivalent benchmark.

ModelPublished API429 units
GPT Image 2gpt-image-2
auto · long side >1536 and up to 2048 px: $0.2532 / 1 image
auto · long side >2048 px: $0.500892 / 1 image
auto · rectangle, side up to 1536 px: $0.0495 / 1 image
auto · square, side up to 1536 px: $0.0633 / 1 image
high · long side >1536 and up to 2048 px: $0.2532 / 1 image
high · long side >2048 px: $0.500892 / 1 image
high · rectangle, side up to 1536 px: $0.0495 / 1 image
high · square, side up to 1536 px: $0.0633 / 1 image
low · long side >1536 and up to 2048 px: $0.0072 / 1 image
low · long side >2048 px: $0.014238 / 1 image
low · rectangle, side up to 1536 px: $0.0015 / 1 image
low · square, side up to 1536 px: $0.0018 / 1 image
medium · long side >1536 and up to 2048 px: $0.0636 / 1 image
medium · long side >2048 px: $0.125768 / 1 image
medium · rectangle, side up to 1536 px: $0.0123 / 1 image
medium · square, side up to 1536 px: $0.0159 / 1 image
Flux.2 ProFLUX.2-pro
1 MP, no references: $0.009 / 1 image
2 MP, no references: $0.0135 / 1 image
4 MP, no references: $0.0225 / 1 image
gemini-3-pro-image (Nano Banana Pro)gemini-3-pro-image
Resolution 1K: $0.0402 / 1 image
Resolution 2K: $0.0402 / 1 image
Resolution 4K: $0.072 / 1 image

Version and release date

Manufacturer release date, Google: . The exact predecessor has not been established in the reviewed sources. This does not automatically replace the ID. The model’s addition date in API429 is unknown.

Frequently asked questions

Which exact ID do I need for Nano Banana 2?

Use gemini-3.1-flash-image. Check it through GET /v1/models with your key before paid generation. Sharing a family name with Pro or Lite does not make them the same ID.

How do I request 2K or 4K?

Set resolution explicitly and choose shape separately through size. Check actual result parameters and warnings. Native Google sizes do not establish effective API429 limits.

Why is image pricing different from request pricing?

For direct Images, the calculator counts the output component by resolution. A full native Google request can include input and text/thinking output; other API429 methods have their own contracts. Cache, search, fees and retries are excluded here.

How do I save a response file?

For b64_json, decode data[0].b64_json and check MIME from bytes. For url, distinguish a hosted URL from a data URI first. Do not label every response PNG, and check an incomplete series before regenerating.

Sources and review

Editorial review: . Pricing · Getting started · Compare the family: Nano Banana

Telegram