GitHub Copilot BYOK (VS Code) with a local model: setup for Ollama, LM Studio or llama.cpp
Bring Your Own Key (BYOK) in VS Code lets the built-in chat and agent use models you supply, including local ones, without a Copilot plan or GitHub sign-in. Ollama is connected through the official Ollama extension, and other local servers through the Custom Endpoint provider. It suits VS Code users who want to keep the native chat UI; inline suggestions, semantic search and embeddings still need GitHub's service.
At a glance
- Type
- vscode-chat
- Licence
- Not verified
- Latest release
- Not verified
- Status
- Maintained
- Local backends
- ollama, openai-compatible, anthropic-compatible
- Needs native tool calling
- Yes
- MCP support
- Not verified
- Recommended minimum context
- Not stated in its docs
- Start-up prompt
- Not measured
- GitHub stars
- Not verified
How to set it up with a local model
Pick your backend. Each command has its own Copy button. Where a step uses an example model, swap in the one you run; the table below lists the ones that fit your machine.
Install it (Ollama extension (VS Code CLI)):
code --install-extension Ollama.ollamaInstall the official Ollama extension. The built-in Ollama provider in VS Code is deprecated.
code --install-extension Ollama.ollamaPull a model that supports tool calling (replace qwen3-coder:30b with your choice).
ollama pull qwen3-coder:30bRaise Ollama's context window (the Ollama VS Code guide asks for at least 64K); or set the context slider in the Ollama app's Settings instead.
OLLAMA_CONTEXT_LENGTH=65536 ollama serveReload the VS Code window, open Chat and choose the model from the Ollama section of the model picker.
Check that it works
Open Chat in agent mode, pick the local model and ask it to read a file. If an Ollama model is missing, run Ollama: Refresh Models and Ollama: Diagnose Models from the Command Palette.
ollama listWhich local models fit, by machine
Checked by this site's engine at the context GitHub Copilot BYOK needs, with 32 GB of system RAM for MoE offload. A Mac counts three quarters of unified memory as usable.
| Machine | Model | Quant | Context | Fit | Ollama |
|---|---|---|---|---|---|
| 12 GB GPU | Qwen 3.5 9B | Q4_K_M | 32,768 | Comfortable (7.4 GB of 12 GB) | qwen3.5:9b |
| Qwen 3.6 35B-A3B | Q4_K_M | 32,768 | With CPU offload (MoE) (22.7 GB of 12 GB) | qwen3.6:35b-a3b | |
| 16 GB GPU | Qwen 3.5 9B | Q4_K_M | 32,768 | Comfortable (7.4 GB of 16 GB) | qwen3.5:9b |
| Qwen 3.6 35B-A3B | Q4_K_M | 32,768 | With CPU offload (MoE) (22.7 GB of 16 GB) | qwen3.6:35b-a3b | |
| 24 GB GPU | Qwen3.8 27B | Q4_K_M | 32,768 | Comfortable (19.9 GB of 24 GB) | qwen3.8:27b |
| Qwen 3.6 27B | Q4_K_M | 32,768 | Comfortable (19.9 GB of 24 GB) | qwen3.6:27b | |
| Devstral Small 2 24B | Q4_K_M | 32,768 | Comfortable (20.7 GB of 24 GB) | devstral-small-2:24b | |
| Qwen 3.6 35B-A3B | Q4_K_M | 65,536 | Tight (23.3 GB of 24 GB) | qwen3.6:35b-a3b | |
| 32 GB GPU | Qwen3.8 27B | Q4_K_M | 32,768 | Comfortable (19.9 GB of 32 GB) | qwen3.8:27b |
| Qwen 3.6 27B | Q4_K_M | 32,768 | Comfortable (19.9 GB of 32 GB) | qwen3.6:27b | |
| Devstral Small 2 24B | Q4_K_M | 32,768 | Comfortable (20.7 GB of 32 GB) | devstral-small-2:24b | |
| Qwen 3.6 35B-A3B | Q4_K_M | 65,536 | Comfortable (23.3 GB of 32 GB) | qwen3.6:35b-a3b | |
| Qwen3-Coder 30B-A3B (MoE) | Q4_K_M | 65,536 | Comfortable (25.7 GB of 32 GB) | qwen3-coder:30b | |
| Mac, 64 GB | Qwen 3.6 35B-A3B | Q8_0 | 131,072 | Comfortable (40.7 GB of 48 GB) | — |
Your exact machine: filter the matrix or check any model in the analyzer.
Common problems with local models
- Agent mode only lists models that support tool calling; for a Custom Endpoint model, set "toolCalling": true.
- VS Code may show a model's maximum context while Ollama allocates less at runtime; raise Ollama's context (64K or more) and reload the window.
- Title generation, commit messages and other utility features keep using GitHub's models unless you point chat.utilityModel and chat.utilitySmallModel at a local model.
- Copilot Business and Enterprise users need an admin to enable the Bring Your Own Language Model Key policy, and local models cannot drive inline suggestions.
Other coding agents
How they rank for local models: the best agent harness for local LLMs.
Sources (9), checked 2026-10-20
- code.visualstudio.com/docs/copilot/customization/language-models
- docs.ollama.com/integrations/vscode
- code.visualstudio.com/docs/configure/extensions/extension-marketplace
- docs.ollama.com/context-length
- lmstudio.ai/docs/cli/local-models/get
- lmstudio.ai/docs/cli/local-models/load
- lmstudio.ai/docs/developer/core/server
- lmstudio.ai/docs/developer/openai-compat
- github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md