Skip to content

Comments

Add native Z.ai (GLM) provider#1

Merged
jamiepine merged 3 commits intospacedriveapp:mainfrom
jiunshinn:feat/zhipu-provider
Feb 16, 2026
Merged

Add native Z.ai (GLM) provider#1
jamiepine merged 3 commits intospacedriveapp:mainfrom
jiunshinn:feat/zhipu-provider

Conversation

@jiunshinn
Copy link
Contributor

@jiunshinn jiunshinn commented Feb 16, 2026

Summary

  • Add Z.ai (Zhipu) as a native LLM provider, enabling direct use of GLM models (glm-4.7, glm-5, etc.) without intermediaries like OpenRouter
  • Z.ai's API is OpenAI-compatible, so implementation reuses existing message conversion and response parsing
  • Fix fallbacks resolution to replace defaults when explicitly set in config (previously fallbacks = {} would not clear Anthropic defaults)

Changes

  • src/config.rs: Add zhipu_key to config structs, env/TOML resolution, onboarding wizard; fix fallbacks field to use Option<HashMap> so explicit empty config clears defaults
  • src/llm/manager.rs: Add "zhipu" match arm in get_api_key()
  • src/llm/model.rs: Add call_zhipu() method and route "zhipu" provider in attempt_completion()

Usage

[llm]
zhipu_key = "env:ZHIPU_API_KEY"

[defaults.routing]
channel = "zhipu/glm-4.7"
worker = "zhipu/glm-4.7"

Test plan

  • cargo check passes
  • cargo test --lib — all 41 tests pass
  • Manual: configure ZHIPU_API_KEY + zhipu/glm-4.7 routing, verify completions work via Discord
Screenshot 2026-02-16 at 5 17 37 pm

jiunshinn and others added 3 commits February 16, 2026 17:14
Allow users with a GLM Coding Plan subscription to use Z.ai models
directly without an intermediary like OpenRouter. Z.ai's API is
OpenAI-compatible so the implementation reuses existing message
conversion and response parsing, only changing the endpoint URL and
auth header.

Changes:
- Add zhipu_key to LlmConfig, TomlLlmConfig, and env/TOML resolution
- Add "zhipu" match arm in LlmManager::get_api_key()
- Add call_zhipu() in SpacebotModel targeting api.z.ai
- Add "Z.ai (GLM)" to onboarding wizard provider list
- Fix fallbacks resolution to replace (not extend) when explicitly set

Usage: configure zhipu_key and route models as zhipu/glm-4.7, etc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jamiepine jamiepine merged commit b2d11fd into spacedriveapp:main Feb 16, 2026
@gempir
Copy link

gempir commented Feb 18, 2026

How do you use this?

I have the
GLM Coding Lite-Monthly Plan

which worked fine on OpenClaw, but for spacebot i'm getting

errorCompletionError: ProviderError: zhipu/glm-4-plus failed after 3 attempts: ProviderError: Z.ai API error (429 Too Many Requests): Insufficient balance or no resource package. Please recharge.
modelzhipu/glm-4-plus

Cannot change the model to anything but zhipu/glm-4-plus in the Agent Model Routing settings

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.

3 participants