Local Models in GitHub Copilot
|
This content was generated with the assistance of AI and should be verified against the official documentation of each tool and framework before being relied on in production. This section’s bibliography lists the reference material consulted while preparing these pages. |
This page was written against VS Code with GitHub Copilot as documented on 2026-09-28 (the official Ollama
extension requires VS Code 1.127 or newer), GitHub Copilot CLI 1.0.89 and Ollama 0.34.4 (see the
Running LLMs Locally baseline). The VS Code and GitHub documentation was read from
their public source repositories (microsoft/vscode-docs, github/docs) on that date. BYOK in VS Code reached
general availability for Copilot Business and Enterprise in GitHub’s changelog of 2026-04-22, and GitHub’s
changelog of 2026-08-11 announced Ollama in Copilot for JetBrains; github.blog could not be reached from the
checking environment, so follow those two entries for the exact rollout details.
Copilot’s own models run in GitHub’s cloud. Bring your own key (BYOK) lets its chat and agent experience use a model you choose instead — a hosted provider under your own account, or a model on your own machine or server. Getting started with Copilot itself is on Getting Started with GitHub Copilot, and matching models to tasks on Choosing Models in Your Assistant; this page is about pointing Copilot at a local model.
(ask · agent)"] --> MP["Model picker"] MP -->|"GitHub-hosted"| GH["Copilot service"] MP -->|"BYOK: Ollama extension"| OLL["Ollama
localhost:11434"] MP -->|"BYOK: Custom Endpoint
chatLanguageModels.json"| CE{"apiType"} CE -->|"chat-completions"| V["vLLM / LM Studio / llama.cpp
/v1/chat/completions"] CE -->|"messages"| A["Anthropic-compatible
/v1/messages"] GH -.->|"always GitHub:
inline completions,
embeddings, semantic search"| VS
VS Code BYOK
Open the Language Models editor from the model picker’s gear icon (Manage Language Models), or run Chat: Manage Language Models from the Command Palette. It lists every model with its capabilities, context size and billing, lets you hide or pin models, and adds new ones in three ways:
-
Built-in providers — Azure, Anthropic, Gemini, OpenAI, OpenRouter, Hugging Face and others: Add Models, pick the provider, enter a group name and the API key or endpoint.
-
Model provider extensions — a Marketplace extension contributes the models; for example the Foundry Toolkit extension for Foundry Local and Foundry models, or the official Ollama extension below.
-
Custom Endpoint — any endpoint that speaks the Chat Completions, Responses or Anthropic Messages API: your own vLLM, LM Studio or llama.cpp server, or a gateway.
BYOK models work without signing in to GitHub and without a Copilot plan, which makes a fully offline setup possible with local models. For a model to appear in agent mode it must support tool calling. See VS Code — AI language models and the VS Code blog post on BYOK.
Ollama: the official extension
The built-in Ollama provider in VS Code is deprecated. Install the official Ollama extension (publisher
Ollama) instead, and remove any built-in Ollama provider configuration:
-
Install the extension from the Marketplace (VS Code 1.127 or newer; Ollama 0.17.6 or newer recommended).
-
Pull a model:
ollama pull qwen3.6(or DocsAssistant’sllama3.1:8bfor chat without agent tools). -
Open Chat, open the model picker and choose the model from the Ollama section. The extension discovers models from
http://127.0.0.1:11434.
VS Code may show a model’s maximum context while Ollama allocates less at run time — the silent-truncation pitfall. For agent use, set Ollama’s context length to at least 64k, reload the window and resend. If models do not appear, run Ollama: Refresh Models or Ollama: Diagnose Models. See Ollama — VS Code.
vLLM, LM Studio or llama.cpp: the Custom Endpoint provider
The Custom Endpoint provider replaces the deprecated "OpenAI Compatible" provider (the
github.copilot.chat.customOAIModels setting is deprecated too). Add Models > Custom Endpoint asks for a group
name, a display name, the API key and the API type, then opens chatLanguageModels.json. For the vLLM server on
vLLM & SGLang:
[
{
"name": "DocsAssistant GPU server",
"vendor": "customendpoint",
"apiKey": "${input:vllmApiKey}",
"apiType": "chat-completions",
"models": [
{
"id": "Qwen/Qwen3.6-27B",
"name": "Qwen3.6 27B (vLLM)",
"url": "http://gpu-server.internal:8000/v1/chat/completions",
"toolCalling": true,
"vision": false,
"maxInputTokens": 120000,
"maxOutputTokens": 8192
}
]
}
]
vendor must be customendpoint; ${input:vllmApiKey} keeps the key in VS Code’s secret storage rather than in
the file. Give the full URL including the API path to avoid ambiguity (without one, VS Code appends /v1 and the
path for the API type). maxInputTokens + maxOutputTokens is treated as the context window, so set them to what
the server allocates, not the model’s theoretical maximum. For LM Studio use
http://localhost:1234/v1/chat/completions; for an Anthropic-compatible server set "apiType": "messages" and a
…/v1/messages URL. For a gateway that expects a different auth header, requestHeaders can send
"Authorization": "Bearer ${apiKey}". See
VS Code — AI language models (Custom
Endpoint configuration reference).
The organisation policy and its limits
For Copilot Business and Enterprise users, the ability to use BYOK in the IDE is governed by the Copilot policy Bring Your Own Language Model Key in VS Code, which an organisation or enterprise administrator can disable in the Copilot policy settings on GitHub.com. GitHub distinguishes this local BYOK (keys stored client-side, models visible only to that user, usable in air-gapped environments) from enterprise BYOK, where owners add keys for custom models on GitHub’s side and users need a Copilot licence and internet access. See GitHub Docs — Bring your own key.
What BYOK does not cover matters as much:
-
Inline suggestions (code completions), semantic search and features that rely on embeddings still use the GitHub Copilot service and need a GitHub account; BYOK applies to chat, agents and utility tasks such as title generation (configurable through
chat.utilityModelandchat.utilitySmallModel). -
Usage of a provider-backed BYOK model is billed by that provider and does not count against Copilot request quotas.
-
The model must support tool calling to be offered in agent mode, and should stream.
A company whose reason for local models is that no code may leave the network therefore still has to decide about inline completions separately — turn them off, or use an open assistant whose autocomplete can be local (see Open Coding Assistants with Local Models).
JetBrains IDEs
Copilot for JetBrains IDEs supports local BYOK too; GitHub’s docs point to the 2025-09-11 changelog for BYOK in
JetBrains and Xcode, and the 2026-08-11 changelog added Ollama. JetBrains' own AI Assistant (a separate product
with a JetBrains AI subscription) also connects to Ollama: Set up Local Models > Third Party AI Providers >
Ollama, host URL http://localhost:11434. See
GitHub
changelog — Copilot Memory and Ollama in GitHub Copilot for JetBrains and
Ollama — JetBrains.
Copilot CLI BYOK
The Copilot CLI (copilot) reads its provider from environment variables. Three provider types are supported:
openai (the default — OpenAI, Ollama, vLLM, Foundry Local and any Chat Completions-compatible endpoint), azure
and anthropic.
| Variable | Required | Meaning |
|---|---|---|
|
yes |
Base URL of the provider’s API. |
|
yes |
Model to use (also settable with |
|
no |
|
|
no |
API key; not needed for an unauthenticated local Ollama. |
|
no |
Bearer token when API-key authentication is not used. |
|
no |
API protocol to use with the provider. |
|
no |
Token limits. |
|
no |
|
Against a local Ollama, as in GitHub’s documentation:
export COPILOT_PROVIDER_BASE_URL=http://localhost:11434
export COPILOT_MODEL=qwen3.6
export COPILOT_OFFLINE=true # optional: fully local, no calls to GitHub
copilot
Ollama can also write this configuration for you — ollama launch copilot — and its own integration page uses
COPILOT_PROVIDER_BASE_URL=http://localhost:11434/v1 together with COPILOT_PROVIDER_WIRE_API=responses
(Ollama’s Responses API); if the GitHub form above fails against your Ollama version, use that one.
copilot help providers prints more examples. Offline mode guarantees isolation only if
the provider is itself local: with a remote base URL, prompts and code still travel to that provider.
Model requirements: the model must support tool calling and streaming, or the CLI returns an error, and
GitHub recommends a context window of at least 128k tokens. With Ollama, remember to raise the context length
(OLLAMA_CONTEXT_LENGTH) to match — the default is far lower. See
GitHub Docs — Using your
own LLM models in GitHub Copilot CLI and Ollama — Copilot CLI.