Skip to content

Commit 5d21dfd

Browse files
author
Ubuntu
committed
feat(providers): add opencode-go provider support and onboarding
1 parent 936607c commit 5d21dfd

35 files changed

+478
-71
lines changed

docs/concepts/model-providers.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,30 @@ OpenClaw ships with the pi‑ai catalog. These providers require **no**
9999
}
100100
```
101101

102+
### OpenCode Go
103+
104+
- Provider: `opencode-go`
105+
- Auth: `OPENCODE_API_KEY`
106+
- Example model: `opencode-go/kimi-k2.5`
107+
- CLI: `openclaw onboard --auth-choice opencode-go`
108+
- Model routing:
109+
- `opencode-go/kimi-k2.5` and `opencode-go/glm-5` use OpenAI-compatible chat/completions
110+
- `opencode-go/minimax-m2.5` uses Anthropic messages
111+
- OpenCode Go is separate from Zen and does not rewrite or replace `opencode/...` refs
112+
113+
```json5
114+
{
115+
agents: { defaults: { model: { primary: "opencode-go/kimi-k2.5" } } },
116+
}
117+
```
118+
102119
### Google Gemini (API key)
103120

104121
- Provider: `google`
105122
- Auth: `GEMINI_API_KEY`
106123
- Optional rotation: `GEMINI_API_KEYS`, `GEMINI_API_KEY_1`, `GEMINI_API_KEY_2`, `GOOGLE_API_KEY` fallback, and `OPENCLAW_LIVE_GEMINI_KEY` (single override)
107-
- Example models: `google/gemini-3.1-pro-preview`, `google/gemini-3-flash-preview`, `google/gemini-3.1-flash-lite-preview`
108-
- Compatibility: legacy OpenClaw config using `google/gemini-3.1-flash-preview` is normalized to `google/gemini-3-flash-preview`, and bare `google/gemini-3.1-flash-lite` is normalized to `google/gemini-3.1-flash-lite-preview`
124+
- Example models: `google/gemini-3.1-pro-preview`, `google/gemini-3-flash-preview`
125+
- Compatibility: legacy OpenClaw config using `google/gemini-3.1-flash-preview` is normalized to `google/gemini-3-flash-preview`
109126
- CLI: `openclaw onboard --auth-choice gemini-api-key`
110127

111128
### Google Vertex, Antigravity, and Gemini CLI

docs/docs.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@
103103
"source": "/opencode",
104104
"destination": "/providers/opencode"
105105
},
106+
{
107+
"source": "/opencode-go",
108+
"destination": "/providers/opencode-go"
109+
},
106110
{
107111
"source": "/qianfan",
108112
"destination": "/providers/qianfan"
@@ -1013,8 +1017,7 @@
10131017
"tools/browser",
10141018
"tools/browser-login",
10151019
"tools/chrome-extension",
1016-
"tools/browser-linux-troubleshooting",
1017-
"tools/browser-wsl2-windows-remote-cdp-troubleshooting"
1020+
"tools/browser-linux-troubleshooting"
10181021
]
10191022
},
10201023
{
@@ -1112,6 +1115,7 @@
11121115
"providers/nvidia",
11131116
"providers/ollama",
11141117
"providers/openai",
1118+
"providers/opencode-go",
11151119
"providers/opencode",
11161120
"providers/openrouter",
11171121
"providers/qianfan",

docs/providers/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Looking for chat channel docs (WhatsApp/Telegram/Discord/Slack/Mattermost (plugi
3939
- [NVIDIA](/providers/nvidia)
4040
- [Ollama (local models)](/providers/ollama)
4141
- [OpenAI (API + Codex)](/providers/openai)
42+
- [OpenCode Go](/providers/opencode-go)
4243
- [OpenCode Zen](/providers/opencode)
4344
- [OpenRouter](/providers/openrouter)
4445
- [Qianfan](/providers/qianfan)

docs/providers/models.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ model as `provider/model`.
3333
- [Mistral](/providers/mistral)
3434
- [Synthetic](/providers/synthetic)
3535
- [OpenCode Zen](/providers/opencode)
36+
- [OpenCode Go](/providers/opencode-go)
3637
- [Z.AI](/providers/zai)
3738
- [GLM models](/providers/glm)
3839
- [MiniMax](/providers/minimax)

docs/providers/opencode-go.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
summary: "Use OpenCode Go (Kimi, GLM, MiniMax) with OpenClaw"
3+
read_when:
4+
- You want OpenCode Go for model access
5+
- You want OpenCode Go without changing OpenCode Zen behavior
6+
title: "OpenCode Go"
7+
---
8+
9+
# OpenCode Go
10+
11+
OpenCode Go is a separate OpenCode provider path for the Go-hosted model catalog.
12+
It is configured with the `opencode-go` provider id and does **not** replace or
13+
change [OpenCode Zen](/providers/opencode).
14+
15+
## Supported models
16+
17+
- `opencode-go/kimi-k2.5`
18+
- `opencode-go/glm-5`
19+
- `opencode-go/minimax-m2.5`
20+
21+
## CLI setup
22+
23+
```bash
24+
openclaw onboard --auth-choice opencode-go
25+
# or non-interactive
26+
openclaw onboard --opencode-go-api-key "$OPENCODE_API_KEY"
27+
```
28+
29+
## Config snippet
30+
31+
```json5
32+
{
33+
env: { OPENCODE_API_KEY: "YOUR_API_KEY_HERE" }, // pragma: allowlist secret
34+
agents: { defaults: { model: { primary: "opencode-go/kimi-k2.5" } } },
35+
}
36+
```
37+
38+
## Routing behavior
39+
40+
OpenCode Go uses two transport shapes internally:
41+
42+
- `kimi-k2.5` and `glm-5` use an OpenAI-compatible chat/completions flow
43+
- `minimax-m2.5` uses an Anthropic messages flow
44+
45+
OpenClaw handles that routing automatically when the model ref uses
46+
`opencode-go/...`.
47+
48+
## Notes
49+
50+
- Auth defaults to `OPENCODE_API_KEY`.
51+
- OpenCode Go is additive. Existing `opencode/...` Zen configs stay unchanged.
52+
- If you want the curated Zen catalog instead, use [OpenCode Zen](/providers/opencode).

docs/providers/opencode.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ OpenCode Zen is a **curated list of models** recommended by the OpenCode team fo
1212
It is an optional, hosted model access path that uses an API key and the `opencode` provider.
1313
Zen is currently in beta.
1414

15+
If you want the separate Go-hosted catalog (`opencode-go/...`), see
16+
[OpenCode Go](/providers/opencode-go).
17+
1518
## CLI setup
1619

1720
```bash

