All use cases
One gateway
Run every coding agent through one URL
Claude Code, Codex, OpenCode, Cursor, and other OpenAI-compatible tools share 271+ models, one balance, and one request log.
What this is for
Each coding agent wants its own provider key and base URL. Switching models or comparing cost means editing every tool separately.
Steps, then copy
- 1.Mint one AnyRouter key.
- 2.Set Anthropic env vars for Claude Code, and OpenAI env vars for Codex, Cursor, and similar tools.
- 3.Start on anyrouter/auto so failover picks a model that is answering.
Claude Code
bash
export ANTHROPIC_BASE_URL="https://anyrouter.dev/api"
export ANTHROPIC_API_KEY="$ANYROUTER_API_KEY"Codex / Cursor
bash
export OPENAI_BASE_URL="https://anyrouter.dev/api/v1"
export OPENAI_API_KEY="$ANYROUTER_API_KEY"OpenCode
bash
anyr opencodeReady to try it
The guide has the full walkthrough. Sign up if you still need a key.
Next playbooks
- Run Claude Code through AnyRouterInstall the anyr CLI, then anyr claude — it injects the base URL, key, and model. Env vars are the fallback if you already run claude yourself.
- Grok Bot + Herdr + Anyr CLI coding loopA live coding agent on a repo checkout: Grok Bot assigns the goal, Herdr shows the box, and the anyr CLI launches Claude Code through AnyRouter.
- Run OpenCode through AnyRouterOne CLI command injects an AnyRouter provider for the session, or add a custom provider in opencode.json — one key, the Chat Completions catalog, and request logs.