Ollama (BYOM) for VS Code
⚠️ Deprecated
Ollama now publishes an official VS Code extension:
Ollama for VS Code (Ollama.ollama).
Install that instead — this extension is no longer maintained.
If both are installed, this extension deactivates itself and lets the
official one provide your Ollama models.
A Bring-Your-Own-Model provider that registers your local
Ollama server with VS Code's language model API
(vscode.lm). Once installed, every model you've pulled into Ollama shows up
in the GitHub Copilot Chat model picker — and is available to any extension
that calls vscode.lm.selectChatModels({ vendor: 'ollama' }).
Built against the
language-model provider contribution point
introduced in VS Code 1.104.
Requirements
- VS Code 1.104 or newer
- Ollama running (default
http://localhost:11434)
- At least one chat-capable model pulled (
ollama pull llama3.2)
Features
- Auto-discovery of installed models via Ollama's
/api/tags endpoint,
including capabilities (tools / vision / thinking) and context length
- Streaming chat completions over Ollama's native NDJSON API
- Tool / function calling for models that support it (native tool calls,
plus inline
<tool_call> XML format used by some model templates)
- Vision input for multimodal models that advertise the
vision capability
- Keeps reasoning out of the chat: native
thinking output is separated by
Ollama, and inline <think>...</think> traces are stripped
- Context window control via
ollama.numCtx (sent as num_ctx with each
request) and memory residency control via ollama.keepAlive
- Optional API key for remote Ollama servers behind an authenticating proxy
Settings
| Setting |
Default |
Description |
ollama.serverUrl |
http://localhost:11434 |
Base URL of the Ollama server |
ollama.apiKey |
"" |
Optional bearer token |
ollama.requestTimeout |
120000 |
Timeout (ms) for non-streaming calls |
ollama.maxOutputTokens |
8192 |
Maximum tokens to generate (num_predict) |
ollama.numCtx |
0 |
Context window per request (num_ctx); 0 = Ollama's default |
ollama.keepAlive |
"" |
How long models stay loaded ("10m", "24h", seconds, -1 forever, 0 unload); empty = Ollama default |
Commands
- Ollama: Refresh Available Models — re-fetches the model list
- Ollama: Check Server Connection — pings
/api/version and reports status
Development
npm install
npm run compile # one-shot bundle to dist/extension.js
npm run watch # incremental rebuild
npm run package:vsix # produce a .vsix to install locally
Press F5 in VS Code to launch an Extension Development Host with the
provider registered.
How it works
The extension registers a LanguageModelChatProvider under the vendor
identifier ollama (declared in package.json under
contributes.languageModelChatProviders):
vscode.lm.registerLanguageModelChatProvider('ollama', provider);
The provider implements three methods:
provideLanguageModelChatInformation — returns the list of models that
VS Code should show in the picker, built from /api/tags (capabilities,
context length) and /api/ps (loaded state, running context), with an
/api/show fallback for older Ollama versions
provideLanguageModelChatResponse — converts VS Code messages to Ollama's
native format, opens a streaming POST to /api/chat, and forwards
text + tool calls back to VS Code as LanguageModelTextPart /
LanguageModelToolCallPart
provideTokenCount — character-based heuristic (Ollama does not expose
a tokenizer endpoint)
License
MIT