OpenRouter Gateway
One OpenRouter key, five new modalities for Agent Zero: image generation with image-to-image, multilingual text-to-speech, audio transcription, async video generation, and multimodal embeddings. Includes read-aloud voice integration and model catalog search.
README
OpenRouter Gateway
One API key. Every modality. Image generation, text-to-speech, transcription, video generation, and embeddings for Agent Zero — all through your OpenRouter account.
What it does
Agent Zero's chat models already work with OpenRouter out of the box. But OpenRouter offers much more than chat — and those endpoints are not OpenAI-compatible, so the framework cannot reach them. This plugin closes that gap:
| Capability | Tool | What you get |
|---|---|---|
| 🖼️ Image generation | openrouter_image |
Text-to-image and image-to-image (FLUX, Gemini Image, GPT-Image, Grok, …) |
| 🗣️ Text-to-speech | openrouter_tts |
Natural voices in many languages, saved as MP3 |
| 🔊 Voice output | (automatic) | Agent Zero's read-aloud button speaks with your chosen OpenRouter voice |
| 📝 Transcription | openrouter_transcribe |
Audio files → text (Whisper, Deepgram, Grok STT, …) |
| 🎬 Video generation | openrouter_video |
Text-to-video (Veo, Kling, Seedance, Sora, …) |
| 🧬 Embeddings | openrouter_embeddings |
Similarity vectors for texts and images |
| 🔍 Model discovery | openrouter_models |
Search the live OpenRouter catalog |
Chat/LLM models stay where they are: Settings → Models with the built-in openrouter provider. This plugin never touches them.
Quick start
- API key: Create a key at openrouter.ai/keys and store it in Agent Zero's secret
API_KEY_OPENROUTER(Settings → Secrets). Alternatively paste it directly into the plugin settings. - Open the settings: Settings → Agent → OpenRouter Gateway.
- Pick your default models: Every model field suggests live entries from the OpenRouter catalog as you type — no need to look up model ids. Only configure what you plan to use; everything else can stay empty.
That's it. Now just ask your agent:
"Generate an image of a lighthouse at dawn" "Read this text aloud" "Transcribe /a0/usr/workdir/meeting.mp3" "Make a short video of a paper boat in the rain"
Tools in detail
Image generation — openrouter_image
{
"tool_name": "openrouter_image",
"tool_args": {
"prompt": "A cinematic robot painter in Berlin",
"size": "1792x1024"
}
}
sizemaps to the closest supported aspect ratio (1:1,16:9,9:16,4:3,3:4)- Images appear directly in the chat
- Image-to-image: add
"reference_images": ["/path/to/photo.jpg"](local paths or URLs) to transform existing images — e.g. "make this photo a watercolor painting"
Text-to-speech — openrouter_tts
{
"tool_name": "openrouter_tts",
"tool_args": { "text": "Hello world", "format": "mp3" }
}
Saves an MP3 (or raw PCM) and returns its path. Uses your default TTS model and voice from the settings; both can be overridden per call.
Transcription — openrouter_transcribe
{
"tool_name": "openrouter_transcribe",
"tool_args": { "path": "/a0/usr/workdir/meeting.mp3", "language": "de" }
}
Supports wav, mp3, flac, m4a, ogg, webm, aac. Audio is sent base64-encoded — remote URLs must be downloaded first. Returns the text plus duration/cost.
Video generation — openrouter_video
{
"tool_name": "openrouter_video",
"tool_args": {
"prompt": "A paper boat sailing down a rainy street gutter, cinematic",
"resolution": "480p",
"duration": 4
}
}
Video generation is asynchronous: the tool submits a job, polls until it finishes (typically 1–5 minutes), and saves the MP4. If it times out (video_poll_timeout, default 600s), the job id is reported — the job usually still completes; just ask the agent to check that job id instead of generating again (you'd pay twice).
💡 Video is the most expensive modality — a short 480p clip costs roughly $0.10–0.30 depending on the model.
Embeddings — openrouter_embeddings
{
"tool_name": "openrouter_embeddings",
"tool_args": {
"inputs": ["first text", "/a0/usr/workdir/photo.jpg"],
"model": "openai/text-embedding-3-small"
}
}
For similarity search, clustering, deduplication, and image search. Texts embed directly; image paths become multimodal inputs (requires a multimodal embedding model). Vectors are written to a JSON file — the chat only shows count, dimensions, and cost.
Model discovery — openrouter_models
{
"tool_name": "openrouter_models",
"tool_args": { "query": "video", "limit": 10 }
}
Searches the live OpenRouter catalog by id or name — useful to find model ids for any of the tools above.
Voice output: let Agent Zero speak with an OpenRouter voice
Once you set a Default TTS model in the plugin settings, the plugin registers itself as a voice provider for Agent Zero's built-in read-aloud feature — the 🔊 button on chat messages then speaks through OpenRouter.
- Pick a model and voice in the settings; the ▶ Preview button plays a short sample so you can choose by ear
- The voice dropdown loads the actual voices supported by your selected model — always current
- A status card appears under Settings → Voice
- No TTS model configured? The plugin stays out of the way and voice output falls back to Kokoro/browser TTS
Settings reference
| Setting | Purpose |
|---|---|
| API key secret alias / API key | Where your OpenRouter key comes from (secret alias recommended) |
| Default image model / size / resolution | Used when a tool call doesn't specify them |
| Default TTS model / voice / format | For openrouter_tts and the voice output integration |
| Default transcription model | For openrouter_transcribe |
| Default video model / poll timeout | For openrouter_video |
| Default embedding model | For openrouter_embeddings |
| Provider routing | Optional fine-tuning of how OpenRouter picks providers (see below) |
All model fields auto-suggest live from the OpenRouter catalog — start typing and pick.
Provider routing (optional)
Control how OpenRouter routes your requests across its providers — applies to all tools:
| Option | Effect |
|---|---|
| Allow fallbacks | Retry with alternative providers when the first fails |
| Sort by | price (cheapest), latency (fastest), or throughput |
| Preferred providers | Comma-separated list, tried in order (e.g. Google, OpenAI) |
| Ignore providers | Providers to skip entirely |
Leave everything empty to let OpenRouter decide (recommended to start with).
Troubleshooting
| Symptom | Fix |
|---|---|
| "OpenRouter API key is not configured" | Set the secret API_KEY_OPENROUTER or paste a key in the plugin settings |
| "No OpenRouter … model configured" | Set the matching default model in the settings, or pass model in the tool call |
| Tools don't appear in chat | Reload the WebUI after enabling the plugin |
| Voice preview fails with a provider error | Some models require a voice — pick one from the dropdown; others reject unknown voices — try (provider default) |
| Video times out | The job likely still finishes — ask the agent to check the reported job id; raise video_poll_timeout for slow models |
| 402 errors | Your OpenRouter account is out of credits |
Automatic cost tracking
When the LLM Cost Tracker plugin is also installed and active, usage and costs from all OpenRouter Gateway tools are automatically captured — no configuration needed.
| Endpoint | What's tracked |
|---|---|
| Image generation | Token usage + cost from response body and headers |
| Text-to-speech | Cost from response headers (audio responses are raw bytes) |
| Transcription | Token usage from response body |
| Embeddings | Token usage and cost from response body |
| Video generation | Cost from response at job submit and completion |
The integration is fail-open: if the Cost Tracker is disabled or not installed, the OpenRouter Gateway works normally with zero overhead. When both are active, OpenRouter costs appear in the Cost Tracker dashboard alongside your chat model costs.
To see OpenRouter costs in the dashboard, add pricing rules with provider_class: "openrouter" in the Cost Tracker settings, or rely on provider-reported costs when OpenRouter includes them in responses.
Pricing note
All usage is billed by OpenRouter at provider list prices (no markup). Rough orders of magnitude: embeddings are fractions of a cent, images and TTS cents, video tens of cents per clip. Failed requests are not billed.