BetaServer tools are currently in beta. The API and behavior may change.
openrouter:image_generation server tool enables any model to generate images from text prompts. When the model determines it needs to create an image, it calls the tool with a description. OpenRouter executes the image generation and returns the result to the model.
How It Works
- You include
{ "type": "openrouter:image_generation" }in yourtoolsarray. - Based on the user’s request, the model decides whether image generation is needed and crafts a prompt.
- OpenRouter generates the image using the configured model (defaults to
openai/gpt-5-image). - The generated image URL is returned to the model.
- The model incorporates the image into its response. It may generate multiple images in a single request if needed.
Quick Start
Configuration
The image generation tool accepts optionalparameters to customize the output:
| Parameter | Type | Default | Description |
|---|---|---|---|
model | string | openai/gpt-5-image | Which image generation model to use. See available image models. |
quality | string | — | Image quality level (model-dependent, e.g. "low", "medium", "high") |
size | string | — | Image dimensions (e.g. "1024x1024", "512x512") |
aspect_ratio | string | — | Aspect ratio (e.g. "16:9", "1:1", "4:3") |
background | string | — | Background style (e.g. "transparent", "opaque") |
output_format | string | — | Output format (e.g. "png", "jpeg", "webp") |
output_compression | number | — | Compression level (0-100) for lossy formats |
moderation | string | — | Content moderation level (e.g. "auto", "low") |
model are passed directly to the underlying image generation API. Available options depend on the specific model being used.
Response
When the model calls the image generation tool, it receives a response like:Works with the Responses API
The image generation server tool also works with the Responses API:Pricing
Image generation pricing depends on the underlying model used:- openai/gpt-5-image (default): See model page
- openai/gpt-5-image-mini: See model page
- openai/gpt-5.4-image-2: See model page
- Other models: See the image models list on OpenRouter
Next Steps
- Server Tools Overview — Learn about server tools
- Web Search — Search the web for real-time information
- Datetime — Get the current date and time
- Tool Calling — Learn about user-defined tool calling