Why one key per agent
One AnyRouter key can drive every coding agent. That is the easy setup, but it pools everything. All agents share one spend limit and one line of usage, and revoking the key signs every agent out.
With a key per agent, each agent gets its own limit, its own usage, and its own revocation. If one agent runs away, it stops at its own limit. If you rotate one key, the other agents keep working.
Give each agent its own key or account
anyr keys create --agent claude --limit 20 # mint a key for Claude Code and save it for it
pbpaste | anyr keys set --agent codex - # store a key you copied from the dashboard
anyr account use work --agent opencode # OpenCode launches with the work account
anyr auth status # the key each agent launches withkeys create --agent mints the key in the account that agent uses, prints it once, and saves it for that agent. The usual scope flags work, so --limit, --reset, --endpoints and --expires set the agent's cap and lifetime.
keys set --agent <agent> - reads a key from stdin. A key typed as an argument is refused, so it stays out of your shell history. account use <name> --agent binds a whole account instead of one key.
--agent takes any agent the CLI launches, including claude, codex, opencode, grok and pi.
See which key each agent uses
anyr auth status (or anyr whoami) adds one line per agent that has its own key or account. Each line shows the masked key and where it comes from:
claude sk-ar-v1-k7m2p…9xq4 · agent key
codex sk-ar-v1-r3c8w…2hd7 · agent key
opencode sk-ar-v1-a9t5n…6vbe · agent account workThe view uses the same lookup as a launch. When ANYROUTER_API_KEY is set, every line says so, because that variable overrides every agent's key. --json returns the same rows in agents. Full keys are never printed.
Undo it
anyr keys unset --agent codex # codex goes back to its account
anyr account use --agent opencode --clear # opencode uses the active accountA removed key keeps working until you revoke it, so keys unset prints the anyr keys revoke command for it. Renaming an account keeps its agents bound, and removing an account unbinds them.
Try it
These commands ship in the next anyr release. Run anyr upgrade to get it.
Docs: accounts and keys.
Related posts
CLI update: multiple accounts, terminal key management, and agents that delegate
The AnyRouter CLI now handles several accounts side by side, manages API keys without the dashboard, runs plan-then-implement pipelines across two models, and lets coding agents hand tasks to each other — one hop, one key.
Run coding agents through one gateway
Point Claude Code, Codex, OpenCode, Cursor, or any OpenAI-compatible tool at AnyRouter and get one key for every model, unified billing, per-request audit logs, and app attribution. Two environment variables — or one npx command with the anyr CLI launcher.
Run Claude Code on AnyRouter — wrapper script or CLI
Route Claude Code through AnyRouter in two ways: a wrapper that installs itself and maps Opus, Sonnet, and Haiku to one catalog model (override with --model), or the anyr CLI launcher. One key, unified billing, audit logs.
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