# GitHub Copilot (VS Code)

Add eWest models to Copilot Chat in VS Code with a custom endpoint.

Copilot Chat in VS Code can use your own model endpoint ("bring your own key"). Add eWest as a **Custom Endpoint** and its `ewest/*` models appear in the model picker for Ask, Edit and Agent modes.

> We haven't tested this setup ourselves; it follows the tool's own documentation. If something doesn't work, contact support.

> Only chat uses your endpoint. Inline code suggestions, semantic search and anything built on embeddings stay on GitHub's own models, and still need a GitHub sign-in. On Copilot Business or Enterprise, an administrator must first turn on the "Bring Your Own Language Model Key in VS Code" policy on GitHub.com.

## Setup

1. Use a current VS Code. Open the model picker in the Chat view and click the gear icon, or run **Chat: Manage Language Models** from the Command Palette.
2. Choose **Add Models**, then **Custom Endpoint**. Enter a group name (for example `eWest`), a display name and your eWest key, then pick the API type **Chat Completions**.
3. VS Code opens `chatLanguageModels.json`. Replace its contents with the file below (keep any other groups you already have), then save.
4. Pick an eWest model in the model picker. If it doesn't show up, restart VS Code.

[Create an API key](https://ewest.ai/keys) and keep it in the `EWEST_KEY` environment variable (`export EWEST_KEY=sk-…`). Never commit it to a repository.

The file defines one group with three models. `apiType` `chat-completions` makes VS Code call `https://api.ewest.ai/v1/chat/completions`, and every model has `toolCalling` on, which Agent mode needs. The key is read through an input variable, so VS Code asks for it instead of storing it in the file. `contextWindow` and `maxOutputTokens` are the values from the model page.

chatLanguageModels.json:

```json
[
  {
    "name": "eWest",
    "vendor": "customendpoint",
    "apiKey": "${input:EWEST_KEY}",
    "apiType": "chat-completions",
    "models": [
        {
          "id": "ewest/claude-sonnet",
          "name": "Claude Sonnet (eWest)",
          "url": "https://api.ewest.ai/v1/chat/completions",
          "toolCalling": true,
          "vision": true,
          "contextWindow": 1000000,
          "maxOutputTokens": 128000
        },
        {
          "id": "ewest/claude-haiku",
          "name": "Claude Haiku (eWest)",
          "url": "https://api.ewest.ai/v1/chat/completions",
          "toolCalling": true,
          "vision": true,
          "contextWindow": 200000,
          "maxOutputTokens": 64000
        },
        {
          "id": "ewest/gemini-flash",
          "name": "Gemini Flash (eWest)",
          "url": "https://api.ewest.ai/v1/chat/completions",
          "toolCalling": true,
          "vision": true,
          "contextWindow": 1048576,
          "maxOutputTokens": 65536
        }
    ]
  }
]
```

Two other API types work as well. **Messages** suits Claude models: its base URL is `https://api.ewest.ai` without `/v1` (VS Code adds `/v1/messages`) and eWest accepts the key as `x-api-key` or as a Bearer token, so either way of sending it works. **Responses** works too. The example sets `statefulResponses` to `false`, so VS Code resends the whole conversation every turn and does not use `previous_response_id`. That does not stop eWest from storing the turns: `/v1/responses` keeps conversations by default (`store: true`, 30 days, encrypted) unless the request says `store: false` or an owner or admin has turned storing off for the organization. See [Responses](https://ewest.ai/docs/responses). Chat Completions is the simplest choice.

Messages (Claude):

```json
[
  {
    "name": "eWest (Messages)",
    "vendor": "customendpoint",
    "apiKey": "${input:EWEST_KEY}",
    "apiType": "messages",
    "models": [
        {
          "id": "ewest/claude-sonnet",
          "name": "Claude Sonnet (eWest, Messages)",
          "url": "https://api.ewest.ai",
          "toolCalling": true,
          "vision": true,
          "contextWindow": 1000000,
          "maxOutputTokens": 128000
        }
    ]
  }
]
```

Responses:

```json
[
  {
    "name": "eWest (Responses)",
    "vendor": "customendpoint",
    "apiKey": "${input:EWEST_KEY}",
    "apiType": "responses",
    "models": [
        {
          "id": "ewest/claude-sonnet",
          "name": "Claude Sonnet (eWest, Responses)",
          "url": "https://api.ewest.ai/v1/responses",
          "statefulResponses": false,
          "toolCalling": true,
          "vision": true,
          "contextWindow": 1000000,
          "maxOutputTokens": 128000
        }
    ]
  }
]
```

## Choose a model

Use the full model ID, including the `ewest/` prefix: `ewest/claude-sonnet` for everyday coding, `ewest/claude-haiku` for fast and cheap work, `ewest/gemini-flash` when you need a very long context. [Models](https://ewest.ai/docs/models) lists every model with its context window and limits; `GET /v1/models` returns the models your key may use.

| Use | Model ID |
| --- | --- |
| Everyday coding and Agent mode | `ewest/claude-sonnet` |
| Fast and cheap chat | `ewest/claude-haiku` |
| Long context (1M tokens), images | `ewest/claude-sonnet, ewest/gemini-flash` |

To add a model, copy one entry in `models`, change `id` and `name`, and set `contextWindow` and `maxOutputTokens` to the values on the model page. Set `vision` to `false` for a model that doesn't take images.

## Verify it works

Open Copilot Chat, choose an eWest model and send a short message. If nothing answers, send the same request without VS Code to rule out the key and model:

cURL:

```bash
# The request Copilot Chat sends for a message, without VS Code:
curl https://api.ewest.ai/v1/chat/completions \
  -H "Authorization: Bearer $EWEST_KEY" \
  -H "content-type: application/json" \
  -d '{"model": "ewest/claude-haiku", "stream": true, "messages": [{"role": "user", "content": "Reply with the single word OK"}]}'
```

The request shows up in the console under **Requests** within a few seconds, with its tokens and cost. Every response carries an `x-request-id` header, its [trace ID](https://ewest.ai/docs/traces).

## Streaming and tools

Chat streams by default. A model is only offered in Agent mode when it supports tool calling, so keep `toolCalling` on for the `ewest/*` chat models (all current ones support tools; the model page says so). Agent mode then reads and edits files and runs commands through tool calls on the same endpoint.

## Troubleshooting

- **404 `model_not_found`:** the model name needs the `ewest/` prefix (`ewest/claude-sonnet`, not `claude-sonnet`). Check the spelling against [Models](https://ewest.ai/docs/models).
- **401, 402 or 403:** the key is missing or wrong, out of budget, or not allowed to use this model. [Errors](https://ewest.ai/docs/errors) explains each code; a [trace ID](https://ewest.ai/docs/traces) finds the request in the console.
- **Empty answer from `ewest/gemini-flash`:** `ewest/gemini-flash` does not think unless reasoning is on (low, medium or high); then thinking uses output tokens and a small output limit can be used up. Allow at least 256 output tokens in the editor's model settings, or turn reasoning off.
- **The model is missing from the picker:** restart VS Code, check that `chatLanguageModels.json` is valid JSON, and on Business or Enterprise ask your administrator about the bring-your-own-key policy.
- **The model is missing in Agent mode:** `toolCalling` must be `true` for it.
- **Responses API and stored turns:** with `statefulResponses` set to `false`, VS Code sends the full history each time and does not use `previous_response_id`. eWest still stores the turns unless the request has `store: false` or storing is off for your organization (see [Responses](https://ewest.ai/docs/responses)).
- **Inline suggestions don't use eWest:** this is expected; they stay on GitHub.

List the models your key may use and copy the ids exactly:

cURL:

```bash
# The models your key may call (use these ids exactly, with the ewest/ prefix):
curl -H "Authorization: Bearer $EWEST_KEY" https://api.ewest.ai/v1/models

# One model, with its context window and whether it supports tools and images:
curl -H "Authorization: Bearer $EWEST_KEY" https://api.ewest.ai/v1/models/ewest/claude-haiku
```

Still stuck? Follow [Troubleshoot a request](https://ewest.ai/docs/troubleshooting).

Source: https://ewest.ai/docs/guides/github-copilot
