Model Cards
Size Control
- Follow the source image ratio: simply omit
aspectRatio; in multi-image editing scenarios, the size of the last image takes precedence - Resolution
imageSize: supports1K/2K/4K- Nano Banana (Gen 1) supports 1K only
- Nano Banana 2 adds 512px
- Nano Banana 2 Lite supports 1K only (no 2K/4K/512px)
How to Integrate
Official Documentation
- Google official docs:
ai.google.dev/gemini-api/docs/image-generation - To integrate with APIYI, just replace the request URL + KEY with APIYI’s; all other parameters are identical to the official ones
Checking Official Status (diagnosing upstream issues)
The Nano Banana series runs on top of Google’s AIStudio / Gemini API. In rare cases, blurry or failing 2K / 4K output can be a problem on Google’s side rather than the integration layer — you can check Google’s official status page (copy and visit it yourself):aistudio.google.com/status.
For example, on Jun 19, 2026 that page reported “Issues with Nano Banana”: Nano Banana 2 / Pro on the Gemini API and AI Studio had problems at 2K or 4K resolution. When you see similar symptoms, compare against the official status page first to quickly tell whether it’s an upstream outage.
Endpoint Support
- Recommended endpoint (Gemini native):
https://api.apiyi.com/v1beta/models/gemini-3-pro-image-preview:generateContent - Supports calls via OpenAI-compatible mode (note: URL upload is not supported, use Base64 instead)
- Does not support
/v1/image/generations
Development Format (Default Recommendation)
- [Recommended] Use the Google native endpoint format
- Images: upload as Base64, download and re-host
- Call method: synchronous multi-threaded calls; asynchronous calls are not yet supported
Input Image Requirements
- A single image cannot exceed 7MB (Google’s rule); if imported via Google Cloud Storage, the per-file limit is 30MB
- Up to 14 images per prompt
- Supported MIME types:
image/png,image/jpeg,image/webp,image/heic,image/heif(thejpgformat is already supported by APIYI) - Base64 size inflation: converting an image to Base64 increases its size by about 33.3% (a 7MB image becomes about 9.3MB)
- APIYI limit: the total volume of images uploaded in a single request must be under 100MB — all calls are synchronous, and oversized payloads can cause memory blowup

Google official technical specs: inline / console upload per-file limit is 7MB, supporting png/jpeg/webp/heic/heif

Base64 encoding increases size by about 33.3%: a 7MB image is roughly equal to 9.3MB
docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/3-pro-image
URL Image Input
In addition to Base64, the Gemini native endpoint also supports passing image URLs (image hosts / OSS addresses) directly viafileData.fileUri, eliminating the need for local encoding.
Curl Example (fileUri)
Python Example (fileUri)
Billing Basics (Important)
- Synchronous call duration: Pro / 2 at 4K take a reasonable generation time of approx. 30–150s
- Disconnecting on timeout still incurs charges: for example, if generation takes 120s but the client sets the timeout to 100s and disconnects, you are still charged
- 429 / 503 are not charged: failed requests are not billed (we try not to keep customers waiting or stuck without an image)
- Content-safety refusals still incur charges: when a customer’s input has content-safety issues and Google refuses to generate the image, a status code 200 is still charged — see error handling and the guarantee plan below
Timeout Settings (Important)
4K image generation takes longer overall, involving stages such as image upload, API processing, and Base64 image download (our backend bills by API processing time). Under normal conditions, 4K takes about 50s (excluding polling), but if the client sets the timeout too short, it will disconnect prematurely before generation completes and report an error:
Call logs: time-to-first-byte for 4K generation is about 43–61s, so the default 120s timeout is too tight
Multi-turn conversational editing (native supports it; reverse models don’t)
The Nano Banana series uses the Gemini native format and supports true conversational multi-turn editing: append each turn’s generated image back intocontents as a role: "model" inlineData, then send the next user instruction. The model edits based on the full conversation history and accumulates changes (e.g. recolor the sofa first, then add an accessory — the earlier change is preserved).
This differs fundamentally from “reverse” image models — be clear on it before integrating:
model-role turn lets Nano Banana 2 (gemini-3.1-flash-image-preview) correctly keep editing and accumulate changes; a reverse model only reads the reference image from the last user message, so keeping conversation history does not work for multi-turn there.contents):
Why Do Responses Occasionally Contain Multiple Images
When callinggemini-3-pro-image, you may occasionally see multiple image parts in a single response (2–10 observed in testing), matching sporadic 6000+ (even five-digit) output-token entries in your logs. This is not an anomaly: Google’s official docs state that Gemini 3 image models have “Thinking” enabled by default (it cannot be disabled in the API), the model generates interim images to test composition and logic, these drafts appear in parts alongside the final version, and “the last image within Thinking is also the final rendered image” (official docs: ai.google.dev/gemini-api/docs/image-generation). Based on our testing in July 2026 (Google native generateContent format):
thoughtSignature field, without a thought: true flag); Google’s docs say Thinking generates at most two interim images, but we observed up to 10 on complex tasks.
Billing impact: each image is billed at a fixed token count (1120 tokens per image at 1K/2K resolution, 2000 at 4K), so output tokens grow strictly linearly with the number of images. A sporadic 6000+ (up to ~13.5k in extreme cases) output-token entry in your logs is simply a 4–10 image response, not a billing anomaly.
Recommended downstream code:
- Always iterate over parts — do not assume one image per response; any per-image counting or saving logic must go by the actual number of parts
- Take the last image when you only need one: the earlier drafts have unfinished details and slightly lower quality, so avoid taking the first
- Controlling the image count via the prompt is largely ineffective (in testing, “output only one image” instructions were ignored) — handle it in code
- Multi-image responses take 35–142s (at 1K resolution, longer with more images), noticeably longer than single-image ones — keep the timeout recommendations above (≥ 5 minutes)
FAQs
Error Handling Guide
Must-Read Common Dev Questions
Failed Generation Guarantee Plan
Why do I get connection reset by peer / write_response_body_failed (500)?
Why do I get connection reset by peer / write_response_body_failed (500)?
- Limit the image count: stay within the official rules (max 14 images per prompt — see the official spec above).
- Limit per-image size: keep each image under 5MB — the official per-image cap is 7MB, and base64 encoding inflates size by roughly 1/3, so leave headroom.
- Compress on the frontend before uploading: compress images on the frontend (or a server-side relay) before sending them to the API — common practice is capping the longest edge, converting to JPEG/WebP, and tuning the quality parameter.
- Switch to URL input: the Gemini native format supports passing an image URL via
fileData.fileUri, sidestepping oversized base64 request bodies entirely — see URL Image Input above.
Use Cases
- AI chat clients: clients such as Cherry Studio can be configured to generate images directly via APIYI
- Generation testing: quickly verify model performance in a chat client or the console
Advanced Needs
- Want to upload images via URL? The Gemini native endpoint supports passing an image URL through
fileData.fileUri; however, OpenAI-compatible mode does not support URL upload, so use Base64 instead. See the code examples and caveats in URL Image Input above. - Want to get a download URL directly (instead of Base64)? Use the NB-OSS group — see Nano Banana OSS Group.