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

With Ollama

  1. 01Start Ollama, for example with ollama serve.
  2. 02Pull a model, such as ollama pull qwen3:8b.
  3. 03That's all OpenCode needs. It looks for Ollama at http://127.0.0.1:11434 and adds its models to the model list without an account connection. Embedding-only models are left out.
Terminal
ollama serve
ollama pull qwen3:8b

With LM Studio

  1. 01Download a model in LM Studio.
  2. 02Start LM Studio's local server. Its default address is http://127.0.0.1:1234/v1.
  3. 03OpenCode discovers LM Studio's language models from that server.

Pick the model in Sidecar

  1. 01Click the Sidecar icon in the Activity Bar.
  2. 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.
  3. 03Open the model menu in the message box and pick the local model. Models are listed by provider.
  4. 04To preselect it in new workspaces, set opencodeSidecar.defaultModel to its providerID/modelID, such as ollama/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.

opencode.json
{
  "$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.