Skip to main content
If you already run a LiteLLM proxy in front of your models, you can keep it and still use ValarCode. Claude Code points at LiteLLM, LiteLLM forwards to Valar, and Valar’s per-engineer routing and attribution work as long as the client id makes it through. This page covers Claude Code. Pi works the same way: it also sends the client id in an X-Valar-Client-Id header, so the LiteLLM config below applies unchanged. Just connect Pi with valar pi on --endpoint <your-litellm-base-url> --api-key <litellm-virtual-key> and restart Pi. Instructions for connecting Cursor through LiteLLM are coming soon (Cursor carries its client id as a token suffix rather than a header).

How it fits together

valar claude on writes three Valar headers into ~/.claude/settings.json: X-Valar-Client-Id (attributes usage to an engineer, defaulting to their username), X-Valar-Harness (names the tool, from a fixed set of supported values) and X-Valar-Cli-Version. All are x--prefixed, so LiteLLM forwards them together — getting that hop right is the one thing that matters. It matters more through a proxy than it does directly. LiteLLM makes its own request upstream, so the user agent Valar sees is LiteLLM’s, not your harness’s — the headers are the only signal left. Without X-Valar-Harness, everything on this path is recorded as Claude Code. An unrecognised value does the same thing. X-Valar-Harness accepts a fixed set of tool names — claude, codex, cursor, gemini, opencode, pi, copilot, librechat — and anything outside that set is ignored rather than rejected, so putting your own application or deployment name here also records the traffic as Claude Code, and serves it on Claude Code’s routing configuration. Send the name of the tool actually making the request. Running LibreChat behind this proxy is a supported case with a page of its own.

Configure LiteLLM

Valar speaks the Anthropic Messages API at https://api.valarhq.ai, so LiteLLM routes to it as an anthropic/* model. Two settings matter:
  1. A wildcard model entry so any model string Claude Code requests (Opus, Sonnet, Haiku, or whatever it names across versions) is forwarded to Valar in Anthropic Messages format. Token and cost accounting still works, because every request maps to a known Anthropic model. The wildcard takes every model name the proxy has no exact entry for, for every key, so it fits a proxy that exists for Valar. For a proxy that other engineers keep using for your current models, see Route only some engineers to Valar.
  2. Header forwarding, so LiteLLM passes Claude Code’s x--prefixed headers (the X-Valar-* set) on to Valar. Without this, they are dropped at the proxy and per-engineer attribution is lost.
Add this to your LiteLLM config:
Set VALAR_API_KEY to your Valar coding key, the vlrcode_… key you generated in the Valar Dashboard. LiteLLM uses it to authenticate to Valar upstream.
The X-Valar-Client-Id header is x--prefixed, which is exactly what LiteLLM’s forward_client_headers_to_llm_api forwards. The header name matters: keep the x-valar- prefix. It is worth confirming on your first request (in Valar’s request logs or the analytics dashboard) that the header actually arrives, since per-engineer attribution only works if it does.

Create a virtual key in LiteLLM

LiteLLM sits between Claude Code and Valar, so Claude Code no longer talks to Valar directly. Instead it authenticates to LiteLLM with a virtual key you create there. In the LiteLLM admin UI (or via the LiteLLM API), create a virtual key that is allowed to reach the Anthropic models you just configured, i.e. the wildcard * entry that forwards to Valar. Copy the key; Claude Code will use it as its bearer token. What flows through after this:
  • Claude Code authenticates to LiteLLM with the virtual key.
  • LiteLLM authenticates to Valar with your Valar coding key (VALAR_API_KEY).
  • Claude Code’s X-Valar-* headers are forwarded to Valar, so routing and attribution behave exactly as in the direct path.

Route only some engineers to Valar

The wildcard entry sends every model name the proxy has no exact entry for to Valar, for every key. That is the right shape for a proxy that exists for Valar. On a proxy that also serves engineers who stay on your current models, use a dedicated prefix instead, and let the virtual key decide who reaches Valar:
Then create the pilot engineers’ virtual keys with an alias per Claude model name. LiteLLM rewrites the requested model to the aliased name before routing, so Claude Code’s settings do not change; the key alone decides where a request goes. Everyone else keeps the bare names and their current path.
An alias matches the exact model name. The four above are what Claude Code currently sends for its Opus, Sonnet, Haiku and Fable tiers; a newer release can add or rename one, and the LiteLLM request log shows what yours sends. A name with no alias and no entry of its own is refused by the proxy. The key can be limited to valar/*: LiteLLM resolves the alias before it checks the key’s model access. If you would rather leave keys alone, set Claude Code’s tier variables (ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_FABLE_MODEL) to the prefixed names in a managed settings file. valar claude on removes those variables, so this variant does not go through the CLI. Keep the global forward_client_headers_to_llm_api switch when you use aliases. The per-group form (litellm_settings.model_group_settings.forward_client_headers_to_llm_api: ["valar/*"]) is evaluated before key aliases apply, so it forwards the headers only when the client itself sends the prefixed name, as in the tier-variable setup.

Connect Claude Code

Now point Claude Code at the LiteLLM proxy instead of Valar directly. Run valar claude on with --endpoint set to your LiteLLM base URL and --api-key set to the virtual key you just created:
For example, if LiteLLM is running at https://litellm.example.com:
The CLI writes LiteLLM’s base URL to ANTHROPIC_BASE_URL, the virtual key to ANTHROPIC_AUTH_TOKEN, and the Valar headers to ANTHROPIC_CUSTOM_HEADERS in ~/.claude/settings.json, the same as the direct path but pointed at your proxy.
Claude Code appends /v1/messages to the base URL, so pass the host without a /v1 suffix, the same way you would for the default Valar endpoint. If your LiteLLM proxy serves the Anthropic surface under a path prefix, include that prefix in --endpoint.

Verify it works

After the first few requests, check:
  • LiteLLM logs: requests are arriving from Claude Code and being forwarded upstream.
  • Valar analytics dashboard: the engineer shows up under their client id (their username by default) with attributed usage. If usage appears but is not attributed to an engineer, the X-Valar-Client-Id header is not making it through; re-check forward_client_headers_to_llm_api and the header name.
To stop routing through LiteLLM and restore Claude Code’s previous settings:

Next steps

Claude Code

The direct connect path and what the CLI writes to settings.json.

Portkey

The same setup for a Portkey gateway.

Model routing

How the client id drives cohort assignment and the split.