Nano Banana
Nano Banana is Google’s Gemini image model. It generates an image from a text prompt, and it edits images that you send with the prompt. The call is synchronous: one POST returns the finished image in the response body, so there is nothing to poll. The request and response shapes mirror Google’s own API.Models
All four models generate and edit on the same endpoint. A request takes up to 14 reference images on every model. The size is a pixel budget that you set with
image_size. The shape is a separate axis that you set with aspect_ratio.
Use Nano Banana 2 for fast everyday generation and edits. It is the default model, and it is the only one that accepts the 512 size.
Use Nano Banana 2.1 for the same everyday work when you do not need the 512 size. It is Google’s update to Nano Banana 2, and it starts at 1K. It is a thinking model, so it inserts a thought step before the output step in the response.
Use Nano Banana Pro when you need the highest fidelity. It starts at 1K. It is a thinking model, so it inserts a thought step before the output step in the response.
Nano Banana (gemini-2.5-flash-image) is the original Nano Banana, the model before Nano Banana 2. It has one size, 1K, and no size control. It returns PNG rather than JPEG.
Endpoints
The base URL ishttps://api.nunchux.com.
There is no poll route. The image is in the response.
Request
Send your API key in theX-API-Key header. See Authentication. Set Content-Type: application/json. Send a User-Agent header that names your application, for example YourApp/1.0.
The JSON body names the model and an input array of content parts. A text-only input generates a new image. Image parts turn the request into an edit. See Editing.
The Nano Banana model to run. See the Models table.Options:
gemini-3.1-flash-image, gemini-nano-banana-2.1, gemini-3-pro-image, gemini-2.5-flash-imageOrdered content parts. A text-only input generates. Add
{ "type": "image" } parts (up to 14) and the text becomes an edit instruction across them. Image parts also carry data and mime_type. See Editing.Output controls. A request that omits
response_format or its type is rejected with no_image_format or invalid_response_format.Output size and shape
image_sizeis a pixel budget, not a shape.1Kis 1024×1024 at1:1, 1584×672 at21:9and 768×1376 at9:16. On the original Nano Banana,1Kis 1024×1024 at1:1, 1344×768 at16:9and 1536×672 at21:9.- Set
image_sizeexplicitly. When you omit it, the call is billed at the model’s largest tier (4K, or1Kon the original Nano Banana), on generations and on edits. - The 14 ratios in the list are accepted on every model.
1:1,21:9and9:16are the ones that have been run end to end. On the original Nano Banana,1:8and8:1return a1:4and a4:1image. - There is no
autovalue foraspect_ratio. To keep the shape of the input on an edit, omit the field. On the original Nano Banana, set it on a multi-image edit.
Editing
Add one or more{ "type": "image" } parts to input, up to 14. The text part becomes an instruction across all of them. The result is always one new image, not a batch and not a mechanical merge. image_size and aspect_ratio work exactly as on a generation.
Raw base64 image bytes on
type: "image" parts, with no data: prefix. Images are sent inline. There is no URL form.Response
The image comes back in the same response, as base64 bytes: JPEG on Nano Banana 2, Nano Banana 2.1 and Nano Banana Pro, and PNG on the original Nano Banana.The status of the interaction. It is terminal on arrival. The call is synchronous, so there is no in-progress state to poll for.
The steps of the interaction. The image is on the first entry whose
content[] carries a data field.Reading the response
- Select the output step by shape, not by index: the first
steps[]entry whosecontent[]carries adatafield. Thesignaturestep is optional, a thinking model such as Nano Banana 2.1 or Nano Banana Pro inserts athoughtstep ahead of the output, and the original Nano Banana can put a step with atextpart ahead of the image. - The bytes are JPEG on Nano Banana 2, Nano Banana 2.1 and Nano Banana Pro, whatever the request asked for. The original Nano Banana returns PNG. Name the file accordingly.
- There is no top-level
dataarray and nob64_jsonfield. If you port a parser from/v1/images, this is the line to change.
Example
Generate
One POST returns the image inline. The example takes the firststeps[] content part that has a data field and saves it as a JPEG.
Edit
The same call with image parts. The prompt places the person from the first image into the room from the second. Omitaspect_ratio to keep the shape of the first input. image_size still applies, and it still bills at 4K when you omit it.
Tips
- Write the prompt as an instruction. Name what must change and what must stay.
- When you send several reference images, say which element comes from which image.
- Set
image_sizeexplicitly. An omitted size is billed at the model’s largest tier (4K, or1Kon the original Nano Banana), on edits as well as on generations. - Use a larger
image_sizeonly when you need the detail. Larger sizes cost more and take longer. - Set
aspect_ratiowhen you want a shape other than1:1. Size and shape are separate axes. - Use Nano Banana Pro for the highest fidelity. Use Nano Banana 2 for fast everyday work.
- Read the image from the first
steps[]entry that has adatapart. Do not hardcode a step index. - Decode and save the image on receipt. The response carries the bytes, not a URL.
Errors and limits
- A request takes up to 14 image parts. Images are sent inline as base64, with no URL form.
- A request that omits
response_formatorresponse_format.typeis rejected withno_image_formatorinvalid_response_format. A rejected request is not charged. 512is accepted ongemini-3.1-flash-imageonly.0.5Kis rejected on every model.gemini-2.5-flash-imageaccepts1Konly.512,2Kand4Kare rejected withnot_priced, and nothing is charged.- Nano Banana is priced per image. The price rises with
image_size, and an omittedimage_sizebills at the model’s largest tier:4K, or1Kongemini-2.5-flash-image. The rates are on the pricing page. See Credits and pricing. - A Nano Banana call counts toward your requests per minute. It does not take a simultaneous-job slot. See Rate limits.
- A
502after the request was sent is refunded automatically. It is safe to retry. - A
503with the codegoogle_unreachablemeans that Google could not be reached before anything was sent. Nothing was charged. Retry with backoff. - A
503whose message saysgoogle pass-through not enabledmeans that the route is not available. Do not retry it in a loop.