Setup guide - Documented by Ollama
Use Ollama in OpenCode
OpenCode talks to Ollama through the @ai-sdk/openai-compatible provider pointed at http://localhost:11434/v1, or via ollama launch opencode, which injects an inline config for the chosen model.
Last verified 6 steps2 official sources
Steps
- Step 1.
Quick start.
Terminalollama launch opencode - Step 2.
Manual setup step 1: install OpenCode (macOS / Linux).
Terminalcurl -fsSL https://opencode.ai/install | bash - Step 3.
Manual setup step 1 (Windows).
Terminalnpm install -g opencode-ai - Step 4.
Step 2: add an Ollama provider to opencode.json.
JSON{ "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "qwen3.5": { "name": "qwen3.5" } } } } } - Step 5.
Step 3: run OpenCode.
Terminalopencode - Step 6.
Configure OpenCode with Ollama without starting an interactive session.
Terminalollama launch opencode --config
Caveats
- Steps come from Ollama's OpenCode integration page; OpenCode's own provider docs were not read today.
- OpenCode requires a context length of 64k or higher per Ollama.
ollama launch opencodedoes not overwrite ~/.config/opencode/opencode.json; models defined only in opencode.json do not appear in theollama launchmodel picker.
More setup guides
Same tool, other providers
Related reading
- Ollama Decision Models: Run Nimble Locally with --askOllama 0.40.4 runs decision models locally: ollama run nimble --ask answers yes/no, label and score questions with probabilities. Commands and limits.
- Ollama 0.40 on Mac: MLX by Default, Disk Space DoubledOllama 0.40 runs supported models on MLX on Apple Silicon and keeps a backup copy of each model you load. What it costs in disk, what is fixed, and the cleanup.
- GitHub Copilot CLI With Ollama: Local Models and the New SandboxCopilot CLI 1.0.94 finds local Ollama models from /model and ships an OS-level sandbox. Setup, the 4k context trap, and why local is not offline.
- Hermes Agent Guide (2026): What It Is, Local Setup With Ollama, Skills, and Hermes vs OpenClawHermes Agent is Nous Research's open-source, self-improving AI agent. Run it locally with Ollama, see how its skills system works, and compare it with OpenClaw.
- What Is OpenClaw? Setup, Skills, MCP Server, Claude Code, and Ollama (2026 Guide)What is OpenClaw? A self-hosted personal AI agent you reach through chat apps. Install, skills and ClawHub, its MCP server, Claude Code use, and Ollama models.
- GitHub Copilot for JetBrains Gains Persistent Memory and Ollama BYOKGitHub Copilot for JetBrains adds memory across chat sessions, Ollama as a BYOK provider, and enterprise settings for MCP access. What each feature does.
FAQ
How do I use Ollama in OpenCode?
OpenCode talks to Ollama through the @ai-sdk/openai-compatible provider pointed at http://localhost:11434/v1, or via ollama launch opencode, which injects an inline config for the chosen model.
Which Ollama model ids work in OpenCode?
The official docs read for this guide list qwen3.5. Requests go to http://localhost:11434/v1.
Is this an official Ollama and OpenCode setup?
Ollama documents this setup in its own docs. It was last checked against 2 official pages on October 17, 2026.
Sources
Last verified against 2 official pages.
- docs.ollama.comhttps://docs.ollama.com/integrations/opencode
- raw.githubusercontent.comhttps://raw.githubusercontent.com/ollama/ollama/main/docs/integrations/opencode.mdx
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.