> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixroute.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini Nano Banana 2.1

> Gemini Nano Banana 2.1 image generation and conversational editing, with native request fields and model-specific limits.

Gemini Nano Banana 2.1 is an image-generation and conversational-editing model focused on visual quality, text rendering, reference consistency, and wide-format images. Use `gemini-nano-banana-2.1`; do not substitute a chat-only Gemini model.

## Model Information

| Field | Description |
| - | - |
| `model` | gemini-nano-banana-2.1 |
| `input limit` | 131,072 tokens |
| `output limit` | 32,768 tokens |
| `input / output` | Text, images, video, and PDF input; image and text output. No native audio output. |
| `image output` | 1K (default), 2K, or 4K. The 512 tier of Nano Banana 2 does not apply. |

These are model specifications. Route availability, billing, file access, and request-size limits depend on the selected channel. Image output uses the native Gemini endpoints below.

`POST https://api.mixroute.ai/v1/models/gemini-nano-banana-2.1:generateContent`

`POST https://api.mixroute.ai/v1/models/gemini-nano-banana-2.1:streamGenerateContent?alt=sse`

## Generate an Image

```bash theme={null}
curl --request POST "https://api.mixroute.ai/v1/models/gemini-nano-banana-2.1:generateContent" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Generate a clean product photograph of a red ceramic mug on a plain white background. No text."
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "TEXT",
      "IMAGE"
    ],
    "imageConfig": {
      "aspectRatio": "1:1",
      "imageSize": "1K"
    },
    "thinkingConfig": {
      "thinkingLevel": "MINIMAL"
    }
  }
}'
```

Use the native `generationConfig.imageConfig` fields for size and aspect ratio on this endpoint. Do not add metadata, asset, an OpenAI size/n field, or a model field inside the request body. The model is selected in the URL.

## Request Fields

| Field | Description |
| - | - |
| `contents` | Required user/model turns with parts. |
| `contents[].parts[].text` | Prompt or editing instruction. |
| `contents[].parts[].inlineData` | Input image object: mimeType and raw Base64 data; no data-URI prefix. |
| `contents[].parts[].fileData` | Native fileUri/mimeType references; resources must be accessible to the route account. |
| `generationConfig.responseModalities` | Use \["TEXT","IMAGE"] or \["IMAGE"] for image output. |
| `generationConfig.imageConfig.aspectRatio` | Native aspect-ratio string, such as 1:1 or 16:9. |
| `generationConfig.imageConfig.imageSize` | 1K, 2K, or 4K, case-sensitive; default 1K. |
| `generationConfig.thinkingConfig.thinkingLevel` | MINIMAL, MEDIUM (default), or HIGH. |
| `generationConfig.thinkingConfig.includeThoughts` | Optional thought-summary parts; skip thought=true parts when saving final images. |
| `generationConfig.maxOutputTokens` | Combined image/text output budget, up to 32,768; too small a budget can prevent a complete image. |
| `tools` | Native Google Search grounding where enabled by the route. Function calling is not supported by this image model. |
| `safetySettings` | Native category/threshold settings, subject to provider and account policy. |

## Limits

* Aspect ratios include `1:1`, `1:4`, `4:1`, `1:8`, `8:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, and `21:9`.
* Up to 14 reference images, with model guidance for up to four characters and ten objects. These are input limits, not a guarantee of perfect consistency.
* Vertex inline-image inputs are limited to 7 MB per image. PNG, JPEG, WebP, HEIC, and HEIF are supported; other request limits can be stricter.
* Omit the unsupported sampling/randomness fields temperature, topP, topK, seed, and logprobs.
* Audio generation, arbitrary function calling, and structured JSON output are not supported.

## Editing and Multi-turn Use

```json theme={null}
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Change the mug color to blue while preserving its shape and the white background."
        },
        {
          "inlineData": {
            "mimeType": "image/png",
            "data": "BASE64_IMAGE_DATA"
          }
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "TEXT",
      "IMAGE"
    ],
    "imageConfig": {
      "aspectRatio": "1:1",
      "imageSize": "1K"
    },
    "thinkingConfig": {
      "thinkingLevel": "MINIMAL"
    }
  }
}
```

Replace BASE64\_IMAGE\_DATA with the source bytes encoded as Base64. For conversational edits, retain the complete prior candidate.content as a model turn, followed by the next user turn. Preserve all thoughtSignature values exactly; do not replace the image history with text alone.

## Read the Output

Process candidates\[].content.parts\[] by type. Save non-thought inlineData parts using their MIME type and decoded Base64 bytes, and read text parts separately. A response without an image requires checking promptFeedback and finishReason; HTTP success alone does not imply image output.

Streaming uses streamGenerateContent?alt=sse with the same body, not a JSON stream flag. Parse SSE data events and handle image/text parts in each JSON event.

[Image generation and editing](/en/api-reference/endpoint/nano-banana) | [Image streaming](/en/api-reference/endpoint/nano-banana-stream)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.