Models & Local LLMs
Modern coding assistants are multi-model by design — GitHub Copilot, Anthropic’s Claude Code, Cursor, and others all let you swap the model behind the tool. Here’s how to pick a better-fitting model, and how to run a model entirely on your own machine, with a full walkthrough for a Windows 11 VirtualBox VM.
Switch the model used for chat and for completions; understand Bring Your Own Key (BYOK) and exactly which assistant features it covers; stand up a local LLM with Ollama or Foundry Local and connect it to an agentic assistant (GitHub Copilot here, but the same steps fit Claude Code, Cursor, and others) inside a Windows 11 / Oracle VirtualBox VM (including the host-GPU performance path); and run a coding assistant fully offline.
There are two distinct reasons to change the model behind your assistant. First, to pick a different hosted model for a task — a faster one for routine edits, a stronger reasoner for a gnarly refactor (say, swapping from a small model to a frontier reasoner like Anthropic’s Claude Opus, OpenAI’s top GPT, or Google’s Gemini Pro for a hard problem). Second, to bring your own model — including one running locally — for privacy, cost control, or fully offline work. We cover both across the four assistant tracks (GitHub Copilot, Claude, ChatGPT, and Gemini) and via the API, then go deep on the local case. The concrete VirtualBox walkthrough later uses GitHub Copilot as its worked example, but the same ideas apply to Claude Code, Cursor, and other agentic assistants.
The “brain” your helper uses can live far away on a giant computer, or right on your own laptop like a pet robot that works without the internet. Small brains fit on your laptop; the biggest brains live in the cloud.
Switching the hosted model
☺ Like you’re 10: Imagine your helper is a team of robots — a speedy one for easy chores and a really careful one for tricky puzzles. Here you learn how to tap the one you want, like choosing which friend to ask for help.
Two things matter here, and people constantly conflate them: the chat model and the completions model are set separately. Most assistants make this same split — the picker in your tool (Copilot’s dropdown, Claude’s model selector, the ChatGPT model menu, Gemini’s picker) chooses the chat/agent model, while inline completions are configured elsewhere.
The chat model
Every assistant surfaces a current-model dropdown — at the bottom of GitHub Copilot Chat, in Claude’s model selector, in the ChatGPT model menu, in Gemini’s picker — where you click and pick a model. Changing it mid-conversation switches which model answers your next prompt. Most tools now ship an Auto (or “smart routing”) option that evaluates your task (reasoning depth, code-gen complexity, bug-diagnosis difficulty, tool orchestration) against real-time model health and availability, then routes to the best fit — which both improves quality and reduces rate-limiting. Copilot’s Auto is a good example: it can hover over any response to show which model produced it, and lets you switch away from Auto to a specific model whenever you want. When routing is billed by whatever model it picks, it’s often capped to a cheaper tier (Copilot, for instance, currently caps Auto to models in the 0×–1× multiplier range).
The completions model
Inline “ghost text” completions use their own model, set independently from chat. In GitHub Copilot, open the Command Palette (Ctrl+Shift+P / ⌘⇧P) and run “GitHub Copilot: Change Completions Model.” The list is smaller and managed more tightly than chat — and changing your chat model has no effect on completions, which trips people up constantly. Whichever assistant you use, treat the completions model as a separate setting from the chat/agent model.
Bring Your Own Model (BYOK)
☺ Like you’re 10: It’s like bringing your own LEGO set to a friend’s house instead of only playing with theirs — you plug in a “brain” you already have a key for, and the app uses it just like its built-in ones.
“Bring Your Own Key” (BYOK) lets you connect a model your assistant doesn’t host — using your own API key or endpoint — and then use it from the same model picker. This is a general idea across tools: GitHub Copilot, Cursor, and other agentic editors all support it, and CLIs like Claude Code point at models via their own API keys. Typical BYOK providers you can wire in include Anthropic (Claude), OpenAI (GPT), Google (Gemini), Azure OpenAI, OpenRouter, and Hugging Face; you can run one locally with Ollama or Foundry Local; or point at a Custom Endpoint that speaks a standard API — Chat Completions, the OpenAI Responses API, or Anthropic’s Messages API (self-hosted or enterprise).
Under the hood this is just the model parameter: whichever assistant you use, BYOK sets the model (and base URL/key) the tool sends to a provider. In GitHub Copilot the entry point is one command — open the Command Palette and run “Chat: Manage Language Models” (or click the gear / Manage Models in the picker) to open the Language Models editor, add a provider, enter the key/endpoint, and choose which models appear. Other tools expose the same idea through a settings pane or a config file with base_url / api_key / model fields.
BYOK is powerful but it is usually not a drop-in replacement for everything a tool does — the exact boundary varies by assistant, so check the docs for yours. In GitHub Copilot, for instance, BYOK covers chat, tools, MCP servers, and utility tasks only: it does not power inline completions / Next Edit Suggestions, nor semantic search or anything using embeddings — those still require a GitHub account and Copilot. Across every tool, provider-backed BYOK usage is billed by that provider, not against the tool’s quota (local models cost only electricity). Since VS Code 1.122, Copilot BYOK even works without signing into GitHub and without a Copilot plan, which is what enables air-gapped use; other assistants similarly let a raw API key stand in for a subscription. On Business/Enterprise, an admin can disable BYOK via policy (in Copilot, the “Bring Your Own Language Model Key in VS Code” policy).
BYOK models work in agent workflows if the model supports the required capabilities — specifically tool calling (function calling) and streaming. A model without tool calling simply won’t appear in the agent-mode picker. So for agentic local work, choose tool-calling-capable models (see the table below).
Deep dive: a local LLM in Copilot on Windows 11 / VirtualBox
☺ Like you’re 10: A “virtual machine” is a pretend computer living inside your real one, like a dollhouse inside your house. We’ll put a little AI brain inside that dollhouse and plug it into your coding helper.
We’ll run Ollama (the simplest local-model runtime) inside a Windows 11 guest on Oracle VirtualBox, and wire it into your assistant’s chat. We use Copilot Chat here as the concrete example, but any BYOK-capable tool (Claude Code, Cursor, and others) connects to a local Ollama endpoint the same way. First, a reality check that will save you hours.
VirtualBox does not pass a real GPU through to the guest for compute (its “3D acceleration” is for display, not CUDA/ROCm). So a model running inside a VirtualBox VM uses the CPU only. Ollama needs a 64-bit CPU with AVX2 and about 8 GB RAM for a 7B model; on CPU expect roughly 3–8 tokens/sec on a 7B model — fine for learning, testing, and privacy, but slow for real work. Plan to use small, quantized models (3B–8B at Q4). If you have a GPU and want speed, skip ahead to running Ollama on the host.
Step 0 — Prepare the VM
In the VirtualBox settings for your Windows 11 guest (shut down first):
- Memory: give it at least 8 GB, ideally 12–16 GB. The model must fit in RAM with overhead (an 8B model at Q4 is ~5 GB).
- Processors: assign 4+ vCPUs (more cores help, with diminishing returns past ~8–12).
- Enable virtualization: System → Processor → enable Nested VT-x/AMD-V isn’t needed for Ollama, but ensure host hardware virtualization is on; System → Acceleration → enable Nested Paging. (VT-x/AMD-V must also be enabled in your host BIOS/UEFI.)
- Disk: models are large — keep 10–30 GB free in the guest.
- Guest Additions: install them for a smoother experience.
Ollama refuses to run without AVX2. Modern VirtualBox (7.x) on a modern host CPU passes AVX/AVX2 through to the guest, so this usually just works — but if Ollama later complains that the CPU lacks AVX/AVX2, that masked instruction set is the cause. Confirm your host CPU supports AVX2, keep VirtualBox up to date, and if the guest still can’t see it, use the host-Ollama path instead.
Step 1 — Install Ollama (in the VM)
Inside the Windows 11 guest, download the Windows installer from ollama.com and run it. Ollama installs a background service that listens on http://localhost:11434. Verify it’s live by opening that URL in the guest’s browser — you should see the plain-text response “Ollama is running.”
Step 2 — Pull a model
Open a terminal (PowerShell) in the guest and pull a small, capable model. For agent mode you need tool calling, so pick accordingly:
# A solid general/tool-calling pick (~4.7 GB): ollama pull llama3.1:8b # Smaller / code-focused options if RAM is tight: ollama pull qwen2.5-coder:7b ollama pull phi4 # Sanity-check it runs and responds: ollama run llama3.1:8b # (type a question; Ctrl+D to exit)
| Your VM RAM | Practical model size (Q4) | Good tool-calling choices for agent mode |
|---|---|---|
| 8 GB | ~7–8B | llama3.1:8b, qwen2.5-coder:7b, phi4 |
| 16 GB | ~13–14B | qwen2.5-coder:14b, mistral-nemo |
| 24 GB+ | ~32B (slow on CPU) | larger Qwen / Llama variants |
Step 3 — Install VS Code + the Copilot extension (in the VM)
Install VS Code and the GitHub Copilot extension inside the guest. Signing into GitHub is optional for BYOK chat, but sign in if you also want inline completions and semantic search (which BYOK does not provide).
Step 4 — Connect Ollama to Copilot
- Open the Command Palette and run “Chat: Manage Language Models” (or open the Chat model picker and click the Manage Models gear).
- Choose the Ollama provider.
- When prompted for the endpoint URL, enter the local Ollama address and confirm:
http://localhost:11434
- VS Code connects and auto-discovers the models you’ve pulled. Select the one(s) you want, and confirm.
- Open Copilot Chat, click the model picker, and select your Ollama model. Ask it something — the response is now generated entirely on your machine.
Your local model now powers chat, editing, and agent mode (if it supports tool calling). Inline completions still come from GitHub’s model, not Ollama — that’s the BYOK boundary. For a fully offline experience you can also point VS Code’s background “utility” models at your local model with the chat.utilityModel and chat.utilitySmallModel settings, so even chat titles and commit messages run locally.
Optional — the Copilot CLI with a local model
The terminal CLI supports the same BYOK idea via environment variables, and can run fully air-gapped:
$env:COPILOT_PROVIDER_BASE_URL = "http://localhost:11434" $env:COPILOT_MODEL = "llama3.1:8b" $env:COPILOT_OFFLINE = "true" # never contact GitHub's servers copilot # start the CLI using your local model
Models used this way must support tool calling and streaming, or the CLI returns an error rather than silently falling back to a hosted model.
Performance path: run Ollama on the host (with the GPU)
☺ Like you’re 10: The dollhouse computer can’t reach the fast graphics chip, so instead we keep the AI brain out in the big house where the fast chip lives, and let the dollhouse phone it up when it needs an answer.
Because the VM is CPU-bound, the fastest setup is to run Ollama on the Windows host (where it can use your GPU) and connect to it from the VM. Two changes make this work:
- Make the host’s Ollama listen beyond localhost. By default Ollama binds to
127.0.0.1, which a VM can’t reach. On the host, set the environment variableOLLAMA_HOST=0.0.0.0(System Properties → Environment Variables) and restart Ollama, so it listens on all interfaces. - Give the VM a network path to the host. In VirtualBox, use a Host-only adapter (the host is typically reachable at something like
192.168.56.1) or a Bridged adapter (the VM joins your LAN). Find the host’s IP on that network withipconfigon the host.
Then in the VM’s VS Code, add the Ollama provider exactly as in Step 4, but enter the host’s IP instead of localhost:
http://192.168.56.1:11434 # use your host's actual IP
Ollama has no authentication by default. Setting OLLAMA_HOST=0.0.0.0 exposes it to every machine that can reach that interface. Prefer a Host-only adapter (visible only to your VMs), or restrict it to a trusted private network — never bind it to 0.0.0.0 on an untrusted or public network.
Another local runtime: Microsoft Foundry Local
☺ Like you’re 10: Ollama is one brand of oven for “cooking” AI answers on your own computer — Foundry Local is a different brand that plugs into the same kitchen, and it can use extra speed chips your computer might have.
Ollama isn’t the only way to run models locally. Foundry Local (Microsoft’s on-device runtime, formerly Azure AI Foundry Local, now generally available) is a strong alternative — and it plugs into Copilot the same way. It runs models entirely on your device with no Azure account, no per-token cost, and offline support, and it exposes an OpenAI-compatible local endpoint so any tool that speaks the OpenAI API can use it.
| Ollama | Foundry Local | |
|---|---|---|
| Engine | llama.cpp / GGUF | ONNX Runtime |
| Acceleration | CPU, NVIDIA/AMD/Apple GPU | Automatic across CPU / GPU / NPU (picks the best execution provider) |
| Catalog | Huge community library | Curated, quantized set (Phi-4, Qwen 2.5 incl. coder, Mistral, DeepSeek, GPT-OSS, Whisper) |
| Install (Windows) | Installer from ollama.com | winget install Microsoft.FoundryLocal |
| Endpoint | Fixed localhost:11434 | Dynamic — find it with foundry service status |
Quickstart in the guest: install it, list and run a model (the runtime downloads and loads it, then serves it on the local OpenAI-compatible endpoint):
winget install Microsoft.FoundryLocal # one-line install foundry model list # see the curated catalog foundry model run phi-4 # download + run + interactive chat # or a code/tool-calling model: foundry model run qwen2.5-coder foundry service status # shows the local endpoint URL
To use it in Copilot, add it through Chat: Manage Language Models — pick the Foundry Local provider, or, because the endpoint is OpenAI-compatible, use the Custom Endpoint provider pointed at the URL from foundry service status. From there it behaves like any BYOK model (chat, tools, MCP, agent mode if the model supports tool calling).
Foundry Local’s headline advantage is NPU/GPU acceleration — but a VirtualBox VM can’t reach the NPU or GPU, so inside the VM it falls back to CPU, just like Ollama. Foundry Local shines on real hardware: a bare-metal Windows 11 machine, especially a Copilot+ PC with an NPU, or run it on the host and connect from the VM via the OpenAI-compatible endpoint.
Going fully offline (air-gapped)
☺ Like you’re 10: This is teaching your helper to work with the internet unplugged, like playing a board game that doesn’t need Wi-Fi — everything happens right there on your own machine.
Pair a local runtime with your editor’s offline support and you get a coding assistant that never touches the network. Since VS Code 1.122, BYOK works without signing into GitHub — once you’ve configured at least one local model, the Chat view becomes available and sign-in prompts are suppressed, so chat, tools, and MCP servers all work in an air-gapped environment.
| Works fully offline (with a local model) | Still needs GitHub sign-in + Copilot |
|---|---|
| Chat, inline-chat editing, and agent mode (tool-calling models) | Inline completions & Next Edit Suggestions |
| Tools and MCP servers | Semantic search (@workspace codebase search) |
Utility tasks — set chat.utilityModel and chat.utilitySmallModel to a local model so titles & commit messages run locally too | Anything that relies on embeddings |
An air-gapped checklist: (1) install Ollama or Foundry Local and pull a tool-calling model; (2) in VS Code, add it via Chat: Manage Language Models; (3) point the two chat.utility* settings at a local model; (4) accept that completions and semantic search won’t be available offline. For the terminal, the Copilot CLI goes fully air-gapped with COPILOT_OFFLINE=true plus a local provider — it disables telemetry and only talks to your local model.
The exact same local runtimes — Ollama and Foundry Local — drop into many other tools (Cline, Continue, Aider, Zed, and more). The local-LLM skill you just learned is portable across the whole ecosystem, which is the subject of the next topic.
Local vs. hosted — choosing well
☺ Like you’re 10: A brain on your laptop keeps secrets at home and works with no internet, but a giant brain in the cloud is usually smarter and faster — so you pick the right one for the job, like choosing a bike for a short trip and a car for a long one.
Local models are excellent for privacy (code never leaves your machine), cost (no premium requests), offline/air-gapped work, and experimentation with open-weight models. The trade-offs are real, though: open models are generally less capable than frontier hosted models like Anthropic’s Claude, OpenAI’s GPT, or Google’s Gemini, CPU inference in a VM is slow, and you lose completions and semantic search. A common pattern is to keep your assistant on a strong hosted model (Copilot’s Auto, Claude in Claude Code, a top GPT in ChatGPT, Gemini Pro — or the right model value over the API) for daily speed and quality, and switch to a local model for sensitive code, offline sessions, or when you’ve hit your request budget.
Foxy: If the cloud brain is smarter, why would I ever pick the little one on my laptop?
Professor Owl: Because “best” depends on the job. A big hosted model is fast and clever, but a local model keeps your code at home and works with the internet unplugged.
Cami the Chameleon: So I match the brain to the task — a quick cloud model for easy edits, and the local one when the code is secret or the Wi-Fi’s gone.
Sol the Sloth: And don’t rush me — for a tricky refactor, a slow, careful model that checks its steps often beats a fast one that guesses.
Foxy: Right pick for the right moment. I’ll run llama3.1:8b at home and save the giant brain for the hard puzzles!
In a Windows 11 VirtualBox VM with ≥8 GB RAM: install Ollama, ollama pull llama3.1:8b, verify http://localhost:11434 shows “Ollama is running,” then connect it in VS Code via Chat: Manage Language Models → Ollama → http://localhost:11434. Ask the local model to explain a file in chat, then try a small agent-mode task and notice whether it can call tools. Bonus: if it’s too slow, move Ollama to the host with OLLAMA_HOST=0.0.0.0 and reconnect using the host’s IP.
(1) Which two model settings are configured separately, and which command changes the completions one? (2) Name three Copilot features BYOK does not cover. (3) Why does a model inside a VirtualBox VM run on CPU, and what does that imply for model size? (4) What two changes let a VM use an Ollama instance running on the host? (5) What capability must a local model have to work in agent mode? (6) What does Foundry Local use for acceleration that Ollama doesn’t emphasize, and why doesn’t it help inside a VM? (7) Which two Copilot features can’t run offline even with a local model?
Check your answers
- Chat vs. completions model: The chat/agent model and the inline-completions model are set separately — changing your chat model has no effect on completions. In Copilot you change the completions one via the Command Palette command “GitHub Copilot: Change Completions Model.”
- What BYOK doesn’t cover: In Copilot, BYOK powers chat, tools, and MCP servers only — it does not drive inline completions / Next Edit Suggestions, semantic search (
@workspace), or anything using embeddings. Those still require a GitHub account and Copilot. - CPU-only in a VM: VirtualBox doesn’t pass a real GPU through to the guest for compute (its “3D acceleration” is display-only, not CUDA/ROCm), so the model runs on CPU. That means you should plan on small, quantized models — roughly 3B–8B at Q4.
- Reaching the host’s Ollama: Set
OLLAMA_HOST=0.0.0.0on the host and restart Ollama so it listens beyond localhost, and give the VM a network path via a Host-only (or Bridged) adapter. Then point VS Code at the host’s IP, e.g.http://192.168.56.1:11434. - Requirement for agent mode: The model must support tool calling (function calling) — and streaming — or it won’t appear in the agent-mode picker.
- Foundry Local’s acceleration: Foundry Local (on ONNX Runtime) automatically uses NPU/GPU acceleration across CPU/GPU/NPU, which Ollama doesn’t emphasize. It doesn’t help inside a VirtualBox VM because the VM can’t reach the NPU or GPU, so it falls back to CPU just like Ollama.
- Not available offline: Inline completions (and Next Edit Suggestions) and semantic search — plus anything relying on embeddings — still need GitHub sign-in and Copilot, so they can’t run offline even with a local model.