Skip to content

feat: built-in zai upstream for Z.ai GLM Coding Plan subscriptions#8

Merged
armenr merged 1 commit into
mainfrom
feat/zai-upstream
Jul 7, 2026
Merged

feat: built-in zai upstream for Z.ai GLM Coding Plan subscriptions#8
armenr merged 1 commit into
mainfrom
feat/zai-upstream

Conversation

@armenr

@armenr armenr commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Makes a Z.ai GLM Coding Plan a zero-config, first-class option — a flat-rate subscription instead of OpenRouter's per-token pricing for GLM.

What

  • zai added to BUILTIN_UPSTREAMS: base = https://api.z.ai/api/anthropic, auth = bearer:ZAI_API_KEY, stripBeta = true. So it's zero-config: set ZAI_API_KEY, use zai:glm-5.2. Override stripBeta/base via [upstreams] if needed.
  • No auth leak: Claude Code's inbound auth is never forwarded to zai (same as openrouter) — proven by an integration test and a live binary drive.
  • check-latest now reports how many non-openrouter models it skipped (incl. the zai-only early-return case — caught in code review).
  • Enumerations (config.ts, types.ts, README) and env docs (README, docs/development.md, .env.example) updated.

Process (as requested)

plan → adversarial plan-verify (corrected stripBeta:falsetrue, +stale enumerations, +check-latest honesty) → red tests (5 failing on unknown upstream zai) → implement → workflow code-review at high (2 findings, both fixed) → bun run check (83 tests) → hand-drove the binary (built-in resolves; zai-only check-latest note; live request → Z.ai got Bearer $ZAI_API_KEY, not Claude's token).

Verified

  • bun run check green: eslint + tsc + 83 tests (+5).
  • Live drive through the compiled binary: subagent → zai:glm-5.2, Bearer ZAI_API_KEY sent, Claude auth not leaked, decision logged.

- Add `zai` to BUILTIN_UPSTREAMS (base https://api.z.ai/api/anthropic, bearer
  ZAI_API_KEY, betas stripped by default) so a flat-rate Z.ai GLM subscription
  works zero-config: set ZAI_API_KEY and use `zai:<model>`. Claude Code's inbound
  auth is never forwarded to zai (no token leak), same as openrouter.
- check-latest now reports how many non-openrouter models it skipped, including
  the zai-only case where it early-returns.
- README: highlighted 'Flat-rate GLM: bring a Z.ai subscription' section;
  ZAI_API_KEY added to the env tables; built-in enumerations updated.
- Tests: unit (auth/base/betas/missing-key) + integration (subagent routes to
  zai with Bearer ZAI_API_KEY, no Claude auth leak).
@armenr armenr merged commit 7bd0277 into main Jul 7, 2026
2 checks passed
@armenr armenr deleted the feat/zai-upstream branch July 7, 2026 10:13
@github-actions github-actions Bot mentioned this pull request Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant