From 716fb382ec46bc456c66f3682b2306ad2c65a79d Mon Sep 17 00:00:00 2001 From: Argenis Date: Sun, 15 Feb 2026 11:22:03 -0500 Subject: [PATCH] fix: correct API endpoints for z.ai, opencode, and glm providers (#167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #167 - z.ai: https://api.z.ai → https://api.z.ai/api/paas/v4 - opencode: https://api.opencode.ai → https://opencode.ai/zen/v1 - glm: https://open.bigmodel.cn/api/paas → https://open.bigmodel.cn/api/paas/v4 Co-Authored-By: Claude Opus 4.6 --- src/providers/compatible.rs | 34 ++++++++++++++++++++++++++++++++++ src/providers/mod.rs | 6 +++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/providers/compatible.rs b/src/providers/compatible.rs index 6aac0e2..4d8f868 100644 --- a/src/providers/compatible.rs +++ b/src/providers/compatible.rs @@ -524,4 +524,38 @@ mod tests { let p = make_provider("test", "https://api.example.com/v1", None); assert_eq!(p.chat_completions_url(), "https://api.example.com/v1/chat/completions"); } + + // ══════════════════════════════════════════════════════════ + // Provider-specific endpoint tests (Issue #167) + // ══════════════════════════════════════════════════════════ + + #[test] + fn chat_completions_url_zai() { + // Z.AI uses /api/paas/v4 base path + let p = make_provider("zai", "https://api.z.ai/api/paas/v4", None); + assert_eq!( + p.chat_completions_url(), + "https://api.z.ai/api/paas/v4/chat/completions" + ); + } + + #[test] + fn chat_completions_url_glm() { + // GLM (BigModel) uses /api/paas/v4 base path + let p = make_provider("glm", "https://open.bigmodel.cn/api/paas/v4", None); + assert_eq!( + p.chat_completions_url(), + "https://open.bigmodel.cn/api/paas/v4/chat/completions" + ); + } + + #[test] + fn chat_completions_url_opencode() { + // OpenCode Zen uses /zen/v1 base path + let p = make_provider("opencode", "https://opencode.ai/zen/v1", None); + assert_eq!( + p.chat_completions_url(), + "https://opencode.ai/zen/v1/chat/completions" + ); + } } diff --git a/src/providers/mod.rs b/src/providers/mod.rs index 3d80516..025bf95 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -186,13 +186,13 @@ pub fn create_provider(name: &str, api_key: Option<&str>) -> anyhow::Result Ok(Box::new(OpenAiCompatibleProvider::new( - "OpenCode Zen", "https://api.opencode.ai", api_key, AuthStyle::Bearer, + "OpenCode Zen", "https://opencode.ai/zen/v1", api_key, AuthStyle::Bearer, ))), "zai" | "z.ai" => Ok(Box::new(OpenAiCompatibleProvider::new( - "Z.AI", "https://api.z.ai", api_key, AuthStyle::Bearer, + "Z.AI", "https://api.z.ai/api/paas/v4", api_key, AuthStyle::Bearer, ))), "glm" | "zhipu" => Ok(Box::new(OpenAiCompatibleProvider::new( - "GLM", "https://open.bigmodel.cn/api/paas", api_key, AuthStyle::Bearer, + "GLM", "https://open.bigmodel.cn/api/paas/v4", api_key, AuthStyle::Bearer, ))), "minimax" => Ok(Box::new(OpenAiCompatibleProvider::new( "MiniMax", "https://api.minimax.chat", api_key, AuthStyle::Bearer,