所有伺服器工具
讓任何文字模型都能產生圖片。模型會撰寫圖片提示詞,OpenRouter 使用設定的圖片模型(預設為 openai/gpt-image-2.6-flare)產生圖片,並將圖片與回應一併傳回。
運作方式
用於在任何模型的回應中加入圖片,包括純文字模型。
- 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-image-2.6-flare 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.