Skip to content

Configuration

Reference for the AnyRouter CLI — the config file, project-level anyrouter.yaml, profile fields, per-tool overrides, every CLI flag, and the management commands.

Reference for how the AnyRouter CLI is configured: the global config file, an optional per-project anyrouter.yaml, all profile fields, per-tool overrides, every CLI flag, and the management commands. One stored key drives every tool.

Add $schema: https://anyrouter.dev/cli/schema.json to the top of any config file for autocomplete and inline validation in VS Code, WebStorm, and any editor that understands JSON Schema.

Config file

The CLI stores your profile(s) and tool settings in ~/.anyrouter/config.yaml. A profile from an older CLI at ~/.config/anyrouter/config.yaml is migrated forward automatically on first run.

$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
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

The full schema is published at https://anyrouter.dev/cli/schema.json.

Profile fields

Each entry under profiles: accepts:

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). Launch with anyr <tool> as usual.
timeout_msnumberRequest timeout in milliseconds. Default: 3000000 (50 minutes).

Per-tool overrides

The tools section overrides the command name and environment variable names for each supported tool — useful if you have 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-level anyrouter.yaml

Drop an anyrouter.yaml in your repo root (or any parent directory) to pin defaults for that project. The CLI walks up from your current directory to find the nearest one, and its values override your global ~/.anyrouter/config.yaml when you launch from inside the tree.

# 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 underlying tool.

anyr claude --model auto --effort high -- --resume
anyr codex --model "anthropic/claude-sonnet-4.6" --effort xhigh
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.
--hub <slug>Load a Skills & Knowledge Hub for this session (Claude Code).
--profile <name>Use a named profile from your config.
--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 (skip auto browser / device detection).
--yesSkip interactive prompts (including the post-login selector session on login).
--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.
--plaintextStore the key in config.yaml instead of the OS keychain.

On macOS the key is stored in the system keychain by default; elsewhere it 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           # active account + masked credentials
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 catalog model ids for --model
anyr skills sync      # sync your Skills & Knowledge Hub locally

Multiple profiles

Add named profiles under profiles: and switch between them with --profile or config use:

$schema: https://anyrouter.dev/cli/schema.json
active_profile: default
profiles:
  default:
    base_url: https://anyrouter.dev/api
    default_model: auto
    pinned_preset: "@preset/coding-stack"
    timeout_ms: 3000000
  work:
    base_url: https://anyrouter.dev/api
    default_model: "anthropic/claude-sonnet-4.6"
    timeout_ms: 600000

Non-interactive / CI environments

When there is no TTY (CI, scripts, Docker), the CLI skips the interactive prompt. Supply a key via flag or environment variable:

# Flag
anyr claude --key sk-ar-your-key "Review this PR"

# Environment variable
ANYROUTER_API_KEY=sk-ar-your-key anyr claude "Review this PR"

# Catalog listing — no saved profile required
anyr models --key sk-ar-your-key
ANYROUTER_API_KEY=sk-ar-your-key anyr models --json

models lists the public catalog and does not require a prior login or ~/.anyrouter/config.yaml. --key and ANYROUTER_API_KEY are accepted the same way as on login, usage, and logs.

Verify

Check that your config resolves as expected before sending a real request:

  • anyr config get prints the active config with secrets redacted.
  • anyr config path prints which config file is in effect (useful when a project anyrouter.yaml overrides the global file).
  • anyr claude --dry-run prints the resolved command, model, and environment — nothing is sent.