opencode with LM Studio
Updated 27 May 2026
Run opencode using local models served by LM Studio.
Setup
1. Configure LM Studio
- Download and install LM Studio
- Load a model (e.g. Gemma 3n-e4b, Qwen 2.5 Coder 14b)
- Start the local server: Developer tab → Start Server (default:
http://127.0.0.1:1234) - Set context length: Settings → Model Defaults → Default Context Length → Model Maximum
2. Copy the config
cp opencode.json ~/.config/opencode/opencode.json
3. Run opencode
opencode
Once opencode is open, type /model to switch to a model prefixed with LM Studio (local).
Note: Running large models locally is often too slow for practical coding use. For a cheaper alternative to Claude/GPT, the DeepSeek API offers competitive performance at a fraction of the cost.
Config
opencode.json points opencode at the LM Studio server and registers local models. Edit the models block to add or remove models — the key must match the model ID shown in LM Studio.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lmstudio": {
"npm": "@ai-sdk/openai-compatible",
"name": "LM Studio (local)",
"options": {
"baseURL": "http://127.0.0.1:1234/v1"
},
"models": {
"google/gemma-3n-e4b": {
"name": "Gemma 3n-e4b (local)"
},
"qwen/qwen2.5-coder-14b" : {
"name": "Qwen 2.5 Coder 14b (local)"
}
}
}
}
}