feat: built-in zai upstream for Z.ai GLM Coding Plan subscriptions#8
Merged
Conversation
- 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
zaiadded toBUILTIN_UPSTREAMS:base = https://api.z.ai/api/anthropic,auth = bearer:ZAI_API_KEY,stripBeta = true. So it's zero-config: setZAI_API_KEY, usezai:glm-5.2. OverridestripBeta/base via[upstreams]if needed.zai(same asopenrouter) — proven by an integration test and a live binary drive.check-latestnow reports how many non-openrouter models it skipped (incl. the zai-only early-return case — caught in code review).config.ts,types.ts, README) and env docs (README,docs/development.md,.env.example) updated.Process (as requested)
plan → adversarial plan-verify (corrected
stripBeta:false→true, +stale enumerations, +check-latest honesty) → red tests (5 failing onunknown 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-onlycheck-latestnote; live request → Z.ai gotBearer $ZAI_API_KEY, not Claude's token).Verified
bun run checkgreen: eslint + tsc + 83 tests (+5).zai:glm-5.2,Bearer ZAI_API_KEYsent, Claude auth not leaked, decision logged.