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_MODEL

Switch profiles with --profile <name> or anyr config use <name>.

Profile fields

FieldTypeDescription
base_urlstringAnyRouter API base URL. Default: https://anyrouter.dev/api.
pinned_presetstringDefault preset slug (e.g. @preset/coding-stack). Used when default_model is auto.
default_modelstringDefault model id, or auto to let the pinned preset choose. Set by the post-login selector session.
default_effortstringOptional reasoning effort for models that declare catalog levels. Omitted when skipped.
provider_connectionsstringComma-separated catalog owner ids from the selector session. Re-login merges this set.
public_aliasstringLocal public model alias (slug of the selected model id, max 30).
identitystringGateway identity id. Default default.
default_toolstringPreferred coding agent id from the post-login wizard (e.g. claude, codex, grok).
timeout_msnumberRequest 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.

FieldDescription
commandExecutable to run (resolved from $PATH).
base_url_envEnvironment variable the tool reads for the API base URL.
auth_envEnvironment variable the tool reads for the API key or token.
model_envEnvironment 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
FieldDescription
modelDefault model id, or auto to use the pinned preset.
presetPreset slug (e.g. coding-stack or @preset/coding-stack).
effortReasoning depth: low, medium, high, xhigh, or max.
toolDefault launcher when none is specified: claude, codex, or grok.
claude / codex / grokPer-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
FlagMeaning
--model auto|<id>Session model. auto picks the best model from your pinned preset.
--effort low|medium|high|xhigh|maxReasoning 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-codeForce the device code flow (headless / SSH).
--pastePrompt to paste an sk-ar- key.
--yesSkip interactive prompts (including the post-login selector session).
--command-path <path>Explicit path to the agent executable.
--dry-runPrint the resolved command and environment (secrets redacted). Run nothing.
--config <path>Use a different config file.
--plaintextAccepted 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 agents

CI 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 --json

models 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