opencode-local-ollama
v0.1.0
Published
Native Ollama model discovery for OpenCode.
Maintainers
Readme
OpenCode Local Ollama Provider
Native Ollama model discovery for OpenCode.
opencode-local-ollama is a native OpenCode provider plugin. It discovers the models you already have in Ollama and registers them as ollama/<model> in OpenCode, so they show up in /models without a manual sync step.
Why
Existing Ollama/OpenCode helpers usually generate config files or require a separate sync command. This plugin runs during OpenCode startup and uses OpenCode's provider hook directly.
Features
- Discovers local models from Ollama on OpenCode boot.
- Uses
/api/tagsto list local models. - Uses
/api/showfor exact model metadata. - Registers models under the
ollamaprovider. - Uses Ollama's OpenAI-compatible endpoint at
/v1. - Respects
OLLAMA_HOSTand plugin options. - Model agnostic: no hardcoded Qwen, Llama, Gemma, Mistral, or DeepSeek rules.
- Strict by default: no guessed capabilities.
- Skips non-chat models when Ollama does not report
completionorchatcapability.
Install
npm install -g opencode-local-ollamaThen add it to your OpenCode config:
{
"plugin": ["opencode-local-ollama"]
}Restart OpenCode and run:
/modelsYou should see entries like:
ollama/llama3.2:latest
ollama/gemma4:31b
ollama/qwen3.5:35bUsage
Pull a model with Ollama:
ollama pull llama3.2Restart OpenCode. The model becomes available as:
ollama/llama3.2:latestConfiguration
Default behavior uses OLLAMA_HOST if set, otherwise http://localhost:11434.
{
"plugin": [
[
"opencode-local-ollama",
{
"host": "http://localhost:11434"
}
]
]
}Options:
| Option | Default | Description |
| --- | --- | --- |
| host | OLLAMA_HOST or http://localhost:11434 | Ollama API host. May include a proxy path. |
| baseURL | unset | Alias for host. If it ends in /v1, the plugin derives the Ollama API base from it. |
| providerID | ollama | OpenCode provider ID to register. |
| timeout | 5000 | Ollama request timeout in milliseconds. |
| context | 4096 | Explicit context limit to expose to OpenCode. |
| output | 4096 | Explicit output token limit to expose to OpenCode. |
| useModelInfoContext | false | Use GGUF architecture context from model_info when num_ctx is not configured. Disabled by default because it can be larger than the runtime context Ollama actually uses. |
Capability Mapping
The plugin treats Ollama as the source of truth.
| Ollama capability | OpenCode mapping |
| --- | --- |
| completion or chat | text input/output model |
| tools | tool calling enabled |
| vision or image | image attachments enabled |
| thinking or reasoning | reasoning enabled |
If Ollama does not report a capability, this plugin does not invent it from the model name.
Context Limits
Ollama model metadata can report very large architecture context windows, such as 131072, while runtime num_ctx may still be much smaller. To avoid overfilling local models, this plugin uses this priority:
- Explicit plugin
contextoption num_ctxfrom/api/showparameters or Modelfilemodel_info.*.context_lengthonly whenuseModelInfoContextistrue- Safe default
4096
Development
npm install
npm test
npm run typecheck
npm run buildLicense
MIT
