Docs · Provider
OpenRouter in Claude Code, Codex, Gemini CLI and OpenCode
OpenRouter sells many vendors’ models behind one key and serves them on OpenAI Chat Completions and Anthropic Messages. Add the key to packinggoods once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use any OpenRouter model through packinggoods’s gateway at 127.0.0.1:3425, each agent on a model of its own.
Add OpenRouter
- Get a keyMake one on openrouter.ai/keys.
- Add the providerIn packinggoods’s Providers tab, press + Add provider, pick OpenRouter, paste the key and save. packinggoods asks OpenRouter which models it serves.
- Pick it for an agentIn the Agents tab, click the model on the agent’s row and choose an OpenRouter model such as
anthropic/claude-opus-5.5.
packinggoods provider add openrouter sk-… packinggoods provider test openrouter
Model ids in packinggoods are provider/model, so OpenRouter’s read openrouter/anthropic/claude-opus-5.5: the provider, then OpenRouter’s own id. The key is kept in packinggoods’s settings; packinggoods doesn’t take it from your shell.
OpenRouter documents two optional headers that credit an app in its rankings, HTTP-Referer and X-OpenRouter-Title. packinggoods doesn’t send them. The provider editor’s Headers field offers them if you want your requests credited.
Endpoints
| API | Base URL | Used for |
|---|---|---|
| Chat Completions | https://openrouter.ai/api/v1 | the model list, requests to non-Claude models, image models |
| Anthropic Messages | https://openrouter.ai/api | Claude Code’s requests, and Claude models from any agent |
| Decisions | https://openrouter.ai/api/v1 | decision models for intent routing |
packinggoods doesn’t use OpenRouter’s Responses API. An agent that speaks Responses, such as Codex, is translated to one of the two above.
Model list
- Where it comes from. packinggoods fetches the list from
https://openrouter.ai/api/v1/models, which gives each model’s context length. Names, reasoning levels and prices come from theopenroutercatalog on models.dev. - Which models agents see. OpenRouter lists hundreds. Unless you pick some, packinggoods shows agents the first 24 OpenRouter lists, newest first. Pick the rest in the provider’s model list, or turn on Best in family to keep only the newest of each family.
- New models.
auto-includerules expose matching models now and each one a later fetch lists for the first time, andrefresh-everyhas packinggoods fetch the list again by itself. - Image models. OpenRouter’s
/modelslists text models only, so packinggoods reads image models such as FLUX, Seedream, Riverflow, Recraft and GPT Image, and their free variants, from/api/v1/models?output_modalities=image. Choose one in Settings → Models → Images. - Decision models. OpenRouter’s decision models (
liquid/d1,cloudflare/clef,~typesafe/jev-latest…) are listed too, so a routing group can classify turns with the same key.
packinggoods provider models openrouter +anthropic/claude-opus-5.5 # expose one more packinggoods provider models openrouter best # newest of each family packinggoods provider auto-include openrouter '*:free' # every free model, now and later packinggoods provider refresh-every openrouter 1d
In each agent
Pick the model on an agent’s row in the Agents tab, or from a terminal. Each guide says what packinggoods writes in that agent’s config and how to switch back.
packinggoods claude openrouter/anthropic/claude-opus-5.5 packinggoods codex openrouter/anthropic/claude-opus-5.5 packinggoods gemini model openrouter/google/gemini-3-pro packinggoods opencode openrouter/anthropic/claude-opus-5.5
- Claude Code speaks Anthropic Messages, and so does OpenRouter at
https://openrouter.ai/api, so its requests are passed on as they are. Models in Claude Code. - Codex speaks only OpenAI Responses. packinggoods translates each request and the reply, streaming and tool calls included: a Claude model goes to OpenRouter’s Anthropic endpoint, every other model to Chat Completions. Models in Codex.
- Gemini CLI speaks Gemini’s API. packinggoods translates it the same way as Codex’s requests. Models in Gemini CLI.
- OpenCode speaks Chat Completions, so its requests go to OpenRouter as they are, except for Claude models, which packinggoods sends to the Anthropic endpoint for their prompt cache (see below). Models in OpenCode.
If OpenRouter says a model isn’t served on the endpoint packinggoods chose, packinggoods builds the request again for the other one and remembers that for the model.
Reasoning
- Models that always reason. Some OpenRouter models refuse to have reasoning turned off (“reasoning is mandatory for this endpoint and cannot be disabled”). When an agent asks for it off, packinggoods asks again with the level left to the model, on Chat Completions and on Messages alike.
- Effort mid-conversation. Claude Code sends a turn’s effort inside the conversation. OpenRouter’s Anthropic endpoint refuses that on some models, such as DeepSeek and GLM. packinggoods asks again at once without it, and doesn’t send it to OpenRouter again until packinggoods restarts.
- Earlier thinking. OpenRouter’s Anthropic endpoint turns away a thinking block without a signature, so packinggoods always sends one. On Chat Completions, earlier reasoning that an agent sends back in OpenRouter’s
reasoningorreasoning_detailsfields is read as the model’s thinking.
Cache, cost and credits
- Claude’s prompt cache. On Chat Completions, a relay that serves both APIs drops
cache_control, and every turn is billed uncached. So packinggoods asks Claude models on OpenRouter’s Messages endpoint, from any agent, with the cache breakpoints the translation adds. - Cache tokens. packinggoods reads cache reads and OpenRouter’s
cache_write_tokensfrom each reply, so the Usage tab counts cache hits and writes apart from the rest. - Cost. The Usage tab prices each call with OpenRouter’s prices from models.dev, or the model maker’s list price when the catalog has none. A model listed at $0, such as one ending in
:free, shows free beside it in packinggoods’s pickers. - Which provider answered. OpenRouter names the provider that served each reply. packinggoods keeps it, and the call’s details in the Usage tab show it as Upstream provider.
- Credits. The OpenRouter row shows what is left on the account, in dollars: total credits less total usage, read from
/api/v1/credits. It’s the whole account’s figure, so each key of one account shows the same.
Several keys and free models
One OpenRouter provider can hold several keys: press Add another key under it, or paste several at once. Requests go to the first key that’s on, and when it runs out or is rate limited the next one takes over. The provider’s routing can also rotate, weight or drain them instead. Adding the preset again makes a second OpenRouter provider; to spread requests over several keys, add them all to the one provider.
- Spend caps.
spend-capstops a key at a dollar amount a day, a month or in all, as the Usage tab prices its calls; routing then goes on to the other keys and the fallbacks. - Fallbacks.
fallbacknames where requests go when OpenRouter is out of quota or down: another provider’s model or a routing group. - Free models. OpenRouter’s free models take 20 requests a minute.
rpmholds each key to a rate: one request more waits for room, up to 2 minutes, then gets a 429 with aRetry-After. - Free-model 429s. When a free model is refused by the shared pool of the provider serving it, packinggoods rests that model only and keeps the other free models in use. Any other 429 on a free model is OpenRouter’s account-wide free limit, and the key rests.
- A pool of free models. A routing group can take every free model OpenRouter lists with the pattern
openrouter/*:free, today’s and those it lists later.
packinggoods provider rpm openrouter 20 packinggoods provider spend-cap openrouter <key> 20 month packinggoods provider fallback openrouter deepseek/deepseek-v4-pro packinggoods group add my-free-pool models='openrouter/*:free' routing=order packinggoods group set opus-anywhere stays=session models+=openrouter/anthropic/claude-opus-5.5
Troubleshooting
- The model list has only
anthropic/ids, or fails to load. A provider given onlyhttps://openrouter.ai/apigets OpenRouter’s catalog underanthropic/names it doesn’t serve. Give it the Chat Completions base,https://openrouter.ai/api/v1, or use the OpenRouter preset, which has both. - “Mid-conversation reasoning effort (configuration_update) is not supported”. OpenRouter says this about Claude Code’s per-turn effort on models such as DeepSeek and GLM. packinggoods asks again at once without the effort, so the agent gets its answer, and stops sending it to OpenRouter until packinggoods restarts.
- 402 with “can only afford” or “fewer max_tokens”. OpenRouter refused the request’s size or its in-flight budget, not because the balance is spent. packinggoods rests the key for half an hour and tries it again then; unlike a key out of credit, its rest doesn’t grow with each refusal.
- Web search asks a model you didn’t pick. It doesn’t: when OpenRouter answers packinggoods’s web search, packinggoods asks one of the OpenRouter models you have picked, since OpenRouter can refuse others for your region. For that search packinggoods turns on OpenRouter’s own
webplugin, which works with any of its models. - Checking a key.
packinggoods provider test openroutersends a tiny request through each endpoint, or to each model you name. Add--as codexor--as claude-codeto send it the way that agent would.
Vercel AI Gateway in Claude Code, Codex and other agents
API relays in Claude Code, Codex and other agents
FAQ
How do I use OpenRouter in Claude Code?
Add your OpenRouter key in packinggoods (Providers, Add provider, OpenRouter), then pick a model such as anthropic/claude-opus-5.5 on Claude Code’s row, or run packinggoods claude openrouter/anthropic/claude-opus-5.5. packinggoods writes Claude Code’s settings.json and passes its requests on to OpenRouter’s Anthropic endpoint as they are.
Can Codex use OpenRouter models?
Yes. Codex speaks only the Responses API, which packinggoods doesn’t use at OpenRouter. packinggoods translates each Codex request: a Claude model goes to OpenRouter’s Anthropic endpoint and every other model to Chat Completions, and the reply comes back to Codex as Responses.
Can Gemini CLI and OpenCode use OpenRouter?
Yes. Gemini CLI’s requests are translated the same way as Codex’s. OpenCode speaks Chat Completions, so its requests go to OpenRouter as they are, except for Claude models, which packinggoods sends to the Anthropic endpoint so the prompt cache works.
How do I use only OpenRouter’s free models?
Make a routing group from the pattern openrouter/*:free, for example packinggoods group add my-free-pool models='openrouter/*:free' routing=order. It takes every free model OpenRouter lists, including ones it lists later. Models priced at $0 show free in packinggoods’s pickers.
Why do OpenRouter’s free models answer 429?
OpenRouter’s free models take 20 requests a minute. Set packinggoods provider rpm openrouter 20 and packinggoods holds requests back to that rate. When the 429 comes from the shared pool of the provider serving one free model, packinggoods rests only that model and keeps the other free models in use.
Does packinggoods show my OpenRouter credits?
Yes. packinggoods reads OpenRouter’s credits endpoint and shows what is left in dollars: total credits less total usage. The figure is for the whole account, so every key of one account shows the same.
Why does packinggoods fetch OpenRouter’s model list from /api/v1?
Asked at the Anthropic base, OpenRouter answers with its catalog under anthropic/ names it doesn’t serve. packinggoods fetches the list from the Chat Completions base, https://openrouter.ai/api/v1, and a provider given only OpenRouter’s Anthropic base is told to add that Chat base.
By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Volcengine Ark · Tencent Cloud · Baidu Qianfan · SiliconFlow · ModelScope · Huawei Cloud MaaS · Xiaomi MiMo · StepFun · LongCat · Qwen · MiniMax · Anthropic · OpenAI · Gemini · Grok · Mistral · GitHub Copilot · Ollama
Every agent: Models in Claude Code, Models in Codex, Models in Gemini CLI, Models in OpenCode. Ask on Discord if you get stuck.