# GitHub Copilot (/docs/integrations/github-copilot)

Use codai in VS Code Copilot Chat through a Custom Endpoint and in Copilot CLI through BYOK.

VS Code Chat needs a **Custom Endpoint** entry for `codai`; Copilot CLI needs four environment variables. Neither needs a Copilot plan or a GitHub sign-in.

## Before you start [#before-you-start]

- A codai key from [hub.codai.ro](https://hub.codai.ro) → **Keys → Create key** (details in the [quickstart](../gateway/index.mdx)).
- On Copilot Business or Enterprise, your org must enable the policy **Bring Your Own Language Model Key in VS Code**.

## VS Code Chat (Custom Endpoint) [#vs-code-chat-custom-endpoint]

The fastest path is the prebuilt config the gateway serves at `https://ai.codai.ro/vscode/chatLanguageModels.json` — three picker entries, the effort dial and tuned headers. Follow the steps on [clients](../gateway/clients.mdx#vs-code-copilot-chat-custom-endpoint).

To write the entry by hand: model picker → **Manage Language Models → Add Models → Custom Endpoint**, then edit the `chatLanguageModels.json` that VS Code opens:

```json title="chatLanguageModels.json"
[
  {
    "name": "codai",
    "vendor": "customendpoint",
    "apiKey": "${input:codaiApiKey}",
    "apiType": "chat-completions",
    "models": [
      {
        "id": "codai",
        "name": "codai",
        "url": "https://ai.codai.ro/v1/chat/completions",
        "toolCalling": true,
        "vision": true,
        "thinking": true,
        "maxInputTokens": 168000,
        "maxOutputTokens": 32000
      }
    ]
  }
]
```

- Give the **full endpoint URL**, including `/chat/completions`.
- `toolCalling: true` is required for agent mode.
- `maxInputTokens + maxOutputTokens` must not exceed the context window. The numbers above are a conservative 200k window; the served config at `https://ai.codai.ro/vscode/chatLanguageModels.json` is the source of truth and advertises the larger windows the gateway can serve.
- For the Anthropic wire format set `"apiType": "messages"` and `"url": "https://ai.codai.ro/v1/messages"`.

The older `github.copilot.chat.customOAIModels` setting and the *OpenAI Compatible* provider are deprecated. Use Custom Endpoint.

### MCP in VS Code [#mcp-in-vs-code]

```json title="mcp.json"
{
  "servers": {
    "codai": {
      "type": "http",
      "url": "https://ai.codai.ro/mcp",
      "headers": { "Authorization": "Bearer ${input:codai-key}" }
    }
  },
  "inputs": [
    { "type": "promptString", "id": "codai-key", "description": "codai API key", "password": true }
  ]
}
```

Open the user file with **MCP: Open User Configuration**, or use `.vscode/mcp.json` per workspace.

## Copilot CLI (BYOK) [#copilot-cli-byok]

```powershell tab="PowerShell"
$env:COPILOT_PROVIDER_BASE_URL   = 'https://ai.codai.ro/v1'
$env:COPILOT_PROVIDER_TYPE       = 'openai'
$env:COPILOT_PROVIDER_API_KEY    = 'codai_xxxxxxxx'
$env:COPILOT_PROVIDER_WIRE_MODEL = 'codai'
$env:COPILOT_MODEL               = 'codai'
copilot
```

```bash tab="bash"
export COPILOT_PROVIDER_BASE_URL='https://ai.codai.ro/v1'
export COPILOT_PROVIDER_TYPE='openai'
export COPILOT_PROVIDER_API_KEY='codai_xxxxxxxx'
export COPILOT_PROVIDER_WIRE_MODEL='codai'
export COPILOT_MODEL='codai'
copilot
```

With `COPILOT_PROVIDER_TYPE=anthropic`, the base URL is the root `https://ai.codai.ro` — no `/v1`. The gateway also serves ready-made scripts; see [clients](../gateway/clients.mdx#github-copilot-cli-byok).

### MCP in Copilot CLI [#mcp-in-copilot-cli]

The CLI does not read `.vscode/mcp.json`. Add the server from the command line:

```bash
copilot mcp add --transport http --header "Authorization: Bearer codai_xxxxxxxx" codai https://ai.codai.ro/mcp
```

To keep the key out of config files, use the stdio memory bridge described on [clients](../gateway/clients.mdx#persistent-memory-for-byok-sessions).

## What works and what does not [#what-works-and-what-does-not]

| Feature | With codai |
| --- | --- |
| Chat, agent mode, tools (VS Code) | Work |
| Copilot CLI sessions | Work |
| Inline suggestions, semantic search, embeddings | Stay on GitHub |
| Titles and commit messages | GitHub models, unless you set `chat.utilityModel` / `chat.byokUtilityModelDefault` |
| Restricted Mode | Shows only Auto |
| GitHub-hosted memory and remote delegation (CLI) | Not available in BYOK mode |

## Troubleshooting [#troubleshooting]

- **CLI reports "Authentication failed (HTTP 401)"** with type `anthropic` — the base URL ends in `/v1`. The real error is a `404`; use the root URL.
- **`codai` is missing from the picker** — restart VS Code; check that the org policy allows your own keys.
- **Agent mode is greyed out** — `toolCalling` is not `true` on the model entry.
- **Agent Host sessions do not list `codai`** — enable `chat.agentHost.byokModels.enabled`.

## Sources [#sources]

Checked 2026-10-02.

- [VS Code — language models](https://code.visualstudio.com/docs/copilot/customization/language-models)
- [VS Code — MCP configuration](https://code.visualstudio.com/docs/copilot/reference/mcp-configuration)
- [VS Code — MCP servers](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)
- [GitHub Docs — Copilot CLI BYOK models](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models)
- [GitHub Docs — Copilot CLI MCP servers](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers)
- [GitHub Docs — Copilot CLI command reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference)
