Use Ollama local models with OpenCode
OpenCode and Ollama each publish an opencode.json example. The local base URL matches. The display name and the example model id do not. Both are quoted here.
OpenCode’s example
File opencode.json. The provider id in the example is ollama, and OpenCode says that id can be any string you want. npm is @ai-sdk/openai-compatible. name is “Ollama (local)”. options.baseURL is http://localhost:11434/v1. The example model id is llama2 with name “Llama 2”. OpenCode says the model name is what shows in the model list.
If tool calls are not working, OpenCode says to raise num_ctx in Ollama, starting around 16k–32k. OpenCode also says Ollama can configure itself and links Ollama’s integration page.
Ollama’s example
- name is “Ollama”, not “Ollama (local)”.
- options.baseURL is the same http://localhost:11434/v1.
- The example model id is qwen3.5 with name qwen3.5.
- Command: ollama launch opencode. Ollama says this starts OpenCode with an inline config and does not overwrite ~/.config/opencode/opencode.json.
- Ollama says OpenCode requires a context length of 64k or higher, and to choose a model and set a 64k+ context window.
The Ollama docs homepage fetched the same day did not contain port 11434. The URL above is from the two integration pages.
Other notes
- Use OpenRouter with Cline
- Use Groq with Cline and OpenCode
- Prices the docs attach to coding models
- Token price calculator
- LLM APIs category list
- Free LLM API limits
Sources
Last checked 2026-10-22.