docs(providers): document Z.ai/GLM dual-endpoint model, no glm.rs needed#309
Merged
Destynova2 merged 1 commit intomainfrom Apr 28, 2026
Merged
docs(providers): document Z.ai/GLM dual-endpoint model, no glm.rs needed#309Destynova2 merged 1 commit intomainfrom
Destynova2 merged 1 commit intomainfrom
Conversation
Verdict on roadmap B-01 ("GLM provider registry"): keep openai_compat,
do not add a dedicated GLM provider impl.
Investigation:
Z.ai exposes GLM models on TWO parallel endpoints:
1. https://api.z.ai/api/anthropic (Anthropic Messages API)
Already wired: provider_type = "z.ai" -> AnthropicCompatibleProvider
in src/providers/registry.rs:233-247. Drop-in for Claude Code.
2. https://api.z.ai/api/paas/v4 (OpenAI Chat Completions)
Reached via provider_type = "openai" + explicit base_url. This is
what presets/ultra-cheap.toml uses for the ongoing free tier
(glm-4.7-flash, glm-4.5-flash, glm-4.5-air).
Quirks survey on the OpenAI-compat path (docs.z.ai/api-reference):
- thinking: { type, clear_thinking } -- request-side, optional
- do_sample: bool -- request-side, optional
- request_id: string -- request-side, optional
- tool_stream: bool -- request-side, optional
- error shape { code, message } -- normalized at dispatch
- finish_reasons sensitive/... -- cosmetic in passthrough
None of these are emitted by Claude Code or Codex CLI clients (the
sole inbound surfaces grob proxies). A dedicated glm.rs would
duplicate OpenAIProvider verbatim and ship as dead code. If a user
ever needs GLM thinking control end-to-end, the Anthropic path
already covers it via thinking blocks.
Changes:
- docs/how-to/providers.md: add a "Z.ai / GLM" section that
enumerates both paths, when to pick each, and the OpenAI-compat
quirks grob deliberately ignores. Update the overview table to
list both rows separately so the choice is unambiguous.
- docs/reference/providers.md: add the openai+base_url row to the
provider creation dispatch table next to provider_type = "z.ai".
- tests/unit/provider_test.rs: add ultra_cheap_preset_zai_uses_openai_compat
regression test that parses presets/ultra-cheap.toml and asserts the
zai provider entry uses provider_type=openai with the canonical
paas/v4 base URL. Guards against silent breakage of the free-tier
path during future provider refactors.
Build dependency: this branch carries the include_dir fix from PR
#304 (cherry-pick of 5a34bac) because main is currently broken --
src/preset/mod.rs has stale include_str! references to deleted
preset files (medium/local/cheap/fast.toml). Once #304 lands, that
commit becomes a no-op merge.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f2ba261 to
98b6e1c
Compare
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.
Verdict on roadmap B-01: keep
openai_compat, do not add a dedicated GLM provider impl.Summary
Z.ai exposes GLM models on two parallel endpoints, both already covered by grob without any new code:
provider_typebase_urlz.ai(existing)https://api.z.ai/api/anthropicopenaihttps://api.z.ai/api/paas/v4ultra-cheappreset)The first path was wired in
src/providers/registry.rs:233-247(routes toAnthropicCompatibleProvider). The second path is whatpresets/ultra-cheap.tomluses today and works as-is through the standardOpenAIProvidertranslation layer.Why no
glm.rsInvestigated the OpenAI-compat endpoint quirks (
docs.z.ai/api-reference/llm/chat-completion):thinking: { type, clear_thinking }provider_type = "z.ai"+ Anthropic thinking blocks if needed end-to-end.do_sample: boolrequest_id: stringtool_stream: bool(GLM-4.6+){ code, message }sensitive/model_context_window_exceeded/network_errorNone of these are emitted by Claude Code or Codex CLI (the only inbound surfaces grob proxies). A dedicated
glm.rswould duplicateOpenAIProviderverbatim and ship as dead code.Changes
docs/how-to/providers.md: new "Z.ai / GLM" section documenting both paths, when to pick each, and the OpenAI-compat quirks grob deliberately ignores. Overview table now lists both rows.docs/reference/providers.md: provider creation dispatch table now documentsprovider_type = "openai" + base_url = api.z.ai/api/paas/v4next to the existingz.airow.tests/unit/provider_test.rs: regression testultra_cheap_preset_zai_uses_openai_compatthat parses the shippedpresets/ultra-cheap.tomland asserts thezaiprovider entry usesprovider_type = "openai"+ canonical paas/v4 URL. Guards against silent breakage of the free-tier path.Build dependency
Cherry-picks
5a34bacfrom PR #304 (fix/preset-mod-include-str) because main is currently broken —src/preset/mod.rshas staleinclude_str!references to deleted preset files (medium/local/cheap/fast.toml). Once #304 lands, that commit becomes a no-op merge.Test plan
cargo fmt --all -- --checkpassescargo clippy --tests --all-targetspasses (no warnings)cargo nextest run --test libpasses (217/217 tests)ultra_cheap_preset_zai_uses_openai_compatpassesenterprise::preset_snapshot_test::snapshot_preset_ultra_cheappassesRollback
If a future user reports they need a dedicated GLM provider for one of the quirks above, revisit by adding the field to
RequestExtensionsrather than forking a new provider type.🤖 Generated with Claude Code