Support OpenCode Go Provider¶
Summary¶
Add opencode-go as a first-class provider in Keen Code using OpenCode Go's documented endpoints:
- OpenAI-compatible chat completions for GLM, Kimi, DeepSeek, MiMo, and Qwen models.
- Anthropic-compatible messages for MiniMax M2.5 and M2.7.
- Default base URL:
https://opencode.ai/zen/go/v1/.
Source: OpenCode Go docs, last checked May 6, 2026: https://opencode.ai/docs/go/
Key Changes¶
- Add
ProviderOpenCodeGo = "opencode-go"to config provider constants. - Add OpenCode Go to
providers/registry.yamlwith the currently documented models: glm-5.1,glm-5kimi-k2.6,kimi-k2.5deepseek-v4-pro,deepseek-v4-flashmimo-v2-pro,mimo-v2-omni,mimo-v2.5-pro,mimo-v2.5minimax-m2.7,minimax-m2.5qwen3.6-plus,qwen3.5-plus- Keep model IDs raw in Keen config, such as
kimi-k2.6, under provideropencode-go. Do not storeopencode-go/<model-id>because Keen already stores provider separately.
Implementation Details¶
- Route
opencode-gomodels inNewClientby model family: minimax-m2.*->NewAnthropicClient- all other OpenCode Go models ->
NewOpenAICompatibleClient - Add OpenCode Go default base URL handling:
- OpenAI-compatible client uses
https://opencode.ai/zen/go/v1/, letting the SDK append/chat/completions. - Anthropic client uses the same base URL and relies on the SDK's Messages path behavior for
/messages. - Add a small helper, for example
isOpenCodeGoAnthropicModel(model string) bool, so protocol routing is explicit and testable. - Do not introduce a new LLM client type unless SDK base URL behavior makes it unavoidable.
Thinking Behavior¶
- DeepSeek OpenCode Go models:
offsendsthinking: {"type":"disabled"}.highandmaxsendthinking: {"type":"enabled"}plusreasoning_effort.- GLM and Kimi OpenCode Go models:
- support
enabled/disabledviathinking: {"type": effort}. - Qwen OpenCode Go models:
- support
enabled/disabledusingenable_thinking: true|false. - MiMo models:
- expose
thinking_effortsonly if verified from/models; otherwise omit thinking controls and still stream anyreasoning_contentreturned by the provider. - MiniMax models:
- do not send Keen thinking controls initially.
- preserve and replay returned Anthropic thinking blocks through the existing Anthropic client path.
Tests¶
- Config/client routing:
opencode-gonon-MiniMax model creates anOpenAICompatibleClient.opencode-goMiniMax model creates anAnthropicClient.- missing API key is rejected like other API-key providers.
- Base URL:
- OpenAI-compatible OpenCode Go client defaults to
https://opencode.ai/zen/go/v1/. - custom
base_urloverrides the default. - Thinking params:
- DeepSeek OpenCode Go maps
off,high, andmaxcorrectly. - GLM/Kimi OpenCode Go maps
enabledanddisabledcorrectly. - Qwen OpenCode Go maps
enabled/disabledtoenable_thinking. - Registry:
- provider
opencode-goloads fromproviders/registry.yaml. - listed models have expected IDs, names, context windows, and thinking efforts where supported.
- Full verification:
- run
gofmton modified Go files. - run
go mod tidy. - run
go test ./....
Assumptions¶
- The default OpenCode Go API key is a normal bearer API key and should use Keen's existing API-key auth path.
- The model list should be static in
providers/registry.yamlfor this change; dynamic loading from/modelsis out of scope. - OpenCode Go remains beta, so provider-specific thinking controls should be conservative and covered by unit tests.