Configuration
Reference for the AnyRouter CLI config file, project anyrouter.yaml, profile fields, per-tool overrides, flags and management commands.
How the CLI is configured: the global config file, an optional per-project anyrouter.yaml, profile fields, per-tool overrides, flags and management commands. One stored key drives every tool.
Add $schema: https://anyrouter.dev/cli/schema.json at the top of a config file for autocomplete and validation in editors that understand JSON Schema.
Config file
Profiles and tool settings live in ~/.anyrouter/config.yaml. A profile from an older CLI at ~/.config/anyrouter/config.yaml is migrated on first run. The schema is at https://anyrouter.dev/cli/schema.json.
$schema: https://anyrouter.dev/cli/schema.json
active_profile: default
profiles:
default:
base_url: https://anyrouter.dev/api
pinned_preset: "@preset/coding-stack"
default_model: auto
timeout_ms: 3000000
work:
base_url: https://anyrouter.dev/api
default_model: "anthropic/claude-sonnet-4-6"
timeout_ms: 600000
tools:
claude:
command: claude
base_url_env: ANTHROPIC_BASE_URL
auth_env: ANTHROPIC_AUTH_TOKEN
model_env: ANTHROPIC_MODEL
codex:
command: codex
base_url_env: OPENAI_BASE_URL
auth_env: OPENAI_API_KEY
model_env: OPENAI_MODELSwitch profiles with --profile <name> or anyr config use <name>.
Profile fields
| Field | Type | Description |
|---|---|---|
base_url | string | AnyRouter API base URL. Default: https://anyrouter.dev/api. |
pinned_preset | string | Default preset slug (e.g. @preset/coding-stack). Used when default_model is auto. |
default_model | string | Default model id, or auto to let the pinned preset choose. Set by the post-login selector session. |
default_effort | string | Optional reasoning effort for models that declare catalog levels. Omitted when skipped. |
provider_connections | string | Comma-separated catalog owner ids from the selector session. Re-login merges this set. |
public_alias | string | Local public model alias (slug of the selected model id, max 30). |
identity | string | Gateway identity id. Default default. |
default_tool | string | Preferred coding agent id from the post-login wizard (e.g. claude, codex, grok). |
timeout_ms | number | Request timeout in milliseconds. Default: 3000000 (50 minutes). |
Per-tool overrides
tools overrides the command and environment variable names for each tool, for a custom wrapper or renamed executable.
| Field | Description |
|---|---|
command | Executable to run (resolved from $PATH). |
base_url_env | Environment variable the tool reads for the API base URL. |
auth_env | Environment variable the tool reads for the API key or token. |
model_env | Environment variable the tool reads for the model name. |
Project anyrouter.yaml
Put an anyrouter.yaml in your repo root (or a parent directory). The CLI uses the nearest one walking up from the current directory, and its values override the global config.
# yaml-language-server: $schema=https://anyrouter.dev/cli/schema.json
model: auto
preset: coding-stack
effort: high
tool: claude| Field | Description |
|---|---|
model | Default model id, or auto to use the pinned preset. |
preset | Preset slug (e.g. coding-stack or @preset/coding-stack). |
effort | Reasoning depth: low, medium, high, xhigh, or max. |
tool | Default launcher when none is specified: claude, codex, or grok. |
claude / codex / grok | Per-tool overrides for model, preset, effort, or base URL. |
CLI flags
Flags go before any --; everything after -- is forwarded verbatim to the tool.
anyr claude --model auto --effort high -- --resume| Flag | Meaning |
|---|---|
--model auto|<id> | Session model. auto picks the best model from your pinned preset. |
--effort low|medium|high|xhigh|max | Reasoning depth, mapped to each tool's native control. |
--profile <name> | Use a named profile. |
--key sk-ar-... | Provide a key non-interactively (first run or CI). |
--device / --device-code | Force the device code flow (headless / SSH). |
--paste | Prompt to paste an sk-ar- key. |
--yes | Skip interactive prompts (including the post-login selector session). |
--command-path <path> | Explicit path to the agent executable. |
--dry-run | Print the resolved command and environment (secrets redacted). Run nothing. |
--config <path> | Use a different config file. |
--plaintext | Accepted for compatibility. Keys are always stored in config.yaml. |
The key is written to config.yaml, readable only by you (mode 600).
Management commands
anyr auth login # sign in (browser first, device code fallback)
anyr setup # save a local profile (same auto sign-in)
anyr whoami # name, email, account, masked key, default model, config path
anyr account list # multiple accounts (* = active)
anyr config get # show the active config (secrets redacted)
anyr config path # print the config file location
anyr config use work # switch to the "work" profile
anyr models # list model ids for --model (--free, --type, --sort; `models show <id>`)
anyr --help # everyday commands
anyr help --all # every command, grouped
anyr <command> --help # flags and examples for one command
anyr commands --json # full command tree for scripts and agentsCI and non-interactive use
Without a TTY the CLI skips prompts. Supply a key by flag or environment variable:
anyr claude --key sk-ar-your-key "Review this PR"
ANYROUTER_API_KEY=sk-ar-your-key anyr models --jsonmodels lists the public catalog and needs no login or config file. --key and ANYROUTER_API_KEY work the same on login, usage and logs. Every command accepts --json (or ANYR_OUTPUT=json), reports errors as JSON and uses fixed exit codes: see Use anyr from scripts and AI agents.
Verify
anyr config get prints the active config (secrets redacted), anyr config path shows which file is in effect (a project anyrouter.yaml may override the global one), and anyr claude --dry-run prints the resolved command, model and environment without sending anything.
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