ollama launch opencode or one opencode.json block, plus the 64k context OpenCode requires, why tool calls fail without it, and what fits on your GPU at that length.
Ari Vale·Links and sources checked ·Updated ·Published ·6 min read
This page has referral links. As an Amazon Associate we earn from qualifying purchases.
Our Runpod referral code: nuninlts (link: https://console.runpod.io/signup?ref=nuninlts). A new account that signs up with Google through it and loads $10 gets a one-time bonus credit, a fixed $5 for European customers and a random $5 to $500 elsewhere (Runpod says most get $5), valid 90 days; we earn 3% of Pod and 5% of Serverless spend for the first 6 months (Runpod's referral docs).
ollama launch opencode # pick a local or cloud model, start OpenCode
ollama launch opencode --model qwen3.5 # skip the picker
ollama launch opencode --config # write the setup without starting a session
That one command is the whole setup if OpenCode is installed and your model runs with 64k context (step 2 below). Per Ollama's docs, re-read December 1, 2026, it starts OpenCode with an inline config for the model you choose, lists both local models and Ollama's cloud models, and leaves your own opencode.json untouched. ollama launch with no app name opens a picker; the CLI reference lists OpenCode, Claude Code, Codex, VS Code and Droid as supported integrations. The --model flag is from the same CLI reference.
OpenCode is the open-source (MIT) terminal coding agent. At about 230,000 GitHub stars on Dec 1, 2026 (210,000 on Sep 25), it's the most-starred of the three we cover in this cluster (Claude Code had about 158,000 and Codex about 137,000 that day). It supports local models natively, and Ollama now ships a first-party integration for it. Of the three agents, it's the one we'd point a newcomer to local models at first. Here's why, and how to set it up without the usual "tool calls don't work" dead end. The full comparison with Claude Code and Codex is in our three-way guide.
OpenCode on your laptop, the model on a box across the room. · Illustration generated with Higgsfield
Step 1: install OpenCode
# macOS / Linux (Ollama's docs)
curl -fsSL https://opencode.ai/install | bash
# Windows (Ollama's docs)
npm install -g opencode-ai
Step 2: fix the context before you start
This step is the one that decides whether OpenCode works. Ollama's page is unambiguous: "OpenCode requires a context length of 64k or higher." Ollama's context-length page lists the defaults: 4k under 24 GiB of VRAM, 32k at 24–48 GiB, 256k at 48 GiB+. The Ollama FAQ still says a flat 4,096. On a typical 8–16GB gaming card you start at 4k, which is 1/16th of what OpenCode needs.
On Sep 25, 2026, OpenCode's own provider docs described the symptom: "If tool calls aren't working, try increasing num_ctx in Ollama. Start around 16k - 32k." That advice was gone when we re-checked on Nov 12, and on Dec 1 the page still says OpenCode probes the local Ollama server at http://127.0.0.1:11434 and adds its models by itself. Go with Ollama's 64k, since coding agents pull file contents into the context as they work.
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
# check it took: CONTEXT should be 64000, PROCESSOR 100% GPU
ollama ps
Step 3 (fast path): ollama launch opencode, in detail
ollama launch opencode # pick a model, start OpenCode
ollama launch opencode --config # configure without starting a session
Ollama's docs are specific about what this touches. ollama launch opencode starts OpenCode with an inline config for the selected model and "does not overwrite ~/.config/opencode/opencode.json". Your existing OpenCode settings still apply. The flip side is that models you've defined only in opencode.json won't show up in the launch model picker.
Step 3 (manual path): opencode.json
If you want the setup committed with your project, add an Ollama provider to opencode.json. This is Ollama's documented block, with the model changed to a coding model:
Then just run opencode. That block is OpenCode's version 1 format, which Ollama's docs still show (re-read Dec 1, 2026). OpenCode 2 reads it as it is: its migration guide says "Existing supported V1 configuration is intended to keep working". In V2's own format the map is called providers, npm becomes package with an aisdk: prefix, and baseURL moves under settings. With Ollama running on the same machine, OpenCode 2 finds it without any provider block at all.
When a global and a project config disagree, OpenCode's config locations and precedence rules decide which one wins. It's worth a read if a setting seems to be ignored.
Which model fits at 64k
OpenCode needs a model with tool calling. Ollama links its tools-capable list. For coding on a home GPU, the Ollama library has Qwen3-Coder 30B (19 GB download, 256K max context) and gpt-oss 20B (14 GB, 128K). At the 64k OpenCode requires, our VRAM engine gives:
VRAM at 64k context (our engine, Q4_K_M)
Qwen3-Coder 30B-A3B
fp16 KV (default)
24 GiB
q8_0 KV
21 GiB
Realistic card
24GB (tight) · 32GB (comfortable)
gpt-oss 20B
fp16 KV (default)
15.6 GiB
q8_0 KV
14.1 GiB
Realistic card
16GB (tight) · 24GB (comfortable)
fp16 KV (default)
q8_0 KV
Realistic card
Qwen3-Coder 30B-A3B
24 GiB
21 GiB
24GB (tight) · 32GB (comfortable)
gpt-oss 20B
15.6 GiB
14.1 GiB
16GB (tight) · 24GB (comfortable)
The q8_0 column is Ollama's documented OLLAMA_KV_CACHE_TYPE=q8_0 setting, which the FAQ says uses "approximately 1/2 the memory of f16" with a very small precision loss. It's a global setting, so it applies to every model you run. Per-GPU tables: best GPU for Qwen3-Coder, best GPU for gpt-oss 20B. The hardware deep-dive is best GPU for Qwen3-Coder.
In practice that means a 24GB card such as a used RTX 3090 for Qwen3-Coder, and a 32GB RTX 5090 if you want the comfortable setup. On a 16GB card, gpt-oss 20B is the realistic pick, and our best local LLM for 16GB VRAM guide lists what else fits. If replies feel slow once the context fills up, our guide on how to speed up local LLM inference covers the settings that matter.
Available at AmazonOwn the card that's comfortable at 64k
GeForce RTX 5090 32GB cards
32 GB: the comfortable size for Qwen3-Coder 30B at 64k context in the table above. Amazon lists several makers' RTX 5090 cards.
Best for running OpenCode with Qwen3-Coder 30B at 64k on your own machine.
Not sure which model to load? Our best local model for OpenCode guide compares seven tool-calling models by the VRAM each needs at 64K context, from 16 GB to 48 GB cards.
"Error: context deadline exceeded" with ollama launch opencode
This error means a request to Ollama ran out of time before it finished. Ollama's docs have no page for it. In Ollama's GitHub issues (for example #17484) it comes up in two moments: while a model is still downloading, and while a big model is loading into memory. Try these in order:
Download the model on its own first. Run ollama pull <model> and let it finish before ollama launch opencode. If the pull stalls, run the same command again.
On a work or school network with a proxy, set HTTPS_PROXY for the Ollama server, not HTTP_PROXY, and install the proxy's certificate as a system certificate. Ollama's FAQ says both.
For a big model on a slow first load, run ollama run <model> "hi" once, check ollama ps shows it loaded, then launch.
If it still fails, set OLLAMA_DEBUG=1, restart Ollama and read server.log. On Windows it's in %LOCALAPPDATA%\Ollama, per Ollama's troubleshooting page.
Quick answers
How do I fix "context deadline exceeded" in Ollama?
It means a request timed out, usually while a model is downloading or loading. Run ollama pull <model> on its own first, set HTTPS_PROXY (not HTTP_PROXY) if you are behind a proxy, load a big model once with ollama run before ollama launch opencode, and check server.log with OLLAMA_DEBUG=1 if it keeps failing.
How do I use Ollama with OpenCode?
Run ollama launch opencode. Or add an ollama provider to opencode.json with npm "@ai-sdk/openai-compatible" and baseURL http://localhost:11434/v1, list your model under "models", then run opencode (Ollama docs, re-read Dec 1, 2026). OpenCode 2 still accepts that block.
What does ollama launch opencode do?
It starts OpenCode wired to an Ollama model you pick, local or cloud, using an inline config. It does not overwrite ~/.config/opencode/opencode.json. Add --model <name> to skip the picker, or --config to set it up without opening a session (Ollama docs, re-read Dec 1, 2026).
Can OpenCode run fully local with Ollama?
Yes. Pick a downloaded model with tool calling, such as qwen3-coder:30b or gpt-oss:20b, and give it at least 64k context. Nothing leaves your machine. Cloud models in the same picker are optional and run on Ollama's servers.
Why aren't OpenCode tool calls working with Ollama?
Almost always context length. Ollama's docs say OpenCode requires 64k or more. Ollama defaults to 4k on GPUs under 24 GiB, so start it with OLLAMA_CONTEXT_LENGTH=64000 and confirm with ollama ps.
Will ollama launch opencode overwrite my config?
No. Per Ollama's docs it starts OpenCode with an inline config and doesn't overwrite ~/.config/opencode/opencode.json, so your existing settings still apply. Models defined only in opencode.json don't appear in the launch picker.
What's the best local model for OpenCode?
One with tool calling and enough context. Qwen3-Coder 30B needs about 24.0 GiB at 64k on our engine (21.0 GiB with the 8-bit KV cache), so a 24GB card is tight. gpt-oss 20B needs about 15.6 GiB (14.1 GiB with q8_0), which suits 16GB cards.
Is OpenCode free?
OpenCode itself is open source under the MIT licence. Running it against a local Ollama model costs nothing beyond your hardware and electricity. Ollama's cloud models, if you choose them, run on Ollama's servers instead.