Skip to main content

Image Generation

Certain Chat Completion models possess native image generation capabilities. This page explains how to use this feature with those specific models.

info

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.

{
"model": "gemini-2.5-flash-image-preview",
"messages": [
{
"role": "user",
"content": "Generate a beautiful sunset over mountains"
}
]
}

Streaming

Image generation also works with streaming. Set "stream": true in your request to receive the response as a stream of events.

{
"model": "gemini-2.5-flash-image-preview",
"messages": [
{
"role": "user",
"content": "Create an image of a futuristic city"
}
],
"stream": true
}

Response Format

The generated image will be included in the assistant's message in an images array.

{
"choices": [
{
"message": {
"role": "assistant",
"content": "I've generated a beautiful sunset image for you.",
"images": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
}
]
}
}
]
}

Discover Supported Models

You can see which Chat Completion models support native image generation on the NagaAI Models page.