settings.json. Claude Code keeps speaking the Anthropic Messages API and you keep choosing models with /model; the gateway maps whatever it sends to the target model your cohort resolves to. See Set up ValarCode for the shared setup and the client-id model.
Prerequisites
- Claude Code installed, with a
~/.claudeconfig directory. - A Valar coding key (
vlrcode_…) and thevalarCLI (install).
Enable routing
Run once per machine:This routes the Claude Code CLI only. The Claude Desktop app is a separate harness — see Claude Desktop.
settings.json env additions, so on takes effect on the next request without a restart. Check the state any time:
/rc), the Chrome extension and claude.ai MCP connectors, which only run on a first-party login. --remote keeps them working:
claude() wrapper to your shell config. valar asks before editing that file — pass -y to answer ahead of time, since a non-interactive run declines rather than edit it. Open a new terminal afterwards. valar claude off stops the proxy and removes the wrapper.
valar detects your shell; --shell overrides it. zsh, bash, fish and POSIX shells (sh, dash, ksh) are supported; tcsh, csh, nushell and PowerShell cannot be served.
What gets written
valar claude on edits the env block of ~/.claude/settings.json. It points the base URL and auth token at Valar, carries the client id in a custom header, and removes anything that would override the gateway’s server-side routing:
- Sets
ANTHROPIC_BASE_URLto Valar. Claude Code appends/v1/messages, so the host is written without a/v1suffix. - Writes the bare coding key to
ANTHROPIC_AUTH_TOKENand removes anyANTHROPIC_API_KEY(which takes precedence asx-api-keyand would conflict). - Adds
X-Valar-Client-Id,X-Valar-HarnessandX-Valar-Cli-Versionlines toANTHROPIC_CUSTOM_HEADERS, preserving any other custom headers you set and replacing stale Valar lines on re-enable. - Strips client-side model-mapping pins (
ANTHROPIC_MODEL, theANTHROPIC_DEFAULT_OPUS_MODEL/SONNET/HAIKU/FABLEsets,CLAUDE_CODE_SUBAGENT_MODEL, and the custom-model-option set) so the gateway’s routing is authoritative. Your top-levelmodelalias is left alone, as long as it names one of the models Valar routes. - Scopes the
/modelpicker to the models Valar routes, via the top-levelavailableModelsandenforceAvailableModelskeys. An id that is not on the list is rejected — including one passed as--modelorANTHROPIC_MODEL. Both are restored byoff. - Merges a behavior/telemetry block to cut Anthropic-bound nonessential traffic while you are routed.
If you are signed in to claude.ai, enabling writes the key as an
Authorization: Bearer line in ANTHROPIC_CUSTOM_HEADERS instead of ANTHROPIC_AUTH_TOKEN, which would otherwise take precedence over your login. In that mode DISABLE_TELEMETRY, DO_NOT_TRACK and CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC are left unset too: any of the three disables feature-flag evaluation, and the last also turns off /feedback, Projects, DesignSync and live preview.0600), since it now holds a bearer token. Before the first change, the original settings.json is snapshotted to ~/.valar/claude/backup.json, so off restores it byte-for-byte, including the model-mapping pins and the original permissions.
The client id defaults to your OS username, so the header reads
X-Valar-Client-Id: jdoe. Use --user-id RANDOM for an opaque vc_… id instead. See per-engineer attribution.Route a single session
To try Valar without changing anything on the machine, or to run one routed session beside a first-party setup, open a single Valar-routed session instead of enabling globally:claude whose routing rides its process environment, with the model picker scoped via a --settings argument. Nothing in your Claude setup is written: no settings.json edit, no backup, no stored defaults. (valar refreshes only its own model-list cache under ~/.valar.) Every other session, and valar claude status, stays untouched. When the session ends, so does the routing.
Because there is nothing persistent to manage, --single-session cannot be combined with --remote.
Turn off routing
settings.json edits made while routing was on are overwritten). Claude Code hot-applies additions but does not unset removals on a running session, so it keeps the old routing until you restart Claude Code. The CLI warns you when it detects a running session.
Next steps
Model routing
How cohorts and the split decide which model serves each request.
LiteLLM integration
Route Claude Code through a LiteLLM proxy without losing attribution.