Image Generation
Beta
Server tools are currently in beta. The API and behavior may change.
The 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-image-1). - 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 optional parameters to customize the output:
All parameters except 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:
If generation fails, the response includes an error:
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-image-1: See OpenAI pricing
- Other models: See the model’s pricing page on OpenRouter
The cost is in addition to standard LLM token costs for processing the request and response.
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