Skip to main content
Certain Chat Completion models possess native image generation capabilities. This page explains how to use this feature with those specific models.
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-3-pro-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-3-pro-image-preview",
  "messages": [
    {
      "role": "user",
      "content": "Create an image of a futuristic city"
    }
  ],
  "stream": true
}

Configuration Options

Aspect Ratio & Resolution

For the gemini-3-pro-image-preview model, you can control the aspect ratio and resolution (image size) of generated images using the image_config parameter:
{
  "model": "gemini-3-pro-image-preview",
  "messages": [
    {
      "role": "user",
      "content": "Generate a beautiful sunset over mountains"
    }
  ],
  "image_config": {
    "aspect_ratio": "16:9",
    "image_size": "4K"
  }
}
Supported aspect ratios:
  • 1:1 - Square
  • 2:3 - Portrait
  • 3:2 - Landscape
  • 3:4 - Portrait
  • 4:3 - Landscape
  • 4:5 - Portrait
  • 5:4 - Landscape
  • 9:16 - Vertical (mobile)
  • 16:9 - Widescreen
  • 21:9 - Ultra-wide
Supported image sizes (resolution):
  • 1K
  • 2K
  • 4K

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.