Why route coding agents through a gateway?
Claude Code, Codex, OpenCode, Cursor, and their cousins all let you override the base URL and key. Point them at AnyRouter and every request from every tool lands on one account: one key for every model, one balance, one audit log with cost, latency, and token counts per request — and the freedom to pick a different model per tool without touching provider SDKs.
Two things make this clean. Claude Code speaks the Anthropic dialect (/messages), Codex and Cursor speak the OpenAI dialect (/chat/completions), and AnyRouter serves both from the same endpoint. And app attribution headers let each tool show up separately in your usage analytics.
How do I point Claude Code at a custom base URL?
Claude Code reads two environment variables. Set them to AnyRouter and every request routes through your account:
export ANTHROPIC_BASE_URL="https://anyrouter.dev/api"
export ANTHROPIC_API_KEY="sk-ar-your-anyrouter-key"
claudeCodex and any OpenAI-compatible tool read the OpenAI pair instead:
export OPENAI_BASE_URL="https://anyrouter.dev/api/v1"
export OPENAI_API_KEY="sk-ar-your-anyrouter-key"
codex "Refactor this function to use async/await"For Cursor, paste the same base URL (https://anyrouter.dev/api/v1) and an sk-ar- key into its OpenAI-compatible custom-model settings — no other change needed.
The anyr CLI launcher does it for you
If you'd rather not manage environment variables, the anyr launcher handles login, key storage, and the environment in one command — and the same stored key powers every launcher:
# Install the native CLI (no Node required)
curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr login
# Launch Claude Code through AnyRouter
anyr claude
# Same for Codex and OpenCode — reuses the stored key
anyr codex
anyr opencode
# Pin a model, set reasoning depth, or preview the env
anyr claude --model "z-ai/glm-5.2"
anyr opencode --model "anthropic/claude-sonnet-4.6"
anyr claude --dry-runConfig is saved to ~/.anyrouter/config.yaml and reused next time. Everything after -- forwards to the underlying tool verbatim (e.g. anyr claude -- --resume).
Attribute each tool's usage
Send app-attribution headers and each tool earns its own row in your analytics and the public rankings. HTTP-Referer is the primary identifier; the optional X-AnyRouter-* headers set the display name, platform, version, and marketplace category (coding tools fit cli-agent or ide-extension).
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer sk-ar-your-key" \
-H "HTTP-Referer: https://myagent.dev" \
-H "X-AnyRouter-Title: My Coding Agent" \
-H "X-AnyRouter-Source: cli" \
-H "X-AnyRouter-Categories: cli-agent" \
-H "Content-Type: application/json" \
-d '{ "model": "anthropic/claude-opus-4-8", "messages": [{"role":"user","content":"hi"}] }'Full setup guides live at /cli and /docs. To route on keys you already pay for, pair this with BYOK — /blog/byok-bring-your-own-keys.
One key for Claude Code, Codex, OpenCode, and Cursor — unified billing and audit logs.
Set up the CLIRelated posts
Use OpenCode with AnyRouter — CLI launcher or opencode.json
Point the OpenCode coding agent at AnyRouter in one command, or add a custom Chat Completions provider in opencode.json. One sk-ar- key reaches every catalog model, with unified billing and request logs.
Point Claude Code at a custom base URL
Claude Code reads ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY, so pointing it at AnyRouter takes two environment variables — no plugin, no fork. You get every model in the catalog behind the same key, automatic failover when a provider is rate-limited, and one audit log shared with Codex, Cursor, and every other agent you run.
Route your first request in 2 minutes
Start free with your own keys, or top up and pay per token. Get $4/mo in credits and free models on Go — $2/mo, or free when you donate a provider key.
Start free