Endpoint
Authentication
Requires authentication using Bearer token or x-api-key header. See Authentication.Request Body
A text description of the desired image(s).Example:
"A white siamese cat"The model to use for image generation.Options:
"auto"- Automatically selectsgemini-3-pro-image-preview"gemini-2.5-flash-image""gemini-3-pro-image-preview"- Other image generation models
"gemini-2.5-flash-image"The number of images to generate. Must be between 1 and 10.Example:
1The size of the generated images. Supported sizes depend on the model.Common sizes:
"1024x1024"(square)"1792x1024"(landscape)"1024x1792"(portrait)"1536x1024""1024x1536"
"1024x1024"The aspect ratio of the generated images. Takes precedence over
size if both are provided.Common ratios:"1:1"(square)"16:9"(landscape)"9:16"(portrait)"4:3""3:2""7:4"
"16:9"The quality of the generated image.Options:
"standard", "hd", "low", "medium", "high"Example: "standard"The style of the generated images.Options:
"vivid"- Hyper-real, dramatic lighting and colors"natural"- Realistic, organic look
"vivid"The format in which the generated images are returned. Only
b64_json is supported.Example: "b64_json"Response
Unix timestamp of when the images were created.
Array of generated images.Each image contains:
b64_json(string): Base64-encoded image datarevised_prompt(string, optional): The actual prompt used (may differ from input)
Examples
Generate Single Image
Generate Multiple Images
Custom Aspect Ratio
High Quality with Vivid Style
Response Example
Image Edits Endpoint
The gateway also supports editing existing images:Request Body (JSON)
Array of input image references to edit. Each image must have:
image_url(string): HTTPS URL or base64 data URL
A text description of the desired image edit.Example:
"Add a watercolor effect to this image"The model to use for image editing.Example:
"gemini-3-pro-image-preview"The number of edited images to generate (1-10).Example:
1Background behavior for generated image output.Options:
"transparent", "opaque", "auto"Example: "transparent"Controls fidelity to the original input image(s).Options:
"high", "low"Example: "high"Output quality for image models.Options:
"low", "medium", "high", "auto"Example: "high"Requested output image size.Options:
"auto", "1024x1024", "1536x1024", "1024x1536"Example: "1024x1024"Output image format.Options:
"png", "jpeg", "webp"Example: "png"Compression level for JPEG or WebP output (0-100).Example:
100Multipart Form Data
The edits endpoint also acceptsmultipart/form-data for OpenAI compatibility:
imageimage[](used by some clients)file
mask- Mask image to specify areas to edit
Edit Image Example
Error Responses
Invalid Request
No Images Generated
Invalid Image URL
Notes
- Images are returned as base64-encoded data in the response
- The gateway internally uses chat completion models with image generation capabilities
- Different models support different aspect ratios and sizes
- For best results, provide detailed and specific prompts
- The
revised_promptin the response shows how the model interpreted your prompt