
GitHub Copilot Chat with Claude through a gateway: Custom Endpoint setup, agent mode and fixes
VS Code's chat can run on models you bring yourself. The built-in Anthropic provider only accepts an API key, with no field for a different address, so a gateway is added through the Custom Endpoint provider. Choose the Messages API type and list the models in chatLanguageModels.json. It has been part of stable VS Code since version 1.122.
What bring-your-own-key covers
| Feature | With your own model |
|---|---|
| Chat, ask and plan | Yes |
| Agent mode, built-in tools and MCP servers | Yes, if the model is marked toolCalling: true |
| Inline suggestions (code completions) and next edit suggestions | No: these still come from GitHub Copilot |
| Semantic search and other embedding-based features | No: these still need a GitHub account |
Since VS Code 1.122 these models work without signing in to GitHub and without a Copilot plan. On Copilot Business and Enterprise, BYOK is on by default, and administrators can turn it off with the **Bring Your Own Language Model Key** policy.
Add the gateway as a Custom Endpoint
- Open the chat view, open the model picker and choose **Manage Language Models**, or run **Chat: Manage Language Models** from the Command Palette.
- Choose **Add Models**, then the **Custom Endpoint** provider.
- Enter a display name and your gateway API key.
- Select the API type **Messages**. VS Code then opens
chatLanguageModels.jsonfor the model list.
chatLanguageModels.json
[
{
"name": "AI Prime Tech",
"vendor": "customendpoint",
"apiKey": "${input:aiprimeApiKey}",
"apiType": "messages",
"models": [
{
"id": "claude-sonnet-5",
"name": "Claude Sonnet 5",
"url": "https://aiprimetech.io/v1/messages",
"toolCalling": true,
"vision": true,
"maxInputTokens": 200000,
"maxOutputTokens": 32000
},
{
"id": "claude-opus-5-5",
"name": "Claude Opus 5.5",
"url": "https://aiprimetech.io/v1/messages",
"toolCalling": true,
"vision": true,
"maxInputTokens": 200000,
"maxOutputTokens": 32000
},
{
"id": "claude-haiku-4-5",
"name": "Claude Haiku 4.5",
"url": "https://aiprimetech.io/v1/messages",
"toolCalling": true,
"vision": true,
"maxInputTokens": 168000,
"maxOutputTokens": 32000
}
]
}
]| Field | Why |
|---|---|
id | The model ID sent to the gateway |
url | The full endpoint. VS Code uses a URL ending in /messages as-is; give the full path to avoid guessing |
toolCalling: true | Required for agent mode. A model without it doesn't appear for agents |
maxInputTokens + maxOutputTokens | Their sum must not exceed the model's context window |
apiKey: ${input:...} | VS Code asks for the key once and stores it, so it isn't written into the file |
With the Messages type, VS Code sends the key in the x-api-key header, which is what the gateway expects. Model IDs must match the gateway's exactly.
GPT models on the same key
The Custom Endpoint provider also speaks the OpenAI formats. To add GPT models from a key in the gateway's Codex group, add a second provider with "apiType": "chat-completions" and model URLs of https://aiprimetech.io/v1/chat/completions. A key reaches only the models of its own group, so Claude and GPT usually need separate entries with separate keys.
The older github.copilot.chat.customOAIModels setting and the **OpenAI Compatible** provider are deprecated in favour of Custom Endpoint. Move old entries into chatLanguageModels.json.
Troubleshooting
| What you see | Cause | Fix |
|---|---|---|
| The model doesn't appear in the picker | Needs a reload, or toolCalling is false, or the workspace is in Restricted Mode | Restart VS Code, set toolCalling: true, trust the workspace |
| The provider list has no Custom Endpoint | VS Code older than 1.122, or BYOK disabled by your organisation | Update VS Code; ask the admin about the BYOK policy |
401 / invalid API key | The stored key is wrong or belongs to another endpoint | Gear icon next to the provider, then **Update API Key** |
| Model not supported | The id doesn't match a gateway model ID | Use an ID from the table below |
| Context or token errors | maxInputTokens plus maxOutputTokens exceeds the window | Lower maxInputTokens |
Concurrency limit exceeded | Several agents or windows running at once on one key | Run fewer in parallel |
For details, run **Developer: Set Log Level**, choose **Trace**, then open **Output** and pick **GitHub Copilot Chat**. The Chat Debug view shows the exact requests. A log line saying BYOK providers were unregistered because the policy disallows them points at an organisation policy.
| Model ID | Use it for |
|---|---|
claude-sonnet-5 | Default for coding and agent work: fast, strong, mid-priced. |
claude-opus-5-5 | Harder reasoning, large refactors, long agent runs. |
claude-fable-5-1 | Most capable and most expensive; save it for the hardest tasks. |
claude-haiku-4-5 | Cheap and quick: titles, summaries, classification, small steps. |
Prefer the terminal? The same key runs Claude Code in VS Code through its own extension.
Frequently asked questions
Can I use my own Claude API key in GitHub Copilot?
Can I change the Anthropic base URL in Copilot?
Do BYOK models work in Copilot agent mode?
Do I need a Copilot subscription to use my own model?
Get an API key — no Anthropic account or waitlist required.
Get your API keyAI Prime Tech is an independent API gateway. It is not affiliated with, endorsed by, or a reseller of Anthropic. Claude and related model names are trademarks of their respective owners.