src/agents/live-model-filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function isModernModelRef(ref: ModelRef): boolean {
8181
return false;
8282
}
8383

84-
if (provider === "openrouter" || provider === "opencode") {
84+
if (provider === "openrouter" || provider === "opencode" || provider === "opencode-go") {
8585
// OpenRouter/opencode are pass-through proxies; accept any model ID
8686
// rather than restricting to a static prefix list.
8787
return true;

src/agents/model-auth-env-vars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const PROVIDER_ENV_API_KEY_CANDIDATES: Record<string, string[]> = {
44
chutes: ["CHUTES_OAUTH_TOKEN", "CHUTES_API_KEY"],
55
zai: ["ZAI_API_KEY", "Z_AI_API_KEY"],
66
opencode: ["OPENCODE_API_KEY", "OPENCODE_ZEN_API_KEY"],
7+
"opencode-go": ["OPENCODE_API_KEY", "OPENCODE_ZEN_API_KEY"],
78
"qwen-portal": ["QWEN_OAUTH_TOKEN", "QWEN_PORTAL_API_KEY"],
89
volcengine: ["VOLCANO_ENGINE_API_KEY"],
910
"volcengine-plan": ["VOLCANO_ENGINE_API_KEY"],

src/agents/model-auth.profiles.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,18 @@ describe("getApiKeyForModel", () => {
397397
},
398398
);
399399
});
400+
401+
it("resolveEnvApiKey('opencode-go') falls back to OPENCODE_ZEN_API_KEY", async () => {
402+
await withEnvAsync(
403+
{
404+
OPENCODE_API_KEY: undefined,
405+
OPENCODE_ZEN_API_KEY: "sk-opencode-zen-fallback", // pragma: allowlist secret
406+
},
407+
async () => {
408+
const resolved = resolveEnvApiKey("opencode-go");
409+
expect(resolved?.apiKey).toBe("sk-opencode-zen-fallback");
410+
expect(resolved?.source).toContain("OPENCODE_ZEN_API_KEY");
411+
},
412+
);
413+
});
400414
});

src/agents/model-compat.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ describe("isModernModelRef", () => {
313313
expect(isModernModelRef({ provider: "opencode", id: "claude-opus-4-6" })).toBe(true);
314314
expect(isModernModelRef({ provider: "opencode", id: "gemini-3-pro" })).toBe(true);
315315
});
316+
317+
it("accepts all opencode-go models without zen exclusions", () => {
318+
expect(isModernModelRef({ provider: "opencode-go", id: "kimi-k2.5" })).toBe(true);
319+
expect(isModernModelRef({ provider: "opencode-go", id: "glm-5" })).toBe(true);
320+
expect(isModernModelRef({ provider: "opencode-go", id: "minimax-m2.5" })).toBe(true);
321+
});
316322
});
317323

318324
describe("resolveForwardCompatModel", () => {

0 commit comments

Comments
 (0)