Use OpenRouter in your coding agents
To use OpenRouter in opencode, pi, Qwen Code, Crush, Claude Code and seven more agents, add your key once with yoink add, pick the openrouter preset and its models, then tick the agents. yoink writes each config with the endpoint that agent prefers. Codex is the exception: it needs a Responses endpoint the preset lacks (why).
On this page
At a glance
| Fact | Value |
|---|---|
| Preset id | openrouter |
openai-chat endpoint | https://openrouter.ai/api/v1 |
anthropic-messages endpoint | https://openrouter.ai/api |
| API keys page | https://openrouter.ai/settings/keys |
| Harnesses it reaches | 12 of 13 |
| Add command | yoink add --external --name <name> --preset openrouter |
| Harness | With this preset |
|---|---|
| Claude Code | uses anthropic-messages |
| pi | uses openai-chat |
| omp | uses openai-chat |
| opencode | uses openai-chat |
| codex | not offered: needs openai-responses |
| Qwen Code | uses openai-chat |
| Kilo Code | uses openai-chat |
| Droid | uses anthropic-messages |
| Crush | uses openai-chat |
| Goose | uses openai-chat |
| Zed | uses openai-chat |
| Continue | uses openai-chat |
| Claude Desktop | uses anthropic-messages |
Generated from the yoink CLI source and docs/providers.md (presets.ts).
Two endpoints, one key
The openrouter preset knows two base URLs for the same key: https://openrouter.ai/api/v1 for OpenAI Chat Completions and https://openrouter.ai/api for Anthropic Messages. Each agent gets the first protocol in its own preference order that the preset offers, so the table above is also a map of which URL lands in which config file. Droid, for example, prefers Anthropic Messages, while pi, opencode and Crush take the Chat endpoint.
A preset is never probed. Instead, whenever yoink lists OpenRouter's models (in the interactive add, or with yoink probe --preset openrouter), it also checks the key against https://openrouter.ai/api/v1/key. If OpenRouter answers 401 or 403, yoink stops with "OpenRouter rejected the API key" before writing anything. Of the seven presets, OpenRouter is the only one with that check. The scripted yoink add --external --preset openrouter takes your --models as given and never contacts OpenRouter; it only looks the ids up on models.dev.
Add it
Interactively, run yoink add, choose Provider (API key), then OpenRouter, paste the key (the input is hidden), pick models and tick harnesses. From a script, pass the key on stdin so it stays out of your shell history:
yoink add
echo "$OPENROUTER_API_KEY" | yoink add --external --name openrouter --preset openrouter \
--models z-ai/glm-4.7 --connect pi,opencode,crush --default z-ai/glm-4.7 --token-stdin
yoink connect openrouter --to qwen,kilo,continue--connect and yoink connect --to take the harness ids. If one of the configs is tracked by git, the scripted forms refuse to write the key into it unless you add --allow-tracked.
Pick models
The model picker is built from OpenRouter's live list at https://openrouter.ai/api/v1/models, so it shows whatever OpenRouter serves today. Lists longer than 12 entries get a search box. OpenRouter model ids carry the vendor as a prefix, such as z-ai/glm-4.7, and yoink writes them exactly like that into every agent. For each model, yoink looks up the context window, output limit, reasoning and image support on models.dev.
yoink models openrouter
yoink models openrouter --set z-ai/glm-4.7,z-ai/glm-4.6Either form re-syncs every agent the provider is connected to.
Use it in Claude Code
Claude Code reaches OpenRouter through the Anthropic Messages endpoint. Because Claude Code holds one backend at a time, connecting OpenRouter makes it the active yoink profile and writes the seven managed keys into ~/.claude/settings.json, with ANTHROPIC_BASE_URL set to https://openrouter.ai/api and your default model in every tier. Switching back to a Claude account, for example with yoink work, strips those keys again.
yoink connect openrouter --to claude-code --default z-ai/glm-4.7
yoink workThe older single-model form still works (the macOS app's single-model add uses it). It saves https://openrouter.ai/api as one Anthropic Messages endpoint with one model, ready for Claude Code:
echo "$KEY" | yoink add --external --name glm --provider OpenRouter \
--base-url https://openrouter.ai/api --model z-ai/glm-4.7 --token-stdinRotate the key
Paste a new key with yoink edit openrouter (the API key field), or pipe it in. Saving the change re-writes the key into every connected agent in one step, and yoink scrubs the old key out of the backups it touched along the way.
echo "$NEW_OPENROUTER_KEY" | yoink edit openrouter --token-stdinFAQ
Does yoink check my OpenRouter key before saving it?
In the interactive add, yes: while it lists models, yoink sends the key to https://openrouter.ai/api/v1/key, and a 401 or 403 answer stops the add before anything is written. The scripted form skips the check, so run yoink probe --preset openrouter --token-stdin first if you want it.
Which OpenRouter URL ends up in which agent?
Claude Code, Droid and Claude Desktop get https://openrouter.ai/api, the Anthropic Messages address. Claude Code and Claude Desktop accept nothing else, and Droid lists Anthropic Messages first. Every other agent yoink connects, such as opencode, pi, Crush, Qwen Code and Goose, gets https://openrouter.ai/api/v1 for Chat Completions.
Related
- Use any provider in pi
Connect any OpenAI- or Anthropic-compatible provider to pi. yoink writes ~/.pi/agent/models.json with model limits from models.dev and sets the default.
- Providers
Add an API key once with yoink, from a preset (OpenAI, Kimi, OpenRouter, DeepSeek, z.ai, Ollama) or any compatible URL it probes, and pick its models.
- Harnesses
What yoink writes into pi, omp, opencode, codex, Claude Code, Qwen Code, Kilo, Droid, Crush, Continue, Goose, Zed and Claude Desktop: paths and keys.
- Use an OpenAI API key in your coding agents
The openai preset has a Responses endpoint, so it is the one preset that reaches Codex. yoink writes it to 11 agents; Claude Code needs Anthropic Messages.
- Use a Kimi Code API key in your coding agents
The kimi-code preset points Claude Code at api.kimi.com/coding and opencode, pi or Crush at api.kimi.com/coding/v1. Distinct from switching Kimi logins.
- Use the Moonshot AI API in your coding agents
Connect a Moonshot AI platform key to Claude Code via api.moonshot.ai/anthropic, and to opencode, pi, Qwen Code or Crush via api.moonshot.ai/v1.