Generate an image synchronously via the native Gemini generateContent protocol — a single request returns the base64 image, no polling.
⚡ Synchronous call:This synchronous endpoint is offered in parallel with the async nano channel (POST /api/cqt/generator/nano). The public "Nano tier" is backed by Gemini image models; a single request returns the base64 image directly — no taskId, no polling. Besides Authorization: Bearer, x-goog-api-key is also accepted. Two request formats are supported: default JSON (native Gemini protocol, below) and multipart/form-data upload (upload reference image files directly for image-to-image — see the section further down).
🔗 Protocol:Gemini generateContent protocol · a single request returns the result directly — no taskId, no polling
{model}pathRequired
Model id in the URL path (tier mapping): gemini-2.5-flash-image (Nano, 1K) / gemini-3-pro-image-preview (Nano Pro, 1K/2K/4K) / gemini-3.1-flash-image-preview (Nano 2, 1K/2K/4K)
contentsarrayRequired
Native Gemini contents array; each item has role and parts[]. Text-to-image usually needs a single role="user" item.
contents[].rolestring
Role; use "user" for image generation
contents[].parts[].textstringRequired
Text prompt describing the image to generate
contents[].parts[].inlineDataobject
Reference image for image-to-image (inline base64): { "mimeType": "image/png", "data": "<base64>" }; omit for text-to-image. You can also pass a URL via fileData.fileUri below.
contents[].parts[].fileData.fileUristring
https URL of a reference image for image-to-image (alternative to inline base64); the server downloads and inlines it. https only, up to 4 reference images; if any download fails the whole request errors and is not charged.
generationConfigobjectRequired
Generation config object; see the sub-fields below
generationConfig.responseModalitiesstring[]Required
Output modalities; must include "IMAGE" for image output (e.g. ["TEXT","IMAGE"]); omitting it returns text only
generationConfig.candidateCountnumber
Number of images: 1-4, default 1. Charged per image (xN) and settled by the number of successful images (failures refunded)
generationConfig.imageConfig.imageSizestring
Resolution: 1K / 2K / 4K, default 1K (Nano is 1K only; Nano Pro / Nano 2 support 2K/4K)
generationConfig.imageConfig.aspectRatiostring
Output ratio: 1:1 / 16:9 / 9:16 / 4:3 / 3:4 / 3:2 / 2:3 / 5:4 / 4:5 / 21:9, default 1:1; follow the official Google imageConfig spec
multipart form upload (text-to-image / image-to-image)
multipart/form-dataThe same non-stream generateContent endpoint branches by Content-Type: application/json uses the native Gemini protocol above, multipart/form-data uses this entry — upload reference images directly via the image file field for image-to-image (no base64 in JSON), or send only prompt for text-to-image. Image models + non-stream only; request body capped at 20MB (over → 413). Returns inline base64 by default; add the query param ?respFormat=url to return a CDN-link envelope instead. Billing is identical to the JSON path (settled by tier × number of successful images).
POST/ v1beta/ models/ {model}:generateContent
{model}pathRequired
Model id in the URL path (tier mapping): gemini-2.5-flash-image (Nano, 1K) / gemini-3-pro-image-preview (Nano Pro, 1K/2K/4K) / gemini-3.1-flash-image-preview (Nano 2). model comes from the URL path only, never a form field.
promptstringRequired
Text prompt: describes the image for text-to-image, or the edit instruction for image-to-image
imagefile
Reference image file (for image-to-image). Repeat the field for up to 4 images: -F
[email protected] -F
[email protected]; omit for text-to-image. png / jpg / webp
nnumber
Number of images, max 4 (maps to generationConfig.candidateCount), default 1; charged per image (xN) and settled by the number of successful images