opencode.jsonc. opencode keeps speaking the Anthropic Messages API and you keep picking your model; the gateway maps whatever it sends to the target your routing resolves to. See Set up ValarCode for the shared setup and the client-id model.
One command covers every way opencode runs — the terminal UI, the desktop app, and a phone driving a session over opencode serve — because all three read the same config file. There is nothing extra to enable per surface.
Prerequisites
- opencode installed, by any method — the install script, Homebrew (
brew install opencode), or the desktop app (brew install --cask opencode-desktop). - A Valar coding key (
vlrcode_…) and thevalarCLI (install).
Enable routing
Run once per machine:opencode.jsonc, so a new opencode session picks it up on start with no env var, shell-rc edit, or new-terminal step. Check the state any time:
Restart opencode to apply a change. opencode reads its config once when it starts and caches it for the life of the process. If you run
valar opencode on or off while the terminal UI, the desktop app, or a serve process is already open, quit and reopen it to pick up the change.What gets written
valar opencode on edits ~/.opencode/opencode.jsonc. It adds a Valar provider that points at the gateway and carries your credentials, and pins both model slots to the Valar auto-router:
- Adds a
valarprovider whosebaseURLis the/v1surface. opencode’s@ai-sdk/anthropicdialect appends/messages, so requests land onhttps://api.valarhq.ai/v1/messages. - Puts the coding key on
options.apiKey. In config it wins over opencode’s own auth store, so there is no login conflict. - Adds the
X-Valar-Client-Id,X-Valar-HarnessandX-Valar-Cli-Versionrequest headers. The client-id header is omitted entirely when there is no client id, rather than written blank. - Writes the full Valar model catalog under the provider’s
models. opencode has no public entry for these models, so what Valar writes here is the model picker you see in the app. - Pins both
modelandsmall_modeltovalar/valar-auto. The small slot matters: left unset, opencode picks its own model for the quick “name this session” call, which would route outside Valar.
opencode.jsonc is snapshotted under ~/.valar/opencode/ before the first change, so off restores it exactly — including any edits you made while routing was on.
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.The desktop app and mobile
The opencode desktop app and the phone clients (which drive a session overopencode serve) run the same engine as the terminal, and read the same ~/.opencode/opencode.jsonc. So valar opencode on routes them too — there is no separate desktop or mobile command.
- Desktop app — enable routing, then open (or restart) the app. It shows the Valar models in its picker with Valar Auto selected.
- Remote / mobile — start the server with
opencode serve, connect your phone client to it on your network, and the server’s requests route through Valar. The phone never contacts Valar directly; your machine’s engine does, so usage attributes toopencodeexactly as the terminal does. For any real remote use, setOPENCODE_SERVER_PASSWORD— an unsecuredserveis open to anyone on your network.
Turn off routing
opencode.jsonc. Start a new opencode session — or restart the app — to pick up the change.
Next steps
Model routing
How cohorts and the split decide which model serves each request.
Models
The open-weight targets and the frontier Claude tiers.