Part of Software Development & Tools — the development stack: environments, APIs and tooling.
A VS Code Copilot custom endpoint lets GitHub Copilot Chat use a model you choose instead of the built-in ones. In this guide I point that endpoint at LLM Vault, a local gateway that keeps the real provider key in an encrypted vault. As a result, Copilot Chat and your custom agents reach Azure AI Foundry or a local model, while the key never appears in VS Code settings.
- VS Code now uses the Custom Endpoint provider. It replaces both the older “OpenAI Compatible” provider and the deprecated
github.copilot.chat.customOAIModelssetting. - Set
"toolCalling": true. Otherwise the model never appears in the agent-mode picker. - Use the full URL
http://127.0.0.1:8765/v1/chat/completionsand a scoped LLM Vault client token as the API key. - Streaming tool calls passed through the gateway intact: qwen3:0.6b called
read_filein my test. - Copilot Business and Enterprise users need the “Bring Your Own Language Model Key in VS Code” policy enabled.
Why use a VS Code Copilot custom endpoint at all
Copilot’s built-in models cover most daily work. However, many teams also pay for their own deployments. A typical case is a GLM or GPT deployment in Azure AI Foundry, bought under an enterprise agreement. In other cases, a team needs a local model for code that must not leave the building.
Bring-your-own-key (BYOK) solves that, but it creates a new problem. The raw provider key ends up in VS Code, next to an agent that can read files and run commands. That is the exact pattern I described in the AI agent API key security guide.
LLM Vault sits in between. VS Code gets a client token that can only call approved models. Meanwhile, the vault holds the Foundry key, applies consent and budgets, and logs every call. In addition, you get per-agent cost reports, which Copilot itself does not show for BYOK models.
What stays the same
Above all, Copilot’s own models keep their GitHub authentication path. The vault never sees them, and it does not try to. Likewise, inline completions still need a GitHub sign-in. The custom endpoint only adds models to the chat model picker.
Prerequisites for a Copilot custom endpoint
- VS Code with the GitHub Copilot Chat extension, recent enough to show Custom Endpoint under “Add Models”.
- LLM Vault running and unlocked. Its gateway listens on
http://127.0.0.1:8765/v1by default. - At least one model alias in the vault, for example
foundry-glm(Azure AI Foundry) orqwen-local(Ollama). - For Copilot Business or Enterprise: the organization policy “Bring Your Own Language Model Key in VS Code” turned on.
Before touching VS Code, check that the gateway answers. A quick curl to the models endpoint is enough:
curl http://127.0.0.1:8765/v1/models -H "Authorization: Bearer lvk_..."
# {"object":"list","data":[{"id":"foundry-glm",...},{"id":"qwen-local",...}]}
Step 1: create a token for the VS Code Copilot endpoint
Open “Clients & agents” in LLM Vault and create a token named “VS Code – Code Reviewer”. Then restrict it to the models Copilot should use, for example foundry-glm, qwen-local. Next, choose “Ask once per session” as the consent mode and 30 days as the lifetime. Finally, set a daily budget, so a runaway agent loop stops at a known cost.
The token appears exactly once. Only its SHA-256 hash is stored. Conveniently, the dialog already contains the VS Code configuration with your gateway URL and model alias filled in.

