opencode-local-vision
v0.1.1
Published
Private local image understanding for text-only OpenCode models through Ollama
Readme
OpenCode Local Vision
Keep OpenCode's main model text-only while pasted images are described by a local Ollama vision model.
Paste image into OpenCode
|
v
OpenCode message-transform hook
|
+--> localhost:11434/api/chat --> local vision model
|
v
Raw image parts removed
|
v
Text description sent to the main modelThe plugin does not create an OpenCode sub-session. Ollama receives only a short safety prompt, the current user question, and the image bytes.
Compatibility
- OpenCode
1.18.x(V1 plugin API) - Ollama with any installed model whose
/api/showresponse reports thevisioncapability - macOS, Linux, and Windows
- PNG, JPEG, and WebP; up to 4 images and 25 MB total per message
OpenCode's message transform hook is experimental. OpenCode V2 uses a different plugin API and is not supported by this release.
Quick start
Install Ollama.
Pull a vision model. The team default below is small enough for most developer machines:
ollama pull qwen2.5vl:3bAdd the pinned npm package to
opencode.jsonc:{ "plugin": ["[email protected]"] }Remove other image-routing plugins, including
@showlotus/opencode-image-vision, and oldfile:///.../local-vision.mjsentries fromopencode.jsonc.Restart OpenCode. Paste an image and ask a question normally. There is no command or model switch.
Do not put a GitHub or raw-file URL in OpenCode's plugin setting. OpenCode installs the npm package into its cache automatically. Keep unrelated plugins unchanged.
The plugin automatically selects the first installed model that reports vision. To standardize a team or choose among multiple local models, set:
export LOCAL_VISION_MODEL=qwen2.5vl:3bWindows PowerShell:
setx LOCAL_VISION_MODEL "qwen2.5vl:3b"Restart OpenCode after changing environment variables.
Model choices
The plugin has no model-name allowlist. These are examples, not dependencies:
| Use case | Ollama model |
| --- | --- |
| Team default | qwen2.5vl:3b |
| Low-memory machines | qwen3-vl:2b |
| General vision | gemma3:4b |
| MiniCPM-V | any installed MiniCPM-V tag reporting vision |
Verify a model before rollout:
ollama show qwen2.5vl:3b
curl -s http://127.0.0.1:11434/api/show \
-d '{"model":"qwen2.5vl:3b"}'The JSON response should include "vision" in capabilities.
Configuration
| Variable | Default | Purpose |
| --- | --- | --- |
| LOCAL_VISION_MODEL | auto-detect | Exact Ollama model tag |
| LOCAL_VISION_BASE_URL | http://127.0.0.1:11434 | Ollama endpoint; loopback HTTP only |
| LOCAL_VISION_TIMEOUT_MS | 120000 | Request timeout |
| LOCAL_VISION_MAX_TOKENS | 2048 | Maximum description tokens |
The endpoint intentionally rejects remote hosts and HTTPS proxies. This prevents configuration drift from turning a local-only workflow into a remote upload path.
Privacy behavior
- Every image attachment in the assembled conversation, including historical user messages, is replaced before the main-model request.
- Ollama failures produce the fixed text
LOCAL_VISION_ERROR; raw images are still removed. - Local file paths and Ollama response bodies are logged locally but are not included in the main-model prompt.
- Image text is marked as untrusted evidence in both the vision prompt and the main-model system context.
- Other OpenCode plugins run in plugin order. Remove other image-routing plugins; a plugin that runs earlier can inspect an image before this plugin removes it.
Team rollout
Use the copyable AI setup prompt and rollout checklist in docs/team-rollout.md.
Update and uninstall
Update by changing the pinned npm version in opencode.jsonc and restarting OpenCode.
Uninstall by removing opencode-local-vision from the plugin array and restarting OpenCode.
Development
npm test
npm run check
npm pack --dry-runNo runtime dependencies are required.
