Home / Learn / GitHub Copilot Chat with Claude through a gateway: Custom Endpoint setup, agent mode and fixes
Claude in Copilot. Two elegant drafting instruments working side by side over a code sheet, with a small external API plug, suggesting collaborative coding.

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 planYes
Agent mode, built-in tools and MCP serversYes, if the model is marked toolCalling: true
Inline suggestions (code completions) and next edit suggestionsNo: these still come from GitHub Copilot
Semantic search and other embedding-based featuresNo: 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

  1. Open the chat view, open the model picker and choose **Manage Language Models**, or run **Chat: Manage Language Models** from the Command Palette.
  2. Choose **Add Models**, then the **Custom Endpoint** provider.
  3. Enter a display name and your gateway API key.
  4. Select the API type **Messages**. VS Code then opens chatLanguageModels.json for the model list.

chatLanguageModels.json

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
idThe model ID sent to the gateway
urlThe full endpoint. VS Code uses a URL ending in /messages as-is; give the full path to avoid guessing
toolCalling: trueRequired for agent mode. A model without it doesn't appear for agents
maxInputTokens + maxOutputTokensTheir 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 pickerNeeds a reload, or toolCalling is false, or the workspace is in Restricted ModeRestart VS Code, set toolCalling: true, trust the workspace
The provider list has no Custom EndpointVS Code older than 1.122, or BYOK disabled by your organisationUpdate VS Code; ask the admin about the BYOK policy
401 / invalid API keyThe stored key is wrong or belongs to another endpointGear icon next to the provider, then **Update API Key**
Model not supportedThe id doesn't match a gateway model IDUse an ID from the table below
Context or token errorsmaxInputTokens plus maxOutputTokens exceeds the windowLower maxInputTokens
Concurrency limit exceededSeveral agents or windows running at once on one keyRun 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-5Default for coding and agent work: fast, strong, mid-priced.
claude-opus-5-5Harder reasoning, large refactors, long agent runs.
claude-fable-5-1Most capable and most expensive; save it for the hardest tasks.
claude-haiku-4-5Cheap 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?
Yes. In VS Code's chat choose Manage Language Models, Add Models, then the Anthropic provider for Anthropic's own API, or Custom Endpoint with API type Messages for a gateway.
Can I change the Anthropic base URL in Copilot?
Not in the built-in Anthropic provider, which only takes a key. Use the Custom Endpoint provider and set each model's url to the gateway's /v1/messages endpoint.
Do BYOK models work in Copilot agent mode?
Yes, when the model is marked toolCalling: true. Built-in tools and MCP servers keep working; inline code completions still come from Copilot.
Do I need a Copilot subscription to use my own model?
Not since VS Code 1.122: BYOK models work without a GitHub sign-in or Copilot plan. Business and Enterprise organisations can disable it by policy.
Start using Claude in minutes

Get an API key — no Anthropic account or waitlist required.

Get your API key

AI 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.

More Claude API guides

How to Get a Claude API KeyClaude API Pricing, ExplainedThe Cheapest Way to Use the Claude APIUnlimited Cursor with the Claude APIUnlimited Claude Code AccessClaude API Gateway vs. Anthropic DirectUse Claude with the OpenAI SDK: OpenAI-compatible endpoint, streaming, tools and limitsClaude models explained: a Claude model comparison of Claude Opus vs Sonnet vs Haiku vs Fable — all Claude API models, Anthropic model names and prices (2026)Paying for the Claude API with CryptoClaude API Access Without a WaitlistHow to Reduce Claude Token UsageUnlimited Cline with the Claude APIUnlimited Roo Code with the Claude APIUnlimited Claude in JetBrains IDEsAider with Claude through a gateway: ANTHROPIC_API_BASE, config files, architect mode and fixesUnlimited Claude in VS CodeOpenCode config for Claude: opencode.json setup, models and common errorsHermes Agent with Claude through a gateway: custom provider setup, cost controls and fixesRunning Unlimited OpenClaw on ClaudeWhat an Anthropic-Compatible API MeansClaude Code API key — ANTHROPIC_API_KEY: how to get it, set it up, and when to use claude setup-token insteadClaude Code API Costs — Pricing and How to Cut ThemClaude API errors explained: server error 500, overloaded 529, rate limit 429, bad request 400 — and the fix for eachHow to buy Claude API credits — and why a Claude credit beats any "buy Claude account" offerClaude free API: is there a free Claude API key, and what is actually free in 2026?Claude API vs Claude Pro/Max Subscription — Which to ChooseCodex CLI with a custom provider: config.toml, GPT and Claude models, IDE extension and fixesConnecting Claude to n8nRouting LiteLLM to ClaudeUsing Claude in Kilo CodeWire Zed to Claude Through the GatewayConnect Cherry Studio to ClaudeChatAnthropic in LangChain: import, base_url, streaming, tools and errorsAnthropic Python SDK: install, set base_url, stream, and handle errorsClaude with the Vercel AI SDK: createAnthropic baseURL, streaming and fixesRun Factory Droid on ClaudeThe Claude Code API, ExplainedIntegrating the Claude API Into Your ApplicationHow to get unlimited Claude usage — and why there is no "Claude Code cracked"