Use OpenCode with local models in VS Code
OpenCode finds Ollama and LM Studio on your machine by itself. Start one, pull a model, and pick it in Sidecar's model menu. The model needs no account or API key.
Updated
What you need
- VS Code 1.95 or newer, or Cursor, Windsurf or VSCodium.
- OpenCode 2.x with its background service.
- Sidecar for OpenCode, from the Marketplace or Open VSX.
- Ollama or LM Studio.
With Ollama
- 01Start Ollama, for example with
ollama serve. - 02Pull a model, such as
ollama pull qwen3:8b. - 03That's all OpenCode needs. It looks for Ollama at
http://127.0.0.1:11434and adds its models to the model list without an account connection. Embedding-only models are left out.
ollama serve
ollama pull qwen3:8bWith LM Studio
- 01Download a model in LM Studio.
- 02Start LM Studio's local server. Its default address is
http://127.0.0.1:1234/v1. - 03OpenCode discovers LM Studio's language models from that server.
Pick the model in Sidecar
- 01Click the Sidecar icon in the Activity Bar.
- 02If you started Ollama or LM Studio after Sidecar connected, run Sidecar: Refresh Connection from the Command Palette. It checks OpenCode's providers and models again.
- 03Open the model menu in the message box and pick the local model. Models are listed by provider.
- 04To preselect it in new workspaces, set
opencodeSidecar.defaultModelto itsproviderID/modelID, such asollama/qwen3:8b.
Ollama or LM Studio on another machine
Point OpenCode at the server in opencode.json with settings.baseURL, and include /v1 at the end. The global file is ~/.config/opencode/opencode.json; a project can have its own opencode.json in its root.
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"ollama": {
"settings": { "baseURL": "http://gpu-box:11434/v1" }
},
"lmstudio": {
"settings": { "baseURL": "http://gpu-box:1234/v1" }
}
}
}For another OpenAI-compatible runtime, OpenCode's provider docs describe a custom provider where you list its models yourself.
What's different with a local model
- Budget Guard counts steps. If OpenCode reports no cost for a model, only the step limit applies.
- No prompt-cache clock. It shows only when a step reports prompt-cache tokens, which most local models don't.
- Images. Sidecar tells you when the model you picked doesn't list image input in OpenCode.
- Tool calls matter. The agent works by calling tools to read, search, edit and run commands, so pick a model that handles tool calls well.
- Where requests go. Sidecar talks only to your local OpenCode service, and OpenCode sends the model's requests to the Ollama or LM Studio server you use.