Assuming you have ollama installed and a local model already downloaded, install opencode following steps here.
Create an opencode.json with config pointing to your downloaded model:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"gemma4": {
"name": "gemma4:e4b"
}
}
}
}
}
Start opencode from ollama with:
ollama launch opencode
Scroll down to other models and select the model you configured above.
