Gemini / Nano Banana Images

Nano Banana 2.1 Image Generation and Editing

Use gemini-nano-banana-2.1-bs with Gemini native, Images, and Chat formats. Compare output, size mapping, references, and streaming.

Updated

Request formats and image output

The model ID is gemini-nano-banana-2.1-bs. Use https://api.juhenextvip.com with Authorization: Bearer <YOUR_API_KEY>. Choose the format that matches your client and desired output.

FormatEndpointImage output
Gemini/v1beta/models/{model}:generateContentinlineData Base64
Images/v1/images/generationsdata[0].url
Images edits/v1/images/editsdata[0].url
Chat/v1/chat/completionsMarkdown image URL; JSON or SSE

Resolution and aspect ratio

Dimensions select a resolution tier and composition; exact pixels are not promised. Read the actual output dimensions. The compatibility layer does not resize or crop the result.

InputExampleMapped result
sizeautoDefault 1K; text-only defaults to 1:1, references let upstream choose
size1536x10241K / 3:2
size1920x10802K / 16:9
size1600x10002K / 3:2 (nearest)
size4096x2304Still 2K / 16:9, not 4K

Single-turn input and reference limits

  • Images generation is text-only; use edits for references. Chat uses only the last user message and does not restore previous images.
  • URL references must be publicly accessible; private addresses are rejected. Replace example.com URLs and Base64 placeholders. Do not put API keys in image URLs.
  • n, response_format, quality, mask, input_fidelity, background, output_format, and output_compression are ignored. They do not enable multiple images, Base64, transparency, or format conversion.
  • The default whole-request limit is 64 MB including Base64 and JSON overhead. The original-image limit is not the final encoded request size.

Usage, errors, and saving results

  • usage / usageMetadata is returned only when provided upstream. Images use input_tokens/output_tokens; Chat uses prompt_tokens/completion_tokens. Missing usage is not a zero-cost statement.
  • 400 usually means invalid parameters or model capabilities; 401 is authentication; 413 is request size; 429 is capacity or rate limiting. Upstream rejection, timeout, no valid image, or storage failure may return 500. Keep the request ID and error for diagnosis.
  • Generation can take time. Chat stream=true starts only after successful generation and storage, without waiting-period progress. Read SSE through data: [DONE]; do not parse the entire stream as one JSON object.
  • URLs are not permanent archives: cleanup or signature changes can invalidate them. Download promptly and preserve id, sig, and the original query string.

Iterative editing in an application

  • The compatibility route does not store conversation history. For the next edit, explicitly include the previous result URL or data URL in edits or in image_url of the last user message.
  • Applications manage prompts, reference order, and current results. Agent workflows can coordinate turns at the application layer; the API does not restore context automatically.
  • For native Base64, use generateContent with one current user content. imageSize accepts 1K or 2K; streamGenerateContent is unsupported.