Skip to content

Commit 2000a12

Browse files
feat(posts): update "How to use OpenCode with Ollama"
Post: 2026-02-04-opencode-ollama-setup.md
1 parent 016a574 commit 2000a12

1 file changed

Lines changed: 54 additions & 41 deletions

File tree

Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,89 @@
11
---
22
layout: post
3-
title: How to set up OpenCode with Ollama
3+
title: How to use OpenCode with Ollama
44
date: 2026-02-04 14:22:24
5+
updated: 2026-05-02 19:41:41
56
excerpt: How to set up OpenCode IDE with an Ollama coding model.
67
categories: opencode ollama ai
78
---
89

910
This post goes over how to set up [OpenCode](https://opencode.ai/) with [Ollama](https://ollama.com/).
1011

11-
## Prerequisites
12+
## Install
1213

13-
[OpenCode](https://opencode.ai/):
14+
[Ollama](https://ollama.com/):
1415

1516
```sh
16-
brew install opencode
17+
brew install ollama
1718
```
1819

19-
[Ollama](https://ollama.com/):
20+
[OpenCode](https://opencode.ai/):
2021

2122
```sh
22-
brew install ollama
23+
brew install opencode
2324
```
2425

2526
## Ollama
2627

27-
Start Ollama:
28+
Start the server in a separate terminal:
2829

2930
```sh
3031
ollama serve
3132
```
3233

33-
Ollama by default uses a [context window size](https://docs.ollama.com/context-length) of 4096 tokens. For tasks that require large context like web search, agents, and coding tools, set the [context window](https://docs.ollama.com/faq#how-can-i-specify-the-context-window-size) to at least 64000 tokens:
34+
Install [gemma4](https://ollama.com/library/gemma4):
35+
36+
```sh
37+
ollama pull gemma4
38+
```
39+
40+
Confirm it's downloaded:
41+
42+
```sh
43+
ollama ls gemma4
44+
```
45+
46+
You should see:
3447

3548
```sh
36-
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
49+
NAME ID SIZE MODIFIED
50+
gemma4:latest c6eb396dbd59 9.6 GB 5 seconds ago
3751
```
3852

39-
Install [qwen2.5-coder](https://ollama.com/library/qwen2.5-coder):
53+
Check the model's context length:
4054

4155
```sh
42-
ollama pull qwen2.5-coder:latest
56+
ollama show gemma4
57+
```
58+
59+
You should see:
60+
61+
```
62+
Model
63+
architecture gemma4
64+
parameters 8.0B
65+
context length 131072
66+
embedding length 2560
67+
quantization Q4_K_M
68+
requires 0.20.0
69+
```
70+
71+
Restart the server with the context length (to maximize memory):
72+
73+
```sh
74+
OLLAMA_CONTEXT_LENGTH=131072 ollama serve
75+
```
76+
77+
Check the performance of the model:
78+
79+
```sh
80+
ollama run gemma4 "ping" && ollama ps
4381
```
4482

4583
## OpenCode
4684

47-
Open **OpenCode** > ⌘P > **Settings** (⌘,) > **Providers** > **Custom provider** > **+ Connect**.
48-
49-
Fill out the custom provider fields:
50-
51-
- Provider ID:
52-
```
53-
ollama
54-
```
55-
- Display name:
56-
```
57-
Ollama
58-
```
59-
- Base URL:
60-
```
61-
http://localhost:11434/v1
62-
```
63-
- Model ID:
64-
```
65-
qwen2.5-coder:latest
66-
```
67-
- Model Display Name:
68-
```
69-
Qwen2.5 Coder
70-
```
71-
72-
Click **Submit**.
73-
74-
> To delete a manually configured model, edit the global config `~/.config/opencode/opencode.jsonc`.
75-
76-
Ollama is connected and the model is ready for use!
85+
Launch opencode with [gemma4](https://ollama.com/library/gemma4):
86+
87+
```sh
88+
ollama launch opencode --model gemma4
89+
```

0 commit comments

Comments
 (0)