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 three models generate and edit on the same endpoint. All three accept up to 14 reference images per edit. 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.
Endpoints
The base URL ishttps://api.nunchux.ai.
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.
string
default:"gemini-3.1-flash-image"
required
The Nano Banana model to run. See the Models table.Options:
gemini-3.1-flash-image, gemini-nano-banana-2.1, gemini-3-pro-imagearray
required
Ordered 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.object
required
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.- Set
image_sizeexplicitly. When you omit it, the call is billed at the largest tier (4K), 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. - There is no
autovalue foraspect_ratio. To keep the shape of the input on an edit, omit the field.
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.
string
Raw base64 image bytes on
type: "image" parts, with no data: prefix. Images are sent inline. There is no URL form.string
The MIME type of the image on
type: "image" parts, for example image/png or image/jpeg.Response
The image comes back in the same response, as base64 JPEG bytes.string
required
Identifier for this interaction.
string
required
The envelope kind.
string
required
The model that ran, echoed back.
string
required
The status of the interaction. It is terminal on arrival. The call is synchronous, so there is no in-progress state to poll for.
integer
required
Unix timestamp when the interaction was created.
integer
required
Unix timestamp of the last update, in practice when the image finished.
string
required
The service tier the call was served on.
object
required
Accounting for the call.
array
required
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, and a thinking model such as Nano Banana 2.1 or Nano Banana Pro inserts athoughtstep ahead of the output. - The bytes are JPEG whatever the request asked for. 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 the4Ktier, 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.- Nano Banana is priced per image. The price rises with
image_size, and an omittedimage_sizebills at the4Ktier. 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.