For dedicated image generation models like Flux, Imagen & others, please refer
to the Images Generations API
Reference.
How to Generate Images
To generate an image, send a standard Chat Completion request to a compatible model with a clear text prompt asking for an image.Streaming
Image generation also works with streaming. Set"stream": true in your request to receive the response as a stream of events.
Configuration Options
Aspect Ratio (Gemini 2.5 Flash)
For thegemini-2.5-flash-image model, you can control the aspect ratio of generated images using the image_config parameter:
1:1- Square2:3- Portrait3:2- Landscape3:4- Portrait4:3- Landscape4:5- Portrait5:4- Landscape9:16- Vertical (mobile)16:9- Widescreen21:9- Ultra-wide
Response Format
The generated image will be included in the assistant’s message in animages array.
- Non-Stream
- Stream