> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valarhq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Visual Studio Code

> Route VS Code through Valar via GitHub Copilot Chat's custom-endpoint (BYOK) provider

ValarCode routes VS Code through GitHub Copilot Chat's bring-your-own-key **Custom Endpoint** provider. Enabling registers a **Valar** provider group in Copilot Chat, and you pick a Valar model from its model picker. The group speaks the Anthropic Messages API; the gateway maps whatever model it sends to the target your routing resolves to. See [Set up ValarCode](/valarcode/setup) for the shared setup and the client-id model.

<Note>
  The VS Code integration uses the `copilot` harness, so the command is `valar copilot`. `valar vscode` is an alias you can use interchangeably; attribution is recorded under the `copilot` harness either way.
</Note>

## Prerequisites

* VS Code (the stable build) with GitHub Copilot Chat signed in, and a version new enough to offer the Custom Endpoint provider. Insiders and forks keep their own config and are not routed.
* A Valar coding key (`vlrcode_…`) and the `valar` CLI ([install](/valarcode/setup#install-the-cli)).

## Enable routing

Run once per machine:

```bash theme={"system"}
valar copilot on --api-key <your-coding-key>
```

Then **reload the VS Code window** and pick a Valar model in Copilot Chat's model picker. If the group is not listed yet, reload again. Check the state any time:

```bash theme={"system"}
valar copilot status
```

## What gets written

The CLI registers a provider group in Copilot Chat's model config, `chatLanguageModels.json`, in the VS Code user directory (`~/Library/Application Support/Code/User` on macOS, `~/.config/Code/User` on Linux), plus one file per additional VS Code profile under `profiles/*/`. The file is a JSON array of provider groups; the CLI adds a group named **Valar**:

```json theme={"system"}
[
  {
    "vendor": "customendpoint",
    "name": "Valar",
    "apiType": "messages",
    "models": [
      {
        "id": "<model-id>",
        "name": "<Model Name>",
        "url": "https://api.valarhq.ai/v1/messages",
        "toolCalling": true,
        "vision": true,
        "thinking": true,
        "contextWindow": 200000,
        "maxOutputTokens": 64000,
        "requestHeaders": {
          "x-api-key": "vlrcode_…",
          "X-Valar-Harness": "copilot",
          "X-Valar-Client-Id": "jdoe",
          "X-Valar-Cli-Version": "1.4.2"
        }
      }
    ]
  }
]
```

In detail, enabling:

* Registers a **Valar** group under the built-in `customendpoint` vendor, with `apiType: "messages"` so the group speaks the Anthropic Messages dialect. The group's `models` list **is** the picker; you choose a Valar model there yourself.
* Writes the full per-model endpoint `https://api.valarhq.ai/v1/messages` on each model, since this vendor has no separate base-URL field.
* Carries the coding key in the **`x-api-key` request header** rather than the vendor's `apiKey` field. That field is stored in the OS keychain and cannot be populated by an external writer, so the key rides as a request header instead; the gateway authenticates it like a bearer token.
* Adds `X-Valar-Harness: copilot`, `X-Valar-Client-Id` and `X-Valar-Cli-Version` to each model's `requestHeaders` for attribution.

On the first enable, the files it touches are snapshotted to `~/.valar/copilot/backup.json`. A VS Code profile you create later is routed by the next `on` and un-routed by `off` on the Valar marker, without a snapshot of its own.

<Note>
  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](/valarcode/setup#per-engineer-attribution).
</Note>

<Warning>
  A `chatLanguageModels.json` that contains comments (JSONC) is skipped and reported rather than rewritten, so a hand-edited file is never clobbered. Remove the comments and re-run `on` to route that profile.
</Warning>

## Turn off routing

```bash theme={"system"}
valar copilot off
```

This restores the pre-enable snapshot and removes the Valar group from any profile it was added to. **Reload the VS Code window** if the Valar models are still listed in Copilot Chat.

## Next steps

<CardGroup cols={2}>
  <Card title="Model routing" icon="route" href="/valarcode/routing">
    How cohorts and the split decide which model serves each request.
  </Card>

  <Card title="Analytics" icon="chart-line" href="/valarcode/analytics">
    Per-engineer usage and savings, attributed by client id.
  </Card>
</CardGroup>
