Login with AnyRouter
Sign in to the AnyRouter CLI with browser login, device code on SSH, or a key, and see where credentials are stored.
The CLI signs you in once, stores a key locally and reuses it on every run. anyr login is an alias of anyr auth login.
curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr auth login # or just run a launcher: anyr claude, anyr chat- Browser (default): the CLI opens anyrouter.dev, you sign in and approve, and the key returns over a local callback. Only a masked
sk-ar-v1-…hint is shown, never the full secret. - Device code (SSH, CI, display-less Linux, or a failed browser): the CLI prints a code and URL. Open the URL on any signed-in device, enter the code and approve. Codes are single-use and expire after a few minutes.
- The key is saved to
~/.anyrouter/config.yaml(mode600) and reused by every launcher. An older~/.config/anyrouter/config.yamlis migrated on first run.
After an interactive login, a selector session can set connected providers (merged with stored ones), a default model (auto keeps smart routing), reasoning effort, public alias and identity, and a default coding agent. Values go to config.yaml; pass --yes to skip the prompts. Provider keys are not collected here; use anyr byok add.
Flags
| Flag | When to use |
|---|---|
--key sk-ar-v1-... | Non-interactive, or you already have a key. Also ANYROUTER_API_KEY. |
--device / --device-code | Force the device code flow. |
--paste | Paste an sk-ar- key from Dashboard → Keys. |
--plaintext | Accepted for compatibility. Keys are always stored in config.yaml. |
--yes | Skip the selector session and coding-agent prompts. |
anyr auth login --device
ANYROUTER_API_KEY=sk-ar-v1-your-key anyr claude --yes # CI, no TTYWithout a TTY the CLI never prompts: pass --key, set ANYROUTER_API_KEY, or use --device.
What the key can do
The login key has the same capabilities as a dashboard key, including Key Management and Credits endpoints (unrestricted allowed_endpoints). It appears under API Keys and can be revoked there at any time; the CLI then asks you to sign in again. anyr keys uses this same key, with no separate management credential. A pasted dashboard key with Key Management off gets 403 from anyr keys until you re-run anyr auth login or enable it.
anyr usage prints remaining credits, today's spend and lifetime used, with the last cached snapshot if refresh fails (details).
Troubleshooting
| Symptom | Fix |
|---|---|
| Browser did not open or timed out | Over SSH or without a display the CLI falls back to device code. Force it with anyr auth login --device. |
| Key rejected (HTTP 401) | Use the full sk-ar-v1-… key. Create a new one in Dashboard → Keys, then anyr auth login --key sk-ar-v1-... or --paste. A 403 from credits (such as a WAF challenge) is not a rejected key. |
| Re-run the selector session | Run anyr auth login again, or edit provider_connections, default_model, default_effort, default_tool in config.yaml. |
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