所有服务器工具
让任何文本模型都能生成图像。模型编写图像提示词,OpenRouter 使用配置的图像模型(默认为 openai/gpt-5-image)生成图像,并将图像与响应一同返回。
工作原理
用于向任何模型的回复添加图像,包括纯文本模型。
- 1
您的模型 判断图像会有帮助,并为其编写提示词。
- 2
OpenRouter 使用配置的图像模型生成图像并返回 URL。
- 3
您的模型 在响应中包含图像,并且可以创建多张图像。
提供商与定价
OpenRouter
图像模型定价
按工具调用的图像模型计价;可选择任何支持图像输出的模型。
每个请求均按标准模型 token 费用计费。
使用此工具
OpenRouter 在请求期间运行工具并将结果返回给模型,因此无需客户端工具循环。
支持的 API:Chat Completions, Responses, and Anthropic Messages。
shell
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.2",
"tools": [
{
"type": "openrouter:image_generation"
}
],
"messages": [
{
"role": "user",
"content": "Draw a watercolor painting of a lighthouse at dusk."
}
]
}'文档中提供了设置、参数和示例。
阅读集成指南常见问题
Yes. Add the openrouter:image_generation tool to the request’s tools array. The model writes an image prompt when the conversation calls for one, OpenRouter generates the image with an image model, and the image comes back with the response. A model with text-only output, such as openai/gpt-5.2, can answer with images this way.
The tool uses openai/gpt-5-image unless you set parameters.model on the tool entry. Any model with image output on OpenRouter can be selected, so switching image models changes one field and keeps the same API key and request shape. Other parameters such as quality, size and aspect_ratio pass through to that model.
Each image is billed at the selected image model’s price, on top of the token cost of the model that calls the tool. Each image model’s price is on its model page and in the image models collection.
With the Images API (POST /api/v1/images), your code writes the prompt and calls the image model directly. With the tool, the model decides when an image helps, writes the prompt itself and can create several images in one Chat Completions, Responses or Anthropic Messages request.