This post goes over how to set up OpenCode with Ollama.
Install
brew install ollama
brew install opencode
Ollama
Start the server in a separate terminal:
ollama serve
Install gemma4:
ollama pull gemma4
Confirm it’s downloaded:
ollama ls gemma4
You should see:
NAME ID SIZE MODIFIED
gemma4:latest c6eb396dbd59 9.6 GB 5 seconds ago
Check the model’s context length:
ollama show gemma4
You should see:
Model
architecture gemma4
parameters 8.0B
context length 131072
embedding length 2560
quantization Q4_K_M
requires 0.20.0
Restart the server with the context length (to maximize memory):
OLLAMA_CONTEXT_LENGTH=131072 ollama serve
Check the performance of the model:
ollama run gemma4 "ping" && ollama ps
OpenCode
Launch opencode with gemma4:
ollama launch opencode --model gemma4