OpenCode Runner¶
OpenCode is a multi-provider terminal coding agent. Kew's OpenCodeRunner shells out to the OpenCode CLI, giving you a single integration that covers Gemini, GPT/o-series, Codex, Ollama, OpenRouter, and 70+ other providers.
Prerequisites¶
- Install the OpenCode CLI — see https://opencode.ai/docs/.
- Wire up the providers you want to dispatch to. The path differs for cloud vs. local:
Cloud providers (Google, OpenAI, OpenRouter, Anthropic): use opencode auth login — credentials are stored in OpenCode's own config.
Local Ollama: opencode auth login ollama does not work — Ollama doesn't fit OpenCode's API-key auth flow. Instead, use Ollama's built-in launcher (Ollama 0.15+) to register your local models with OpenCode in one step:
This walks you through model selection and updates OpenCode's known-models cache. Recommended: pull a model with at least a 64k context window (Qwen3-Coder, Qwen2.5-Coder, etc.) before running it, since OpenCode's agentic loop can chew through context fast.
Either way, kew does not see or manage provider credentials.
Selecting a model¶
Use the provider_id/model_id form anywhere kew accepts a model:
Kew routes any provider/model string (and the prefixes gemini-, gpt-, o1-, o3-, o4-, ollama/) to the OpenCode runner. To force OpenCode regardless of the model string, set runner = "opencode".
Examples¶
Gemini 2.5 Pro:
OpenAI Codex:
Local Ollama:
OpenRouter (multi-segment paths supported):
OpenRouter¶
OpenRouter puts hundreds of models from many vendors behind a single API key, and OpenCode treats it as one more provider. Use the three-segment form openrouter/<vendor>/<model>:
Authenticate once with opencode auth login openrouter, or set OPENROUTER_API_KEY in the environment.
OpenRouter models work in [routing] tiers like any other model string:
Before dispatching real code through OpenRouter, read OpenRouter models — the underlying providers have varying data retention and training policies, and there are account-level settings worth configuring first.
Resume support¶
OpenCode supports session resume via --session <id>. When kew detects a transient failure (rate limit, timeout, API error), it re-dispatches with the saved session ID and a "continue where you left off" prompt — same behavior as the Claude Code runner.
Configuration¶
See [agent.opencode] for the full config reference.
Limitations (v1)¶
- No native budget gate. OpenCode does not expose a
--max-budget-usdflag. Use kew's dispatch-level budget settings instead. - No attached-server mode. Every dispatch starts a fresh
opencode runprocess. If cold-boot latency becomes a problem, attaching to a long-runningopencode serveis a planned future enhancement. - Provider auth surfaces as permanent failure. A missing credential causes OpenCode to exit non-zero with a descriptive error; kew classifies this as permanent and the OpenCode error message appears in the run history.