Images

Nano Banana 2.1 Image Generation & Editing

Use gemini-nano-banana-2.1-c with Gemini native, Images, or Chat requests. Compare size mapping, URL and Base64 output, references, streaming, and ignored parameters.

Updated

Download Markdown

Choose a request format

The public model ID is gemini-nano-banana-2.1-c. All three formats use the same model. Keep your existing Images or Chat request structure, or choose Gemini generateContent for native Base64 output.

Use https://api.unifyllm.top and Authorization: Bearer <YOUR_API_KEY>.

FormatEndpointImage outputUse case
Gemini/v1beta/models/{model}:generateContentinlineData Base64Native content and image bytes
Images/v1/images/generationsdata[0].urlExisting Images generation clients
Images edits/v1/images/editsdata[0].urlEdit with uploads, public URLs, or data URLs
Chat/v1/chat/completionsMarkdown image URL, JSON or SSESingle-turn images in chat clients

Images: generation and editing

json
1{2  "model": "gemini-nano-banana-2.1-c",3  "prompt": "A green ceramic cup on a white background. No text.",4  "size": "1920x1080"5}

size and actual image dimensions

Images and Chat derive resolution and aspect ratio from size. Width and height must be positive integers. A long edge up to 1536 requests 1K; a larger edge requests 2K, with the nearest supported aspect ratio.

  • size does not accept "1K", "2K", "4K", or "16:9". Native imageSize uses 1K / 2K instead.
  • 4096x2304 still requests 2K, never 4K. A disabled tier returns an error rather than a silent downgrade.
  • size selects resolution and composition. Actual pixels can differ: a public gateway test requested 1920x1080 and received 2752×1536, without resizing or cropping.
sizeTierAspect ratio
autoDefault 1K1:1 for text; upstream chooses with references
1024x10241K1:1
1536x10241K3:2
1920x10802K16:9
1600x10002K3:2, nearest
4096x23042K16:9

Parameters that have no effect

Images and Chat accept the following fields for client compatibility, but ignore their values and do not forward them upstream.

FieldActual behavior
nOne valid image per request
response_formatReturns an image URL even for b64_json
quality / input_fidelityNot used as generation controls
maskNo mask-based editing; not treated as a reference
backgroundDoes not guarantee transparency
output_format / output_compressionPreserves the generated format without requested transcoding or compression

Gemini native: Base64 image output

Native parameters, request examples, and response structure

  • contents contains exactly one current user message. Add inlineData or public fileData image references in parts.
  • responseModalities must include IMAGE. imageSize supports 1K and 2K, not explicit 4K.
  • Inspect candidates[].content.parts[], skip thought=true parts, then decode inlineData.data using its mimeType.
  • Opaque fields such as thoughtSignature remain unchanged. This route still does not restore multi-turn state. Only generateContent is supported, not streamGenerateContent.
json
1{2  "contents": [3    {4      "role": "user",5      "parts": [6        {7          "text": "A red ceramic teapot on a white background."8        }9      ]10    }11  ],12  "generationConfig": {13    "responseModalities": [14      "IMAGE"15    ],16    "imageConfig": {17      "imageSize": "1K",18      "aspectRatio": "1:1"19    }20  }21}

Chat: current-turn input only

Only the last user message in messages is read. Top-level prompt and other history are not included. To edit a previous result, explicitly put its URL or data URL in the current image_url. Replace the example URL with your own public image.

Chat parameters, JSON output, and SSE examples

  • stream=false: read the Markdown image URL from choices[0].message.content.
  • stream=true: chat.completion.chunk starts after successful generation and storage, followed by finish_reason=stop and data: [DONE]. There are no waiting-period progress events or Base64 chunks.
  • Network chunks can split SSE events. Reassemble complete data: events instead of calling response.json() on the stream.
json
1{2  "model": "gemini-nano-banana-2.1-c",3  "messages": [4    {5      "role": "user",6      "content": [7        {8          "type": "text",9          "text": "Change the cup to green; preserve the white background."10        },11        {12          "type": "image_url",13          "image_url": {14            "url": "https://example.com/reference.jpg"15          }16        }17      ]18    }19  ],20  "size": "auto",21  "stream": false22}

References, timeouts, and result storage

  • The model defaults to up to 14 references and 40 MB of original bytes combined; account or platform limits may be tighter. Prompt text is limited to 12,000 characters.
  • Use file uploads, public URLs, or image data URLs. Private addresses and account-scoped Files API file_id are unsupported. Images must be readable supported formats such as PNG/JPEG/WebP.
  • Base64 increases size. The default whole-request limit is 64 MB, so original file size alone is not sufficient.
  • Generation can take tens of seconds or longer. Configure suitable connection and read timeouts. A client timeout does not prove generation failed; do not blindly resubmit paid requests.
  • Download the complete returned URL without an API key. Preserve id, sig, and the query string. Cleanup or signature changes can invalidate old links, so save the image to your own storage promptly.

Verified coverage and troubleshooting

The integration task on 2026-11-27 completed the following real requests through api.unifyllm.top and downloaded and decoded the resulting images. This records that test scope, not a latency or capability guarantee.

  • 400: check size, resolution tier, aspect ratio, references, and current prompt.
  • 401: check the key and model access. 413: reduce the encoded request size. 429: reduce concurrency and follow Retry-After.
  • 500 can indicate upstream rejection, timeout, no valid image, or storage failure. Keep the time, request ID, and error for support.
  • Missing usage is not a zero-cost statement. Check the model, usage, and charge in the console. Retry the same image URL first if download fails.
ScenarioVerified result
Native 1K generationHTTP 200 / Base64 / 1024×1024
Images generation, 1920x1080HTTP 200 / URL / 2752×1536
Single-reference multipart editHTTP 200 / URL / 1024×1024
Chat SSE generationHTTP 200 / URL / [DONE] / 1024×1024