Accounts and keys in the CLI
Use several AnyRouter accounts, give each coding agent its own key, and manage API keys from the terminal.
The CLI supports any number of accounts (work, personal, a self-hosted gateway), each with its own key, base URL and defaults, and can list, create, update and revoke API keys.
Multiple accounts
anyr account list # * marks the active account
anyr account add work # sign in to a second account
anyr account use work # switch
anyr account rename work team
anyr account remove team # not the active account; also deletes its stored keysAccounts live in ~/.anyrouter/config.yaml. To pick one, strongest first: --profile <name> on a command, ANYROUTER_PROFILE=<name> in the environment, then the persistent default from anyr account use.
One key per coding agent
Separate keys keep each agent's spend, limits and revocation apart. These commands arrive in the first anyr release after 0.1.37 (anyr upgrade).
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 copied from the dashboard
anyr account use work --agent opencode # OpenCode launches with the work account
anyr auth status # the key each agent launches with--agent takes any launched agent: claude, codex, opencode, grok, pi, qwen, goose, aider, crush, kilo, pool, fx.
A launch picks its key in this order:
--key, thenANYROUTER_API_KEY.- The agent's own key (
keys create --agentorkeys set --agent). --profileorANYROUTER_PROFILE.- The agent's account (
account use <name> --agent). - The active account.
keys create --agentmints the key in that agent's account, prints it once and saves it. The scope flags (--limit,--reset,--endpoints,--expires) work as usual;--quietstill saves it and prints only the secret. It refuses while--keyorANYROUTER_API_KEYis set.keys set --agent <agent> -reads the key from stdin (an argument is refused, so it stays out of shell history). Only a wholesk-ar-v1-key is accepted.anyr keys unset --agent codexremoves the agent's own key. The key keeps working until you revoke it; the CLI prints theanyr keys revokecommand.anyr account use --agent opencode --clearremoves an account binding. Renaming an account keeps its bindings; removing it unbinds them.
Who am I, and signing out
anyr whoami # or: anyr status; --json for scripts
anyr logout # active account
anyr logout --profile work # a specific accountwhoami shows name, email, active account, a masked key hint, default model and config path, plus the masked key and source for each agent with its own key or account (agents in --json). Full secrets are never printed. logout removes the account's key from config.yaml; anyr auth login restores it.
Managing API keys
anyr keys list # * marks the key this machine uses
anyr keys create laptop # named key (default: cli-<hostname>)
anyr keys show <hash> # limit, spent, endpoints, expiry
anyr keys update <hash> --limit 50 --disable # --enable turns it back on
anyr keys revoke <last4|id|hash> # asks first; --yes in scripts- CLI login mints (or reuses) a key with Key Management permission, so
anyr keysworks right afteranyr auth login. If a dashboard key has Key Management off, enable it or log in again. keys createprints the key once. In a terminal the CLI offers to store it for the current account.- An existing key's secret cannot be fetched again. To switch keys, run
anyr login, oranyr login --key -to paste one from the dashboard. keys revokewarns when you revoke the key the account is using.
Scoped keys for CI
anyr keys create ci-bot --limit 25 --reset monthly --endpoints chat,embeddings --expires 30d
KEY=$(anyr keys create ci-bot --limit 5 --quiet) # prints only the secret; not saved--limit: spend cap in USD.--reset: window (daily,weekly,monthly).--expires:30d,12h,45mor2w.--endpoints:chat,embeddings,moderations,rerank,documents,speech,decisions,mcp,me,relay,models,keys,credits,logs,dashboard,trace. Chat, messages and responses share one permission, sochatcovers all three.--quietprints only the secret on stdout, safe to capture.
Check and script
anyr claude --dry-run # command and environment a launch would use (secrets redacted; works on every launcher)
ANYROUTER_PROFILE=ci anyr whoami --json | jq -r .base_url
anyr keys list --json | jq -r '.[] | select(.current) | .name'account list is line-per-account text; whoami --json and keys list --json emit masked values and presence flags only, never secrets.
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer