mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:20:43 +00:00
Adds OpenRouter image generation support for image_generate. Fixes #55066. Thanks @notamicrodose.
4.7 KiB
4.7 KiB
summary, read_when, title
| summary | read_when | title | |||
|---|---|---|---|---|---|
| Use OpenRouter's unified API to access many models in OpenClaw |
|
OpenRouter |
OpenRouter provides a unified API that routes requests to many models behind a single endpoint and API key. It is OpenAI-compatible, so most OpenAI SDKs work by switching the base URL.
Getting started
Create an API key at [openrouter.ai/keys](https://openrouter.ai/keys). ```bash openclaw onboard --auth-choice openrouter-api-key ``` Onboarding defaults to `openrouter/auto`. Pick a concrete model later:```bash
openclaw models set openrouter/<provider>/<model>
```
Config example
{
env: { OPENROUTER_API_KEY: "sk-or-..." },
agents: {
defaults: {
model: { primary: "openrouter/auto" },
},
},
}
Model references
Model refs follow the pattern `openrouter//`. For the full list of available providers and models, see [/concepts/model-providers](/concepts/model-providers).Bundled fallback examples:
| Model ref | Notes |
|---|---|
openrouter/auto |
OpenRouter automatic routing |
openrouter/moonshotai/kimi-k2.6 |
Kimi K2.6 via MoonshotAI |
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:
{
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.
On real OpenRouter requests (https://openrouter.ai/api/v1), OpenClaw also adds
OpenRouter's documented app-attribution headers:
| Header | Value |
|---|---|
HTTP-Referer |
https://openclaw.ai |
X-OpenRouter-Title |
OpenClaw |
X-OpenRouter-Categories |
cli-agent |