gemini-3.1-flash-image, and every call costs $0.055 from 512px to 4K, with no Google account needed.
What Nano Banana 2 supports
1K to 4K images cost less than Google’s standard price per output image:
- 1K: $0.067 at Google, $0.055 on LaoZhang API
- 2K: $0.101 at Google, $0.055 on LaoZhang API
- 4K: $0.151 at Google, $0.055 on LaoZhang API

Output of the generate example below: 2K, 16:9
Parameters and limits
Google shut down
gemini-3.1-flash-image-preview on June 25, 2026, according to its deprecations page. On LaoZhang API, the -preview IDs are mapped to the matching stable IDs; use the stable ID, gemini-3.1-flash-image, directly. To compare all five Nano Banana models, see the Nano Banana overview.
Before you call
1
Create an API key
In Token management, open the create-token dialog (创建令牌), set Billing mode (计费模式) to Usage first (按量优先, recommended) or Per-call (按次计费), and click Create (创建). Nano Banana 2 has only a per-call price, and a Usage-based (按量计费) key can’t call it; the billing rules explain when a request is charged.

2
Set the key and install the dependencies
3
Add a save function for cURL
The cURL examples need When the response holds no image, the function prints the error,
jq. Define this shell function to save the last image in a Gemini-native response, which is the final result if interim images come back too, with the extension that matches its mimeType:promptFeedback, and finishReason fields instead.Generate an image
- cURL
- Python
candidates[0].content.parts[].inlineData.data, and mimeType gives its format. Both examples decode it and save a PNG, JPEG, or WebP file to match.
Larger sizes take longer to render, so keep a generous client timeout; the examples allow 300 seconds.
Output sizes
imageSize accepts four values from 512 to 4K, with the K in uppercase; 1K is the default. Google publishes these pixel dimensions for Nano Banana 2:
At
512, a 1:1 image is 512×512; Google’s image generation guide lists the other 512px sizes.
Edit images
Send the instruction first, then the reference images asinlineData parts, and refer to the images by their order in the prompt (“the first image”, “the second image”). Nano Banana 2 accepts up to 14 references: at most 10 object images and 4 character images.
- cURL
- Python
This request combines two local files. Build the body with
jq so large images don’t exceed shell argument limits, and keep each mimeType consistent with its file:inlineData part with a fileData part that carries its URL:
Ground images in Google Search
Add thegoogleSearch tool to base an image on current information, such as a forecast or recent results. Allow TEXT in responseModalities so any text the model writes alongside the image comes back too:
Use the OpenAI-compatible route
If your app already uses the OpenAI SDK, call Nano Banana 2 through chat completions. This route has no ratio or size settings, so a text-only prompt returns a 1K image in a frame the model picks. The image comes back as a Base64 data URL insidemessage.content. Save this script as nano_banana_2_chat.py:
Errors and billing
Send values from these lists:- The ratios
1:4,4:1,1:8, and8:1work only on Nano Banana 2 and Nano Banana 2.1. - Google rejects lowercase sizes such as
2k. - A request can return HTTP 200 without an image, for example when the prompt doesn’t ask for one or a safety check blocks the output. It is charged as one call. Check
finishReason(andpromptFeedbackif present), then change the prompt or references before resending; see Avoid paying for empty responses. - HTTP 401 means the key or the
Authorization: Bearerheader is wrong. Retry 429 and 5xx responses with backoff, and check call logs before resending a request that timed out.
FAQ
How much does the Nano Banana 2 API cost per image?
$0.055 per call, and each call returns one image. Output size, thinking level, reference images, and editing don’t change the price, so you can budget by request count. Google’s standard price for the same model is $0.067 at 1K, $0.101 at 2K, and $0.151 at 4K per output image (checked November 5, 2026), so a 4K image costs about 64% less on LaoZhang API. If you don’t need 512px output, Nano Banana 2.1 takes the same request at $0.045 per call.How do I request 512px output?
SetgenerationConfig.imageConfig.imageSize to the string 512 on the Gemini-native route. Only Nano Banana 2 accepts it; Output sizes lists the other values.
Why does Nano Banana 2 keep returning square images?
Set the ratio ingenerationConfig.imageConfig.aspectRatio on the Gemini-native route, for example "aspectRatio": "16:9", and the output always uses it. The 14 values are in Parameters and limits.
Without aspectRatio, the shape isn’t fixed:
- With a reference image, the output follows the reference image’s ratio.
- With a text-only prompt, the model picks the shape, which may be 1:1 or a wide frame.
- The OpenAI-compatible route has no ratio setting. Switch to the Gemini-native route when you need a fixed ratio, as in Generate an image.
How do I change the thinking level, and does it affect the price?
Nano Banana 2 and Nano Banana 2 Lite support two thinking levels,minimal (the default) and high, to trade latency for quality, and LaoZhang API passes the setting through. On the Gemini-native route, set it in generationConfig.thinkingConfig.thinkingLevel, for example "thinkingConfig": {"thinkingLevel": "high"}.
The level doesn’t change the price: LaoZhang API bills per call only, so a high request still costs the Nano Banana 2 per-call price (Google itself bills thinking tokens on top). Nano Banana Pro always thinks, and its level can’t be changed.
How do I turn on image search grounding, and what are the limits?
AddsearchTypes to the Google Search tool from Ground images in Google Search, and list both webSearch and imageSearch:
- A tool without
searchTypesuses web search only, andimageSearchalone uses image search only. - With both types listed, as above, either is allowed; the model decides whether to search and which type to use.
searchTypesmust be an object; an array has no effect. When image search is used,groundingMetadatain the response includesimageSearchQueries.
Related pages and sources
- Nano Banana overview — compare the five models, the two protocols, and billing
- Nano Banana 2.1 — the newer version, 1K to 4K at a lower price per call
- Nano Banana 2 Lite — low-cost 1K images
- Nano Banana Pro — complex layouts and brand-critical assets
- Nano Banana image editing (Standard) — move
gemini-2.5-flash-imageedits to Nano Banana 2 - Google: Nano Banana image generation — sizes, aspect ratios, reference limits, thinking, and grounding
- Google: generateContent reference —
imageConfig,thinkingConfig, and Google Search tool fields - Google: Gemini API deprecations — upstream model shutdown dates
- Call logs — check a request’s status and charge