Step 2: add the VS Code Copilot custom endpoint
In VS Code, open the command palette and run Chat: Manage Language Models. Then choose Add Models and Custom Endpoint. Enter a group name such as “LLM Vault”, paste the client token as the API key and select the Chat Completions API type.
Alternatively, edit the JSON directly. VS Code opens a chatLanguageModels.json file for this provider. This is the entry LLM Vault generates:
[
{
"name": "LLM Vault",
"vendor": "customendpoint",
"apiKey": "${input:llmVaultToken}",
"apiType": "chat-completions",
"models": [
{
"id": "foundry-glm",
"name": "foundry-glm (LLM Vault)",
"url": "http://127.0.0.1:8765/v1/chat/completions",
"toolCalling": true,
"vision": false,
"maxInputTokens": 128000,
"maxOutputTokens": 16000,
"requestHeaders": { "X-LLMVault-Agent": "vscode-copilot" }
}
]
}
]
How VS Code resolves the custom endpoint URL
According to the VS Code language models documentation, a URL that already ends in /chat/completions is used as-is. Otherwise, VS Code appends the path and inserts /v1 when it is missing. Therefore, the full URL avoids any guessing. The id field must match the alias in the vault, because the gateway routes by that name.
The three fields that matter most
First, toolCalling: agent mode only lists models that support tools. Second, maxInputTokens: keep it at or below the real context of the upstream model, or long sessions fail at the provider. Third, requestHeaders: the X-LLMVault-Agent header labels the calls, so the vault’s activity log shows “vscode-copilot” instead of a generic client name.
Free ebook
Free AI Video, Generated Locally
Working scripts and measured benchmarks. Free.
No spam. Unsubscribe at any time.
Step 3: use the custom endpoint in Copilot agent mode
The model now appears in the chat model picker as “foundry-glm (LLM Vault)”. Furthermore, custom agents in .github/agents can pin it in their front matter. Their instructions and tools stay exactly as they were:
---
name: Code Reviewer
description: Reviews the pending change for bugs and security issues.
tools: ['codebase', 'search', 'problems', 'changes']
model: foundry-glm (LLM Vault)
---
Review only the pending changes. Never request or read API keys or .env files.
Model access is brokered by LLM Vault.
Notice the last instruction. It is not a security control on its own. Still, it reduces noise, because the agent stops trying to “help” by looking for credentials.
Step 4: approve the first request
The first chat message triggers a consent prompt in LLM Vault. It names the client, the agent label, the project and the model. Choose “Allow for this session”, and the following requests pass without prompts until you lock the vault.

