Add Z.AI provider support for GLM-5 (#938)

This commit is contained in:
Reid
2026-03-12 03:43:32 -07:00
committed by GitHub
parent 5d9d17bf71
commit e2eb340c04
3 changed files with 47 additions and 2 deletions
+1 -1
View File
@@ -245,7 +245,7 @@ This document tracks feature parity between IronClaw (Rust implementation) and O
| Ollama (local) | ✅ | ✅ | - | via `rig::providers::ollama` (full support) | | Ollama (local) | ✅ | ✅ | - | via `rig::providers::ollama` (full support) |
| Perplexity | ✅ | ❌ | P3 | Freshness parameter for web_search | | Perplexity | ✅ | ❌ | P3 | Freshness parameter for web_search |
| MiniMax | ✅ | ❌ | P3 | Regional endpoint selection | | MiniMax | ✅ | ❌ | P3 | Regional endpoint selection |
| GLM-5 | ✅ | | P3 | | | GLM-5 | ✅ | | P3 | Via Z.AI provider (`zai`) using OpenAI-compatible chat completions |
| node-llama-cpp | ✅ | | - | N/A for Rust | | node-llama-cpp | ✅ | | - | N/A for Rust |
| llama.cpp (native) | ❌ | 🔮 | P3 | Rust bindings | | llama.cpp (native) | ❌ | 🔮 | P3 | Rust bindings |
+21 -1
View File
@@ -238,6 +238,26 @@
"can_list_models": false "can_list_models": false
} }
}, },
{
"id": "zai",
"aliases": [
"bigmodel"
],
"protocol": "open_ai_completions",
"default_base_url": "https://api.z.ai/api/paas/v4",
"api_key_env": "ZAI_API_KEY",
"api_key_required": true,
"model_env": "ZAI_MODEL",
"default_model": "glm-5",
"description": "Z.AI GLM inference API",
"setup": {
"kind": "api_key",
"secret_name": "llm_zai_api_key",
"key_url": "https://z.ai/manage-apikey/apikey-list",
"display_name": "Z.AI",
"can_list_models": false
}
},
{ {
"id": "cerebras", "id": "cerebras",
"aliases": [], "aliases": [],
@@ -382,4 +402,4 @@
"can_list_models": false "can_list_models": false
} }
} }
] ]
+25
View File
@@ -637,6 +637,31 @@ mod tests {
); );
} }
#[test]
fn registry_provider_alias_resolves_zai() {
let _guard = ENV_MUTEX.lock().expect("env mutex poisoned");
// SAFETY: Under ENV_MUTEX.
unsafe {
std::env::remove_var("LLM_BACKEND");
std::env::remove_var("ZAI_API_KEY");
std::env::remove_var("ZAI_MODEL");
}
let settings = Settings {
llm_backend: Some("bigmodel".to_string()),
selected_model: Some("glm-5".to_string()),
..Default::default()
};
let cfg = LlmConfig::resolve(&settings).expect("resolve should succeed");
assert_eq!(cfg.backend, "zai");
let provider = cfg.provider.expect("provider config should be present");
assert_eq!(provider.provider_id, "zai");
assert_eq!(provider.model, "glm-5");
assert_eq!(provider.base_url, "https://api.z.ai/api/paas/v4");
assert_eq!(provider.protocol, ProviderProtocol::OpenAiCompletions);
}
#[test] #[test]
fn nearai_backend_has_no_registry_provider() { fn nearai_backend_has_no_registry_provider() {
let _guard = ENV_MUTEX.lock().expect("env mutex poisoned"); let _guard = ENV_MUTEX.lock().expect("env mutex poisoned");