Skip to content

Commit 175c1b7

Browse files
feat: configure zai-coding-plan auth via env var + provider pin (#64)
## Summary Configures `zai-coding-plan` provider authentication using environment variables (no `opencode auth login` needed) and pins the base URL as a workaround for [opencode#11106](anomalyco/opencode#11106). **Design decision:** Environment variables are sufficient for container auth. OpenCode resolves credentials in priority order: env vars > `.env` file > `auth.json`. Env vars take precedence over `auth.json`, need no interactive TTY, and are the recommended path for containers. The entrypoint deliberately does NOT call `opencode auth login`. ## Changes - **`build/etc/opencode/opencode.jsonc`** — Pin `provider.zai-coding-plan.options.baseURL` to `https://api.z.ai/api/coding/paas/v4` (workaround for opencode#11106) - **`AGENTS.md`** — Add Provider Authentication section with credential priority + `ZHIPU_API_KEY` table; clarify `OMO_*` flags are subscription toggles, not credentials - **`docs/guides/configuration.md`** — Add user-facing Provider Authentication section with `ZHIPU_API_KEY` docs, credential priority, and `podman run` example ## Usage ```bash podman run -it --rm \ -e ZHIPU_API_KEY=your-key-here \ -e OMO_ZAI_CODING_PLAN=yes \ opencoder ``` - `ZHIPU_API_KEY` — provides the API credential (auth) - `OMO_ZAI_CODING_PLAN=yes` — enables ZAI models in agent fallback chains (subscription toggle) Both are needed for the models to work. ## Verification - `validate.sh`: 35/36 passed, 0 failed (1 pre-existing warning) - JSONC parsed clean — provider config intact with correct URL - `opencode.json` validated via `jq` ## Commits 1. `feat(config): pin zai-coding-plan base URL in opencode.jsonc` 2. `docs(agents): document ZHIPU_API_KEY provider auth` 3. `docs: document ZHIPU_API_KEY for zai-coding-plan auth` Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) --------- Co-authored-by: Sisyphus <[email protected]>
1 parent 2a14395 commit 175c1b7

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

‎AGENTS.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,15 @@ The entrypoint selectively enables each optional skill collection at container s
300300
| `ECC_ENABLED` | Runtime install of `everything-claude-code` skills via skills.sh CLI (default: disabled) |
301301
| `SUPERPOWERS_ENABLED` | Runtime install of `superpowers` skills via skills.sh CLI (default: disabled) |
302302

303-
Additionally, `OMO_CLAUDE` / `OMO_GEMINI` / `OMO_COPILOT` / `OMO_OPENAI` / `OMO_OPENCODE_GO` / `OMO_OPENCODE_ZEN` / `OMO_ZAI_CODING_PLAN` (values: `yes`/`no`/`max20`) pass subscription config to `bunx oh-my-opencode install` at runtime. `OMO_FORCE=yes` forces reinstall.
303+
Additionally, `OMO_CLAUDE` / `OMO_GEMINI` / `OMO_COPILOT` / `OMO_OPENAI` / `OMO_OPENCODE_GO` / `OMO_OPENCODE_ZEN` / `OMO_ZAI_CODING_PLAN` (values: `yes`/`no`/`max20`) pass **subscription toggles** to `bunx oh-my-opencode install` at runtime — they control which LLM models are added to agent fallback chains, NOT authentication. `OMO_FORCE=yes` forces reinstall.
304+
305+
### Provider Authentication
306+
307+
OpenCode resolves provider credentials in priority order: **environment variables** > project `.env` file > `~/.local/share/opencode/auth.json` (written by interactive `opencode auth login`). Environment variables are the recommended path for containers — no interactive TTY required, and they take precedence over `auth.json`. The entrypoint deliberately does NOT call `opencode auth login`.
308+
309+
| Env var | Provider | Purpose |
310+
|---------|----------|---------|
311+
| `ZHIPU_API_KEY` | `zai-coding-plan` | API key for ZAI Coding Plan subscription (GLM-4.5, GLM-5.x models). Base URL is pinned in `opencode.jsonc` as a workaround for [opencode#11106](https://github.com/anomalyco/opencode/issues/11106). |
304312

305313
### Runtime Environment Variables
306314

‎build/etc/opencode/opencode.jsonc‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
"which": "allow"
4444
}
4545
},
46+
// Provider-specific overrides
47+
// zai-coding-plan: pin base URL to the coding plan endpoint
48+
// Workaround for opencode issue #11106 (endpoint auto-detection may fail)
49+
"provider": {
50+
"zai-coding-plan": {
51+
"options": {
52+
"baseURL": "https://api.z.ai/api/coding/paas/v4"
53+
}
54+
}
55+
},
4656
// Plugins are defined in build/.opencode/opencode.json to keep project-level
4757
// and container-level plugin lists in sync
4858
// Sharing behavior for sessions (manual = explicit user action required)

‎docs/guides/configuration.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,34 @@ The entrypoint passes subscription flags to `bunx oh-my-opencode install` at con
166166

167167
Set `OMO_FORCE=yes` to force reinstall of oh-my-opencode regardless of existing state.
168168

169+
> **Note:** `OMO_*` flags are **subscription toggles**, not credentials. They tell oh-my-opencode which models to add to agent fallback chains. Authentication is handled separately via environment variables (see below).
170+
171+
## Provider Authentication
172+
173+
OpenCode resolves provider credentials in priority order:
174+
175+
1. **Environment variables** (highest priority) — recommended for containers
176+
2. **Project `.env` file**
177+
3. **`auth.json`** (`~/.local/share/opencode/auth.json`, written by interactive `opencode auth login`)
178+
179+
For containers, pass the API key as an environment variable — no interactive TTY required, and it takes precedence over `auth.json`. The entrypoint does **not** call `opencode auth login`.
180+
181+
### ZAI Coding Plan
182+
183+
| Variable | Required | Purpose |
184+
|----------|----------|---------|
185+
| `ZHIPU_API_KEY` | Yes (to use GLM models) | API key for the `zai-coding-plan` provider (GLM-4.5, GLM-5.x). The base URL is pinned to `https://api.z.ai/api/coding/paas/v4` in `opencode.jsonc` as a workaround for [opencode#11106](https://github.com/anomalyco/opencode/issues/11106). |
186+
187+
```bash
188+
# Run with ZAI Coding Plan authentication
189+
podman run -it --rm \
190+
-e ZHIPU_API_KEY=your-key-here \
191+
-e OMO_ZAI_CODING_PLAN=yes \
192+
opencoder
193+
```
194+
195+
`OMO_ZAI_CODING_PLAN=yes` enables the ZAI models in the fallback chain; `ZHIPU_API_KEY` provides the credential. Both are needed for the models to actually work.
196+
169197
## Adding Plugins
170198

171199
1. Add the plugin to `build/.opencode/opencode.json` with a pinned version:

0 commit comments

Comments
 (0)