Generate image
Last updated October 8, 2026
Generate images with google/gemini-nano-banana-2.1 on the native Gemini generateContent endpoint using official Google SDKs.
Image generation with google/gemini-nano-banana-2.1 via Gemini's native generateContent endpoint. Shares the same URL structure as chat generation, allowing official Google SDKs to work unchanged once their base URL points to the gateway.
Successor to Nano Banana 2 with improved visual quality, prompt adherence, multi-turn character consistency, and text rendering. Output resolutions start at 1K (no 512 tier).
https://gateway.amux.ai/v1beta/models/google/gemini-nano-banana-2.1:generateContentAuthorization
headerAuthorizationstringRequiredRequest
application/jsoncontentsarray<object>RequiredConversation turns containing prompt text and reference inputs. Place text in parts[].text; pass reference media (images, video, or PDF) inline via parts[].inline_data or by URI via parts[].file_data. Supplying reference media performs multimodal reference generation on the same endpoint.
›contentsarray<object>
role"user" | "model"Turn author: user for caller input, model for prior model responses. Optional for single-turn requests.
partsarray<object>Ordered content parts for this turn. Text and reference media may be interleaved within a single turn.
›partsarray<object>
textstringText prompt segment. Multiple text parts in one turn are concatenated in order.
inline_dataobjectInline reference media (image, video, or PDF). Total inline payload per request must not exceed 100 MB, and each PDF must not exceed 50 MB; use file_data for larger files.
›inline_dataobject
mime_typestringMedia MIME type, such as image/png, image/jpeg, video/mp4, or application/pdf.
datastringRaw file bytes encoded as Base64 without a data:...;base64, Data URL prefix.
file_dataobjectReference media supplied via URI and fetched upstream; recommended for larger assets.
›file_dataobject
mime_typestringMedia MIME type, formatted identically to inline_data.mime_type.
file_uristringFiles API URI or publicly reachable HTTPS URL (up to 15 MB per file). Upstream returns an error if the URI cannot be fetched.
generationConfigobjectRequiredGeneration configuration. Image output is governed by responseModalities and dimensions settings. Both imageConfig and responseFormat.image are accepted as equivalent dimension forms; if both are supplied, imageConfig takes precedence field by field.
›generationConfigobject
responseModalitiesarray<"TEXT" | "IMAGE">RequiredOutput modalities. Must be set to ["TEXT", "IMAGE"] to enable image generation; omitting IMAGE returns text only.
responseFormatobjectResponse format settings; image dimension controls reside under image.
›responseFormatobject
imageobjectOutput image dimension settings. Both fields are optional and default to model-selected values when omitted.
›imageobject
aspectRatio"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"Output aspect ratio across the 14 supported values. Unsupported values are ignored, recorded in amux.notes, and replaced by the model default (matching /v1/images/* and /v1/tasks).
imageSize"1K" | "2K" | "4K"Output resolution tier. Unsupported values follow the same fallback behavior as aspectRatio.
toolsarray<object>Grounding tool configuration. Pass [{ "google_search": {} }] to enable Google Search grounding. Billed per deduplicated search query listed in groundingMetadata.webSearchQueries.
Response
200responseGeneration succeeded. Generated images and text commentary are interleaved in candidates[].content.parts.
Enabling image output
Set generationConfig.responseModalities to ["TEXT", "IMAGE"]. Without IMAGE, this endpoint returns text only.
Supported parameter ranges
Aspect ratios (14):
1:1 · 2:3 / 3:2 · 3:4 / 4:3 · 4:5 / 5:4 · 9:16 / 16:9 · 21:9 · 1:4 / 4:1 · 1:8 / 8:1
Resolution tiers: 1K · 2K · 4K (defaults to 1K when omitted)
Values outside the supported sets are ignored, recorded in amux.notes, and replaced with model defaults. This native endpoint, the OpenAI-compatible image endpoint, and Amux Tasks share the same image pipeline and parameter validation rules.
On cross-protocol paths, an OpenAI-style pixel string in size (such as 1024x1024) is mapped to a supported aspect ratio and resolution tier above, with any lossy conversion recorded in amux.notes. On native Gemini calls, specify aspectRatio and imageSize directly.
Multimodal reference inputs
Reference-based generation and text-to-image share this endpoint via contents[].parts. Beyond images, this model accepts video clips and PDF documents (for example, matching the visual style of a video or generating visuals from a PDF specification):
- Inline bytes (
inline_data): pass raw Base64 without adata:prefix indataand specify the media type inmime_type(such asimage/png,video/mp4, orapplication/pdf). Total inline payload per request is capped at 100 MB, and any single PDF is capped at 50 MB. - URI reference (
file_data): pass a Files API URI or publicly reachable HTTPS URL (up to 15 MB per public URL) infile_urifor upstream fetching—recommended for larger files.
Up to 14 reference images are accepted per request (at most 10 object references and 4 character references). Media types other than image, video, and PDF are forwarded unchanged with a diagnostic note in amux.notes.
Reasoning depth (thinkingLevel)
The model performs internal reasoning prior to rendering, supporting minimal, medium (default), and high. Configure generationConfig.thinkingConfig.thinkingLevel on the native endpoint (forwarded unchanged): deeper reasoning improves complex composition and typography accuracy while increasing latency and thinking token usage.
Billing
Depending on the serving provider, output is metered either per token or per image; refer to the model page and pay-as-you-go pricing for current rates. Billing is consistent across this endpoint, /v1/images/*, and /v1/tasks.
When billed per token, image output tokens and text output tokens are priced separately: usageMetadata.candidatesTokensDetails reports per-modality counts, and each modality is billed as a distinct line item. Thinking tokens are billed at the text output rate, and video or PDF reference inputs are billed at the text input rate.
Output image token consumption depends on resolution: 1,120 tokens at 1K, 1,680 at 2K, and 3,780 at 4K.
Grounding with Google Search
Pass tools: [{ "google_search": {} }] to let the model query Google Search before generating an image. The camelCase googleSearch emitted by official SDKs is also accepted; when calling through the OpenAI-compatible image endpoint or /v1/tasks, pass web_search: true.
Grounding is billed per search query: a single call may issue multiple queries, metered by the deduplicated count of non-empty entries in candidates[].groundingMetadata.webSearchQueries.
Streaming and batching
Streaming image generation (:streamGenerateContent) is not supported for this model and is rejected; send non-streaming requests instead. Each request produces one image, with no batch count parameter.
Alternative endpoints
You can also call this model via the OpenAI-compatible image endpoint and Amux Tasks. All parameter constraints documented on this page apply across those endpoints as well.
Errors
Error responses follow Gemini's native error schema. See Errors and retries for status codes and retry guidance.
curl https://gateway.amux.ai/v1beta/models/google/gemini-nano-banana-2.1:generateContent \
-H "x-goog-api-key: $AMUX_API_KEY" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "<string>",
"inline_data": {
"mime_type": "image/png",
"data": "<string>"
},
"file_data": {
"mime_type": "video/mp4",
"file_uri": "https://example.com/clip.mp4"
}
}
]
}
],
"generationConfig": {
"responseModalities": [
"TEXT",
"IMAGE"
],
"responseFormat": {
"image": {
"aspectRatio": "1:1",
"imageSize": "1K"
}
}
},
"tools": [
{}
]
}'{
"candidates": [
{
"content": {
"parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "image/png",
"data": "<string>"
}
}
]
}
}
],
"usageMetadata": {
"promptTokenCount": 0,
"candidatesTokenCount": 0,
"totalTokenCount": 0,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 0
}
],
"candidatesTokensDetails": [
{
"modality": "IMAGE",
"tokenCount": 0
}
]
}
}