# Nano Banana 2.1 — Gemini generateContent This file is the focused AI-readable context for one UniAll documentation page. URL: https://docs.uniall.ai/models/image/nano-series/nano-banana-2-1/gemini-format Locale: en Markdown: https://docs.uniall.ai/ai/pages/models/image/nano-series/nano-banana-2-1/gemini-format.md Description: Generate and edit Nano Banana 2.1 images with the official Gemini model ID, inline Base64 references, and image response parts. Agent guidance: - Use this page when the user is asking about this specific route or model capability. - Preserve endpoint paths, JSON keys, model IDs, and placeholder values exactly. - `{BASE_URL}` means `https://api.uniall.ai`; treat `sk-***` and `task_xxx` as safe placeholders, not real secrets. ## Page Markdown ## Overview Use `gemini-nano-banana-2.1` to generate an image from text or edit up to 14 reference images with the Gemini request format. Each synchronous request returns one image as Base64 in an `inlineData` response part. ## Endpoint ```http POST /v1beta/models/gemini-nano-banana-2.1:generateContent ``` The base URL is `https://api.uniall.ai`. The main examples use Google's official model ID `gemini-nano-banana-2.1`. The compatible URL `/v1beta/models/nano-banana-2.1:generateContent` also remains available. ## Authentication Use your UniAI user API key: ```http x-goog-api-key: Content-Type: application/json ``` ## Request Parameters Send one `user` entry in `contents`. Use camelCase field names. | Parameter | Type | Required | Description | | --- | --- | --- | --- | | `contents` | array | Yes | Exactly one user-content entry. | | `contents[].role` | string | Yes | `user`. | | `contents[].parts[].text` | string | Yes | Non-empty generation or editing instruction. | | `contents[].parts[].inlineData` | object | Conditional | Reference image for editing; add a part for each image, up to 14. | | `contents[].parts[].inlineData.mimeType` | string | Conditional | `image/png`, `image/jpeg`, or `image/webp`. | | `contents[].parts[].inlineData.data` | string | Conditional | Raw Base64 image bytes without a Data URL prefix. | | `generationConfig.imageConfig.imageSize` | string | No | `1K`, `2K`, or `4K`; defaults to `1K`. | | `generationConfig.imageConfig.aspectRatio` | string | No | One of the 14 ratios below. If omitted, the ratio follows the reference image or generated content. | | `generationConfig.thinkingConfig.thinkingLevel` | string | No | `MINIMAL`, `MEDIUM`, or `HIGH`; defaults to `MEDIUM`. | | `generationConfig.responseModalities` | string[] | No | Defaults to `["IMAGE"]`; also accepts `["TEXT", "IMAGE"]`. Text appears only if final text is actually generated. `["TEXT"]` alone is unsupported. | | `generationConfig.candidateCount` | integer | No | Only `1` is accepted; each request returns one image. | ### Resolution And Reference Images Supported aspect ratios: ```markdown 1:1 1:4 1:8 2:3 3:2 3:4 4:1 4:3 4:5 5:4 8:1 9:16 16:9 21:9 ``` Resolution is a tier, not a fixed longest-edge pixel count. For example, a non-square `1K` result can be `1376 × 768`. `0.5K`, `512`, and `8K` are unsupported. Editing requires 1 to 14 PNG, JPEG, or WebP reference images. Keep them in `parts` in the order described by your prompt. Order and duplicate entries are preserved; duplicates count toward the limit. Set `mimeType` to the actual image type and put only raw Base64 in `data`. ## Request Examples ### Text To Image ```bash curl -X POST "https://api.uniall.ai/v1beta/models/gemini-nano-banana-2.1:generateContent" \ -H "x-goog-api-key: " \ -H "Content-Type: application/json" \ -d '{ "contents": [ { "role": "user", "parts": [ {"text": "Create a spring latte poster with a cream background and clear typography"} ] } ], "generationConfig": { "responseModalities": ["IMAGE"], "imageConfig": {"imageSize": "2K", "aspectRatio": "16:9"}, "thinkingConfig": {"thinkingLevel": "HIGH"}, "candidateCount": 1 } }' ``` ### Image Editing Replace `` with the reference image's raw Base64 bytes before sending this request. ```bash curl -X POST "https://api.uniall.ai/v1beta/models/gemini-nano-banana-2.1:generateContent" \ -H "x-goog-api-key: " \ -H "Content-Type: application/json" \ -d '{ "contents": [ { "role": "user", "parts": [ {"text": "Keep the cup shape and color; replace the background with a bright cafe"}, { "inlineData": { "mimeType": "image/png", "data": "" } } ] } ], "generationConfig": { "responseModalities": ["IMAGE"], "imageConfig": {"imageSize": "2K", "aspectRatio": "4:5"}, "thinkingConfig": {"thinkingLevel": "MEDIUM"}, "candidateCount": 1 } }' ``` Add another `inlineData` part for each additional reference image. To make a later edit, use the previous output image as a reference in a new independent request. ## Response Example ```json { "candidates": [ { "content": { "role": "model", "parts": [ { "inlineData": { "mimeType": "image/png", "data": "" } } ] }, "finishReason": "STOP" } ] } ``` | Response field | Description | | --- | --- | | `candidates[].content.parts[].inlineData` | Final image. Base64-decode `data` and save it according to the returned `mimeType`. | | `candidates[].content.parts[].text` | Optional final text when requesting `["TEXT", "IMAGE"]` and final text is actually generated. Text is not guaranteed. | | `usageMetadata` | May be present when actual usage metadata is available; do not require it to read the image. | Find the part containing `inlineData` rather than assuming the first part is an image. The response is synchronous and has no task ID or polling step. A client timeout does not confirm that generation stopped; avoid automatically submitting the request again. ## Capability Limits And Common Errors - Search is unavailable. Omit `tools`, `enable_web_search`, and `enable_image_search`; supplying them is rejected even when a search flag is `false`. - Only a single user-content entry with text and image references is supported. Multi-turn history, thinking signatures or summaries, video/PDF input, Files, Interactions, and Batch APIs are unavailable in this image integration. - `quality`, custom pixel `size` or `custom_size`, masks, transparent backgrounds, `seed`, and streaming output are unsupported. - Do not use `/v1/chat/completions` or `/v1/images/tasks` for Nano Banana 2.1. - An editing request without a reference image, more than 14 references, a Data URL prefix inside `inlineData.data`, an unsupported image size, text-only output, or a `candidateCount` other than `1` is invalid. - Thinking control is available only for the new 2.1 integration. It is not enabled for `nano-banana-2`, `nano-banana-pro`, or fixed-resolution compatibility models. ## Related Pages - [Nano Series](/models/image/nano-series) - [Nano Banana 2.1 — OpenAI Images](./openai-format) - [Gemini generateContent Format for other Nano models](/models/image/nano-series/gemini-format)