# GitHub Copilot Integration

> **Last verified**: 2026-09-18 · 📄 Per official docs (VS Code 1.138.0 / bundled Copilot extension 0.66.0, Copilot CLI v1.0.86 released 2026-09-17)

## At a glance

| Item | Details |
|---|---|
| Models you can use | Claude ✅ (only the `messages` type) · GPT ✅ (Chat / Responses) · Chinese models ✅ (Chat) · Gemini ❌ (no such protocol option) |
| Protocol & Base URL | VS Code `url` takes the **full path**: `https://api.qcode.cc/api/v1/messages` · `https://api.qcode.cc/openai/v1/chat/completions` · `https://api.qcode.cc/openai/v1/responses`; the CLI takes the **root only** (Route B) |
| Where to configure | VS Code: command palette `Chat: Manage Language Models` → `chatLanguageModels.json`; CLI: environment variables |
| Official docs | [VS Code language models](https://code.visualstudio.com/docs/agent-customization/language-models) · [Copilot CLI BYOK](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models) |

## Prerequisites

- **Route A**: VS Code ≥ 1.122 (Custom Endpoint reached Stable on 2026-05-28).
- **Route B**: GitHub Copilot CLI installed.
- A QCode.cc `cr_` key ([dashboard](https://qcode.cc/dashboard)). Models are billed per token by QCode — separate from any Copilot plan fee (see [Subscriptions vs API Keys vs QCode Keys](/docs/reference/subscription-vs-api-key)).

## Setup

### Route A: VS Code Custom Endpoint (recommended)

Open the command palette (`Ctrl/Cmd+Shift+P`) → **`Chat: Manage Language Models`** → choose **Custom Endpoint**; VS Code opens `chatLanguageModels.json` for editing. Four official rules:

- `vendor` must be `customendpoint`; the key field is `apiKey`.
- `apiType` has three legal values: `messages` (Anthropic protocol), `chat-completions`, `responses`. **Claude models only work with `messages`**.
- `url` should be the **complete request URL including the path** (official guidance); otherwise VS Code inserts `/v1` for you and builds a 404 easily.
- To appear in Agent mode, an entry needs `"toolCalling": true`, or the model stays out of the picker.

Claude plus GPT/Chinese models side by side:

```json
[
  { "name": "QCode Claude", "vendor": "customendpoint", "apiKey": "cr_your-QCode-key",
    "apiType": "messages",
    "url": "https://api.qcode.cc/api/v1/messages",
    "toolCalling": true,
    "models": [ { "id": "claude-sonnet-5" } ] },
  { "name": "QCode OpenAI", "vendor": "customendpoint", "apiKey": "cr_your-QCode-key",
    "apiType": "chat-completions",
    "url": "https://api.qcode.cc/openai/v1/chat/completions",
    "toolCalling": true,
    "models": [ { "id": "gpt-5.6" }, { "id": "glm-5.3" } ] }
]
```

GPT over the Responses protocol (the same leg Codex uses, GPT-only):

```json
[
  { "name": "QCode Responses", "vendor": "customendpoint", "apiKey": "cr_your-QCode-key",
    "apiType": "responses",
    "url": "https://api.qcode.cc/openai/v1/responses",
    "toolCalling": true,
    "models": [ { "id": "gpt-5.6" } ] }
]
```

Save, and the models show up in the chat model picker.

### Route B: Copilot CLI bring-your-own-key

The CLI declares a custom model through four environment variables; `COPILOT_PROVIDER_TYPE` officially takes only `openai` (default), `azure`, `anthropic`. For the QCode Anthropic leg:

```bash
# Anthropic Messages route — base URL is the ROOT, no path appended
export COPILOT_PROVIDER_TYPE=anthropic
export COPILOT_PROVIDER_BASE_URL="https://api.qcode.cc/api"
export COPILOT_PROVIDER_API_KEY="cr_your-QCode-key"
export COPILOT_MODEL="claude-sonnet-5"

# OpenAI-compatible route — base URL includes /v1 but not /chat/completions
export COPILOT_PROVIDER_TYPE=openai
export COPILOT_PROVIDER_BASE_URL="https://api.qcode.cc/openai/v1"
export COPILOT_PROVIDER_API_KEY="cr_your-QCode-key"
export COPILOT_MODEL="gpt-5.6"
```

Use one set at a time (the later export wins): the first block connects Claude over the Anthropic leg, the second connects GPT / Chinese models over the OpenAI-compatible leg — where the base URL ends at `/v1`, the opposite of Route A.

🔴 The number-one trap on this page: **VS Code wants the full path in `url`, the CLI wants the root in `BASE_URL`** — copy-pasting one form into the other always fails.

### Copilot on JetBrains

GitHub lists JetBrains among the clients supporting local BYOK, with OpenAI-compatible Custom Endpoints available since 2026-07-14, configured under Copilot's **Manage Models**. Field-level details are not yet documented officially, and Anthropic-type endpoints on JetBrains are not confirmed on the official pages — treat [GitHub Copilot docs](https://docs.github.com/copilot) as the source of truth.

## Verify it works

Pick the custom model in Copilot Chat (or the `copilot` CLI) and send one message:

- A normal reply = connected.
- `401` = `apiKey` / `COPILOT_PROVIDER_API_KEY` wrong (keep the full `cr_` prefix).
- `404` = the URL shape is off — VS Code needs the full path, the CLI needs the root (check the table above).
- Every request is visible under your key at [probe.qcode.cc](https://probe.qcode.cc). For the full checklist see [troubleshooting](/docs/reference/troubleshooting).

## Known limitations

- **Inline completions still run through GitHub**: custom endpoints / BYOK affect Chat and Agent only (official boundary).
- **No Gemini option**: `apiType` has no Gemini protocol, so `gemini-*` models are unavailable here — pick another client (see [Tool Compatibility Overview](/docs/ide/tool-compatibility)).
- Organization policies may disable custom model endpoints; enterprise users should check their policy first.
- The `messages` full-path form (`/api/v1/messages`) follows the official recommendation of writing complete URLs; if your VS Code build behaves differently (auto-inserting `/v1`), fix it against the 404/400 codes as described above.
- Capability fields (`vision`, `maxInputTokens`, `maxOutputTokens`, …) can be declared per entry; semantics on the official page.

## Related docs

- [VS Code Integration (Claude Code extension)](/docs/ide/vscode)
- [Endpoints and API paths](/docs/getting-started/endpoints-and-api-paths)
- [Tool Compatibility Overview](/docs/ide/tool-compatibility)
- [Subscriptions vs API Keys vs QCode Keys](/docs/reference/subscription-vs-api-key)
- [JetBrains IDE Integration](/docs/ide/jetbrains)