🤖 feat: add Z.ai as a native provider with GLM 5.3 Flash - #4007
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This comment has been minimized.
This comment has been minimized.
|
@codex review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9c4983eba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Adds Z.ai (Zhipu) as a first-class native provider (provider id
zai, backed by the official@ai-sdk/zaipackage), starting with one model:zai:glm-5.3-flash(GLM 5.3 Flash, aliasesglm/glm-flash).Background
GLM models were previously reachable only through the OpenRouter gateway (
openrouter:z-ai/glm-4.6). Users with a Z.ai API key can now use GLM 5.3 Flash directly: 1M context, 128K max output, vision input, and forced reasoning with Z.ai'sreasoning_effortcontrol.Implementation
zaidirect provider (createZai,ZAI_API_KEY, default base URLhttps://api.z.ai/api/paas/v4); the generic direct-provider factory path handles it with no custom code. OpenRouter routing is intentionally not wired (OpenRouter uses the hyphenatedz-aivendor slug).GLM_53_FLASHwith tokenizer overridezai/glm-4.5(closest published GLM encoding in ai-tokenizer).low/high/maxonly.isGlm53Modeldrives a["low", "high", "max"]policy, andresolveEffectiveThinkingLevelclamps unset/"off" through the policy the same way Mythos-class Anthropic models do, so tracked levels match wire behavior.zaibranch sendsthinking: enabled, mappedreasoningEffort(high/xhigh to high, max to max, else low), andtoolStream: true(Z.ai's recommended streaming-tool-calls flag).Validation
/api/paas/v4/chat/completions, modelglm-5.3-flash,thinking: enabled, andreasoning_effortmapping low to low, high to high, max to max. A dummy key surfaced Z.ai's genuine auth error cleanly.Notes
UAT observation for a product-level call: the composer hides Low for this model by default because the global default Min Thinking floor is
medium(existing behavior for all models, seepolicy.test.ts"medium floor hides off/low"; Grok 4.6 loses Low the same way). With the per-model Min Thinking setting lowered, the composer offers exactly Low/High/Max, and "off" is never offered. If always-reasoning models should be exempt from the floor, that belongs in a follow-up.Risks
Low regression risk: the change is almost entirely additive (new provider/model entries plus one new providerOptions branch). The one shared-path edit is
resolveEffectiveThinkingLevel, which now clamps for GLM 5.3 in addition to Mythos-class Anthropic models; behavior for all other models is unchanged and covered by existing policy tests.Generated with
xum• Model:anthropic:claude-fable-5• Thinking:xhigh• Cost:$40.18