Skip to content

docs(providers): document Z.ai/GLM dual-endpoint model, no glm.rs needed#309

Merged
Destynova2 merged 1 commit intomainfrom
feat/glm-provider-or-doc
Apr 28, 2026
Merged

docs(providers): document Z.ai/GLM dual-endpoint model, no glm.rs needed#309
Destynova2 merged 1 commit intomainfrom
feat/glm-provider-or-doc

Conversation

@Destynova2
Copy link
Copy Markdown
Contributor

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:

Path provider_type base_url Purpose
Anthropic Messages API z.ai (existing) https://api.z.ai/api/anthropic Drop-in for Claude Code (Coding Plan)
OpenAI Chat Completions API openai https://api.z.ai/api/paas/v4 Free tier / PAYG (ultra-cheap preset)

The first path was wired in src/providers/registry.rs:233-247 (routes to AnthropicCompatibleProvider). The second path is what presets/ultra-cheap.toml uses today and works as-is through the standard OpenAIProvider translation layer.

Why no glm.rs

Investigated the OpenAI-compat endpoint quirks (docs.z.ai/api-reference/llm/chat-completion):

Quirk Impact on grob
thinking: { type, clear_thinking } Request-side, optional. Use provider_type = "z.ai" + Anthropic thinking blocks if needed end-to-end.
do_sample: bool Request-side, optional. Not emitted by Claude Code / Codex CLI.
request_id: string Request-side, optional trace ID. Not emitted by inbound clients.
tool_stream: bool (GLM-4.6+) Request-side, optional. Not emitted by inbound clients.
Error shape { code, message } Cosmetic — normalized at dispatch layer.
Finish reasons sensitive / model_context_window_exceeded / network_error Cosmetic in passthrough.

None of these are emitted by Claude Code or Codex CLI (the only inbound surfaces grob proxies). A dedicated glm.rs would duplicate OpenAIProvider verbatim 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 documents provider_type = "openai" + base_url = api.z.ai/api/paas/v4 next to the existing z.ai row.
  • tests/unit/provider_test.rs: regression test ultra_cheap_preset_zai_uses_openai_compat that parses the shipped presets/ultra-cheap.toml and asserts the zai provider entry uses provider_type = "openai" + canonical paas/v4 URL. Guards against silent breakage of the free-tier path.

Build dependency

Cherry-picks 5a34bac from PR #304 (fix/preset-mod-include-str) 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.

Test plan

  • cargo fmt --all -- --check passes
  • cargo clippy --tests --all-targets passes (no warnings)
  • cargo nextest run --test lib passes (217/217 tests)
  • ultra_cheap_preset_zai_uses_openai_compat passes
  • enterprise::preset_snapshot_test::snapshot_preset_ultra_cheap passes

Rollback

If a future user reports they need a dedicated GLM provider for one of the quirks above, revisit by adding the field to RequestExtensions rather than forking a new provider type.

🤖 Generated with Claude Code

@Destynova2 Destynova2 enabled auto-merge April 28, 2026 06:40
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>
@Destynova2 Destynova2 force-pushed the feat/glm-provider-or-doc branch from f2ba261 to 98b6e1c Compare April 28, 2026 20:44
@Destynova2 Destynova2 merged commit dc97c9e into main Apr 28, 2026
32 checks passed
@Destynova2 Destynova2 deleted the feat/glm-provider-or-doc branch April 28, 2026 20:51
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