feat: add OpenRouter image generation (#67668)

Adds OpenRouter image generation support for image_generate. Fixes #55066. Thanks @notamicrodose.
This commit is contained in:
Gabriel Kripalani
2026-04-24 02:39:19 +02:00
committed by GitHub
parent 3c5ee63c66
commit 0f026addaa
13 changed files with 579 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ summary: "Use OpenRouter's unified API to access many models in OpenClaw"
read_when:
- You want a single API key for many LLMs
- You want to run models via OpenRouter in OpenClaw
- You want to use OpenRouter for image generation
title: "OpenRouter"
---
@@ -59,6 +60,25 @@ Bundled fallback examples:
| `openrouter/openrouter/healer-alpha` | OpenRouter Healer Alpha route |
| `openrouter/openrouter/hunter-alpha` | OpenRouter Hunter Alpha route |
## Image generation
OpenRouter can also back the `image_generate` tool. Use an OpenRouter image model under `agents.defaults.imageGenerationModel`:
```json5
{
env: { OPENROUTER_API_KEY: "sk-or-..." },
agents: {
defaults: {
imageGenerationModel: {
primary: "openrouter/google/gemini-3.1-flash-image-preview",
},
},
},
}
```
OpenClaw sends image requests to OpenRouter's chat completions image API with `modalities: ["image", "text"]`. Gemini image models receive supported `aspectRatio` and `resolution` hints through OpenRouter's `image_config`.
## Authentication and headers
OpenRouter uses a Bearer token with your API key under the hood.