Claude CodeCoding agents
Run Claude Code through AnyRouter
Install 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.
Set it up
anyr CLI
$ curl -fsSL https://anyrouter.dev/cli.sh | bash$ anyr loginSigned in. via browser key sk-ar-v1-7f3c2…9a1dSaved /Users/you/.anyrouter/config.yamlNext anyr claude$ anyr claude --dry-runcommand: claudeargs: []env:ANTHROPIC_API_KEY=sk-ar-...9a1dANTHROPIC_AUTH_TOKEN=sk-ar-...9a1dANTHROPIC_BASE_URL=https://anyrouter.dev/apiANTHROPIC_DEFAULT_FABLE_MODEL=anyrouter/freeANTHROPIC_DEFAULT_FABLE_MODEL_DESCRIPTION=Fable alias + fallbackANTHROPIC_DEFAULT_HAIKU_MODEL=anyrouter/freeANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION=Background & subagentsANTHROPIC_DEFAULT_OPUS_MODEL=anyrouter/freeANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION=Opus aliasANTHROPIC_DEFAULT_SONNET_MODEL=anyrouter/freeANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION=Sonnet aliasANTHROPIC_MODEL=anyrouter/freeANYROUTER_MODEL_MODE=concreteANYROUTER_PINNED_PRESET=@preset/coding-stackANYR_LAUNCHER_CHILD=1API_TIMEOUT_MS=3000000CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=0CLAUDE_CODE_SUBAGENT_MODEL=anyrouter/freemcp: not checked (--dry-run does not ask the gateway; a launch connects it when the workspace has auto-connect on)$ anyr claude
- 1.Install the anyr CLI with the curl | bash one-liner (native binary, no npm).
- 2.Run anyr claude. First run signs you in or pastes an sk-ar- key; later runs reuse ~/.anyrouter/config.yaml.
- 3.Pin a catalog model when you want one (anyr claude --model anyrouter/auto). Env vars remain the manual fallback.
Why use this
Claude Code talks to Anthropic by default. To use other models, share billing across tools, or keep an audit log, you need a custom base URL without rewriting how the CLI works.
How the request flows
Claude Code
AnyRouterone URL
Your modelany model
Other ways to set it up
Env wrapper
export ANTHROPIC_BASE_URL="https://anyrouter.dev/api"
export ANTHROPIC_API_KEY="$ANYROUTER_API_KEY"
claudeEndpoints and key
- OpenAI-compatible
- https://anyrouter.dev/api/v1
- Anthropic-compatible
- https://anyrouter.dev/api
- Key
- ANYROUTER_API_KEY (sk-ar-…)