diff --git a/.openclaw-sync/source.json b/.openclaw-sync/source.json index 0b07d0087..f9fc39998 100644 --- a/.openclaw-sync/source.json +++ b/.openclaw-sync/source.json @@ -1,5 +1,5 @@ { "repository": "openclaw/openclaw", - "sha": "d4d307e07a863823bbb401fdaeb6c00ebeaf4dfa", - "syncedAt": "2026-04-24T00:31:44.575Z" + "sha": "0f026addaab28e03b42a0bd80243145feb9656f2", + "syncedAt": "2026-04-24T00:40:10.805Z" } diff --git a/docs/help/testing.md b/docs/help/testing.md index fb27fc70c..43a329639 100644 --- a/docs/help/testing.md +++ b/docs/help/testing.md @@ -868,12 +868,13 @@ If you want to rely on env keys (e.g. exported in your `~/.profile`), run local - `google` - `minimax` - `openai` + - `openrouter` - `vydra` - `xai` - Optional narrowing: - - `OPENCLAW_LIVE_IMAGE_GENERATION_PROVIDERS="openai,google,xai"` - - `OPENCLAW_LIVE_IMAGE_GENERATION_MODELS="openai/gpt-image-2,google/gemini-3.1-flash-image-preview,xai/grok-imagine-image"` - - `OPENCLAW_LIVE_IMAGE_GENERATION_CASES="google:flash-generate,google:pro-edit,xai:default-generate,xai:default-edit"` + - `OPENCLAW_LIVE_IMAGE_GENERATION_PROVIDERS="openai,google,openrouter,xai"` + - `OPENCLAW_LIVE_IMAGE_GENERATION_MODELS="openai/gpt-image-2,google/gemini-3.1-flash-image-preview,openrouter/google/gemini-3.1-flash-image-preview,xai/grok-imagine-image"` + - `OPENCLAW_LIVE_IMAGE_GENERATION_CASES="google:flash-generate,google:pro-edit,openrouter:generate,xai:default-generate,xai:default-edit"` - Optional auth behavior: - `OPENCLAW_LIVE_REQUIRE_PROFILE_KEYS=1` to force profile-store auth and ignore env-only overrides diff --git a/docs/providers/openrouter.md b/docs/providers/openrouter.md index 907e6747a..0c623648e 100644 --- a/docs/providers/openrouter.md +++ b/docs/providers/openrouter.md @@ -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. diff --git a/docs/tools/image-generation.md b/docs/tools/image-generation.md index 944f7cf1b..8a16233f1 100644 --- a/docs/tools/image-generation.md +++ b/docs/tools/image-generation.md @@ -1,5 +1,5 @@ --- -summary: "Generate and edit images using configured providers (OpenAI, OpenAI Codex OAuth, Google Gemini, fal, MiniMax, ComfyUI, Vydra, xAI)" +summary: "Generate and edit images using configured providers (OpenAI, OpenAI Codex OAuth, Google Gemini, OpenRouter, fal, MiniMax, ComfyUI, Vydra, xAI)" read_when: - Generating images via the agent - Configuring image generation providers and models @@ -15,7 +15,7 @@ The tool only appears when at least one image generation provider is available. ## Quick start -1. Set an API key for at least one provider (for example `OPENAI_API_KEY` or `GEMINI_API_KEY`) or sign in with OpenAI Codex OAuth. +1. Set an API key for at least one provider (for example `OPENAI_API_KEY`, `GEMINI_API_KEY`, or `OPENROUTER_API_KEY`) or sign in with OpenAI Codex OAuth. 2. Optionally set your preferred model: ```json5 @@ -46,15 +46,16 @@ The agent calls `image_generate` automatically. No tool allow-listing needed — ## Supported providers -| Provider | Default model | Edit support | Auth | -| -------- | -------------------------------- | ---------------------------------- | ----------------------------------------------------- | -| OpenAI | `gpt-image-2` | Yes (up to 4 images) | `OPENAI_API_KEY` or OpenAI Codex OAuth | -| Google | `gemini-3.1-flash-image-preview` | Yes | `GEMINI_API_KEY` or `GOOGLE_API_KEY` | -| fal | `fal-ai/flux/dev` | Yes | `FAL_KEY` | -| MiniMax | `image-01` | Yes (subject reference) | `MINIMAX_API_KEY` or MiniMax OAuth (`minimax-portal`) | -| ComfyUI | `workflow` | Yes (1 image, workflow-configured) | `COMFY_API_KEY` or `COMFY_CLOUD_API_KEY` for cloud | -| Vydra | `grok-imagine` | No | `VYDRA_API_KEY` | -| xAI | `grok-imagine-image` | Yes (up to 5 images) | `XAI_API_KEY` | +| Provider | Default model | Edit support | Auth | +| ---------- | --------------------------------------- | ---------------------------------- | ----------------------------------------------------- | +| OpenAI | `gpt-image-2` | Yes (up to 4 images) | `OPENAI_API_KEY` or OpenAI Codex OAuth | +| OpenRouter | `google/gemini-3.1-flash-image-preview` | Yes (up to 5 input images) | `OPENROUTER_API_KEY` | +| Google | `gemini-3.1-flash-image-preview` | Yes | `GEMINI_API_KEY` or `GOOGLE_API_KEY` | +| fal | `fal-ai/flux/dev` | Yes | `FAL_KEY` | +| MiniMax | `image-01` | Yes (subject reference) | `MINIMAX_API_KEY` or MiniMax OAuth (`minimax-portal`) | +| ComfyUI | `workflow` | Yes (1 image, workflow-configured) | `COMFY_API_KEY` or `COMFY_CLOUD_API_KEY` for cloud | +| Vydra | `grok-imagine` | No | `VYDRA_API_KEY` | +| xAI | `grok-imagine-image` | Yes (up to 5 images) | `XAI_API_KEY` | Use `action: "list"` to inspect available providers and models at runtime: @@ -134,7 +135,11 @@ Tool results report the applied settings. When OpenClaw remaps geometry during p defaults: { imageGenerationModel: { primary: "openai/gpt-image-2", - fallbacks: ["google/gemini-3.1-flash-image-preview", "fal/fal-ai/flux/dev"], + fallbacks: [ + "openrouter/google/gemini-3.1-flash-image-preview", + "google/gemini-3.1-flash-image-preview", + "fal/fal-ai/flux/dev", + ], }, }, }, @@ -167,13 +172,31 @@ Notes: ### Image editing -OpenAI, Google, fal, MiniMax, ComfyUI, and xAI support editing reference images. Pass a reference image path or URL: +OpenAI, OpenRouter, Google, fal, MiniMax, ComfyUI, and xAI support editing reference images. Pass a reference image path or URL: ``` "Generate a watercolor version of this photo" + image: "/path/to/photo.jpg" ``` -OpenAI, Google, and xAI support up to 5 reference images via the `images` parameter. fal, MiniMax, and ComfyUI support 1. +OpenAI, OpenRouter, Google, and xAI support up to 5 reference images via the `images` parameter. fal, MiniMax, and ComfyUI support 1. + +### OpenRouter image models + +OpenRouter image generation uses the same `OPENROUTER_API_KEY` and routes through OpenRouter's chat completions image API. Select OpenRouter image models with the `openrouter/` prefix: + +```json5 +{ + agents: { + defaults: { + imageGenerationModel: { + primary: "openrouter/google/gemini-3.1-flash-image-preview", + }, + }, + }, +} +``` + +OpenClaw forwards `prompt`, `count`, reference images, and Gemini-compatible `aspectRatio` / `resolution` hints to OpenRouter. Current built-in OpenRouter image model shortcuts include `google/gemini-3.1-flash-image-preview`, `google/gemini-3-pro-image-preview`, and `openai/gpt-5.4-image-2`; use `action: "list"` to see what your configured plugin exposes. ### OpenAI `gpt-image-2`