If nobody answers within 90 seconds, the request fails with HTTP 403 and consent_timeout. Copilot then shows the error message from the gateway.
Control what a Copilot agent session costs
Agent mode is hungry. A single agent turn often sends the whole conversation, the tool schemas and file contents again. Therefore, a budget per client token matters more here than for a chat script.
Here is a worked example with the demo price list for foundry-glm: 2.00 USD per million input tokens and 8.00 USD per million output tokens. One agent turn with 40,000 input tokens and 2,000 output tokens costs 0.08 + 0.016 = 0.096 USD. Consequently, a daily budget of 10 USD allows roughly 100 such turns. After that, the gateway answers with HTTP 429 budget_exceeded, and Copilot stops instead of looping overnight.
Cached input changes the picture. In the same price list, cached input costs 0.50 USD per million tokens. If half of those 40,000 tokens hit the provider’s prompt cache, the turn drops to about 0.066 USD, which is 31% cheaper. LLM Vault records cached tokens separately, so the dashboard shows how much the cache actually saved.
In addition, a requests-per-minute limit catches tight loops early. I use 60 requests per minute for an interactive Copilot token and 120 for batch jobs. Both limits live on the token, so one runaway client cannot exhaust another client’s budget.
Pick models that handle tools well
Not every model is a good agent. For example, my 0.6-billion-parameter qwen3 test model did call read_file correctly, yet it is far too small for real refactoring. As a rule of thumb, use a large hosted model for agent mode and a small local model for quick questions. Fortunately, the vault lets you expose both under one Custom Endpoint group, each with its own maxInputTokens.
Also check the context window. A model alias with 32,000 tokens of context needs "maxInputTokens": 32000 or less. Otherwise, long agent sessions fail at the provider with a context-length error, and the gateway logs it as an upstream 400.
Performance of the Copilot custom endpoint
The gateway handles exactly the requests Copilot agent mode sends: Chat Completions with SSE streaming and streamed tool calls. I checked all three against a real local model, and every request also landed in the audit log.
The timing numbers are small enough to ignore in an IDE. On the Ollama run, the direct call took 1,087 ms and the same call through the vault took 1,094 ms, so the gateway added about 7 ms. On a slower llama.cpp run, the overhead was 42 ms on a 39,846 ms generation, which is 0.1%. By contrast, the human part dominates: the consent buttons arm after 1.2 s, and an unanswered prompt expires after 90 s.
| Request shape | Backend | Result |
|---|---|---|
| Chat Completions, non-streaming | Ollama qwen3:0.6b | HTTP 200, usage reported, model name rewritten to the alias |
| Chat Completions, streaming | Ollama qwen3:0.6b | HTTP 200, 199–307 SSE chunks, [DONE] |
Streaming with tools | Ollama qwen3:0.6b | Tool call read_file streamed back intact |
apiType: messages (Anthropic format) | Ollama | HTTP 200, usage reported |
Model discovery GET /v1/models | LLM Vault | Lists only aliases the token may use |
Troubleshooting the Copilot custom endpoint
The model does not appear in agent mode
Set "toolCalling": true on the model entry. VS Code hides models without tool calling from the agent picker.
“OpenAI Compatible” is missing from the provider list
That provider is deprecated. Use Custom Endpoint with the Chat Completions API type instead.
HTTP 401 invalid_token or token_expired
The token was mistyped, rotated or expired. Create a new one in LLM Vault and update the input variable in VS Code.
HTTP 429 budget_exceeded or rate_limited
The token hit its daily budget or its requests-per-minute limit. Raise the limit on the token, or wait until the next day for the daily budget to reset.
HTTP 423 vault_locked
The vault auto-locks after 15 minutes of inactivity by default. Unlock it, and Copilot can retry immediately.
Frequently asked questions
Does the Foundry key ever reach VS Code?
No. VS Code stores only the client token. The vault adds the provider key inside its own outbound HTTPS request.
Can I use a local Ollama or llama.cpp model in Copilot Chat this way?
Yes. Add the local server as a provider in LLM Vault, expose a model alias, and list that alias in the Custom Endpoint entry. Small models may handle tools poorly, so test agent mode before relying on it.
Does this work without a Copilot subscription?
The VS Code documentation says BYOK models work without a GitHub sign-in. In that case, built-in utility models are unavailable, and inline suggestions still require a sign-in.
Can the Copilot custom endpoint use the Anthropic Messages API?
Yes. Set apiType to messages and use http://127.0.0.1:8765/v1/messages. In LLM Vault, that works for aliases backed by Anthropic or Ollama.
How do I see what Copilot spent?
Open Activity in LLM Vault and filter by the client “VS Code – Code Reviewer”. Each request shows tokens, cost, consent type and whether usage was reported or estimated.
Summary
A VS Code Copilot custom endpoint is the cleanest way to bring your own models into Copilot Chat. Pointing it at LLM Vault keeps the provider key out of VS Code entirely. Use the Custom Endpoint provider, the full /v1/chat/completions URL, toolCalling: true and a scoped client token. In my tests, streaming and tool calls passed through the gateway intact. Moreover, every Copilot request now has a consent decision, a cost and an audit entry. For local backends and their measured overhead, continue with the local LLM gateway article.
LLM Vault itself is free and open source. The installer, the portable version and the example scripts from the videos are on the LLM Vault download page.
The download bundle vscode-copilot-custom-endpoint.zip contains the chatLanguageModels.json template, the custom agent file and the live test that checks streaming tool calls.
Companion code — the fragments above are the working parts: the Custom Endpoint JSON entry, the custom agent front matter that pins the vault model, and the curl check that confirms which aliases a token may use.
Free ebook
Free AI Video, Generated Locally
Run Wan 2.1 in ComfyUI on your own GPU — the scripts I use, measured times, sample clips. No cloud, no API keys.
No spam. Unsubscribe at any time.


The section on ‘Why use a VS Code Copilot custom endpoint at all’ is spot on—predictability and speed matter way more than hype in 2026 workflows. That’s why we’ve added Orylia for our image and video creation; you describe the scene in plain words and it picks an arena-ranked model, crafts a pro prompt, and shows the price before executing.