# Nano Banana family API: choosing a model, choosing an endpoint, and the response structure Source: https://ofox.ai/docs/develop/models/nano-banana Google's Gemini image models, five in total. We recommend calling them through the **Gemini native API**, which gives precise control over aspect ratio and resolution; the OpenAI-compatible API also works, but supports only some parameters. ## Common tasks - [Set aspect ratio and resolution](https://ofox.ai/docs/develop/models/nano-banana/text-to-image) — Landscape, portrait and 4K images, and the values each model supports. - [Editing & multi-image](https://ofox.ai/docs/develop/models/nano-banana/image-edit) — Upload images and edit them with a text instruction. - [Troubleshooting errors](https://ofox.ai/docs/develop/models/nano-banana/errors) — 400 invalid argument, wrong aspect ratio, no image returned, 410. ## Choosing a model **Key point**:Nano Banana 2 is recommended for most cases; choose Pro for 4K output or complex compositions, and 2 Lite for generating small images in bulk. - **Nano Banana 2.1**(Latest): Three tiers: 1K, 2K, 4K; Aspect ratios from 1:8 to 8:1; 2K and 4K measured at about 2 minutes — gemini-nano-banana-2.1 - **Nano Banana 2**(Everyday pick): Four resolutions from 512 to 4K; Widest choice of aspect ratios, including 1:8 and 8:1 — gemini-3.1-flash-image - **Nano Banana Pro**(Quality first): Three tiers: 1K, 2K, 4K; Reasons before generating, so it takes longer — gemini-3-pro-image - **Nano Banana 2 Lite**(Speed first): 1K only; Measured at about 5 seconds per image; outputs JPEG — gemini-3.1-flash-lite-image - **Nano Banana**(Previous gen): Fixed at about 1K; resolution cannot be set; Fine for existing projects — gemini-2.5-flash-image **Model IDs (copy them exactly)** - Nano Banana 2.1: `google/gemini-nano-banana-2.1` — Latest - Nano Banana 2: `google/gemini-3.1-flash-image` — Everyday pick - Nano Banana Pro: `google/gemini-3-pro-image` — 4K, complex compositions - Nano Banana 2 Lite: `google/gemini-3.1-flash-lite-image` — 1K only - Nano Banana: `google/gemini-2.5-flash-image` — Previous gen For live prices, see the model pages: [Nano Banana 2](https://ofox.ai/models/google/gemini-3.1-flash-image), [Nano Banana Pro](https://ofox.ai/models/google/gemini-3-pro-image). The actual charge follows `usageMetadata` in the response. ## Choosing an endpoint **Key point**:Use the Gemini native API when you need to control aspect ratio and resolution. | | Gemini native API (recommended) | OpenAI-compatible API | |---|---|---| | Endpoint | `POST /gemini/v1beta/models/:generateContent` | `POST /v1/images/generations`, `/v1/images/edits` | | Aspect ratio | `imageConfig.aspectRatio` | Top-level `aspect_ratio` | | Resolution | `imageConfig.imageSize`: 512, 1K, 2K, 4K | **Not supported**; sending `image_size` returns 400 | | `size: "WIDTHxHEIGHT"` | Not applicable | Not supported; set the ratio with `aspect_ratio` | | `n` (multiple images) | Not applicable | Not supported; one image per request | | Editing | Put `inlineData` in `parts` | Upload files to `/v1/images/edits` | | Reference images `input_images` | Not applicable | Not supported; use `/v1/images/edits` for editing | | Returned in | `candidates[0].content.parts[].inlineData.data` | `data[0].b64_json` | ## Latency and timeouts **Key point**:Set the client timeout to 300 seconds or more. The API is synchronous. We measured about 5 to 20 seconds at 1K and about 30 seconds at 4K; Nano Banana 2.1 at 2K and 4K takes about 2 minutes. It takes longer at peak times. Pro reasons before generating the image (the response includes `thoughtsTokenCount`), so it is slower than Nano Banana 2 at the same resolution. The common 60-second default timeout does not cover 4K or peak-time requests; if the client disconnects, the request is still billed. ## Response structure ```json filename="200 OK (native API, data truncated)" { "candidates": [{ "content": { "parts": [{ "inlineData": { "mimeType": "image/png", "data": "iVBORw0KGgo…" } }], "role": "model" }, "finishReason": "STOP" }], "modelVersion": "google/gemini-3-pro-image", "usageMetadata": { "promptTokenCount": 7, "candidatesTokenCount": 2000, "candidatesTokensDetails": [{ "modality": "IMAGE", "tokenCount": 2000 }], "thoughtsTokenCount": 211, "totalTokenCount": 2218 } } ``` - The image is in the `parts` item that contains `inlineData`, **not necessarily the first item**; text may come before it. Iterate over `parts` to find it. - The `IMAGE` entry in `candidatesTokensDetails` gives the number of output image tokens. We measured 1,120 at 1K and 2,000 for Pro at 4K. - `thoughtsTokenCount` appears only in Pro responses and counts the reasoning tokens used before generating the image. ## Official docs The official docs describe behavior when calling Google directly; when calling through OfoxAI, the measured results on this page take precedence. - [Gemini API · Image generation](https://ai.google.dev/gemini-api/docs/image-generation) - [Gemini API · Aspect ratios and image size](https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios_and_image_size) - [OfoxAI · Gemini native protocol generateContent](https://ofox.ai/docs/api/gemini/generate-content) ## FAQ **How do I generate a 4K image with Nano Banana Pro?** Use the Gemini native API and pass imageSize: "4K" in generationConfig.imageConfig, with aspectRatio to set the ratio. In our tests a 16:9 4K output was 5504x3072, about 16 MB, and took about 33 seconds. The OpenAI-compatible API does not support imageSize; sending image_size returns 400. **Which aspect ratios does Nano Banana 2 support?** Ten common ones: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9 and 21:9; plus four extra-wide or extra-tall ratios: 1:4, 4:1, 1:8 and 8:1. Any ratio not on the list returns 400 Request contains an invalid argument. **Does Nano Banana Pro support 1:8 or 4:1?** No. The four ratios 1:4, 4:1, 1:8 and 8:1 are supported only by Nano Banana 2.1, Nano Banana 2 and Nano Banana 2 Lite; use one of these three for extra-tall or extra-wide images. **Should imageSize be 4K or 4k?** We recommend uppercase 1K, 2K and 4K, matching Google. In our tests OfoxAI also accepts lowercase. The 512 tier has no K and is supported only by Nano Banana 2. **How do I set the Nano Banana aspect ratio on the OpenAI-compatible API?** Use the top-level aspect_ratio, e.g. "16:9". That API has no resolution parameter; for 2K or 4K use imageConfig.imageSize on the Gemini native API. **Can Nano Banana generate several images at once?** No, each request generates one image. For more, send several requests concurrently, keeping the rate limit in mind. **What timeout should I set for Nano Banana?** We recommend 300 seconds or more. We measured about 5 to 20 seconds at 1K, about 30 seconds at 4K, and about 2 minutes for Nano Banana 2.1 at 2K and 4K, longer at peak times. Pro reasons before generating, so it is slower than Nano Banana 2.