From 9f77df4a277b4b494add312bc58f4df9069d05ab Mon Sep 17 00:00:00 2001 From: Norman King Date: Mon, 25 May 2026 11:19:59 -0400 Subject: [PATCH] feat: add zai-coding provider for Z.AI GLM Coding Plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new zai-coding provider that uses the Anthropic-compatible endpoint (https://api.z.ai/api/anthropic) instead of the OpenAI-compatible /api/paas/v4 endpoint. The Z.AI Coding Plan quota is only accessible via the Anthropic endpoint — the standard endpoint returns 1113 (insufficient balance). Changes: - New plugin: plugins/model-providers/zai-coding/ with anthropic_messages api_mode - Register zai-coding in PROVIDER_REGISTRY (hermes_cli/auth.py) with inference_base_url pointing to the Anthropic endpoint - Add provider aliases: zai-coding, zai-coding-plan, glm-coding, z-ai-coding Co-Authored-By: Oz --- hermes_cli/auth.py | 9 +++++ .../model-providers/zai-coding/__init__.py | 33 +++++++++++++++++++ .../model-providers/zai-coding/plugin.yaml | 5 +++ 3 files changed, 47 insertions(+) create mode 100644 plugins/model-providers/zai-coding/__init__.py create mode 100644 plugins/model-providers/zai-coding/plugin.yaml diff --git a/hermes_cli/auth.py b/hermes_cli/auth.py index 6f4fc3446361b..b0122352b4c89 100644 --- a/hermes_cli/auth.py +++ b/hermes_cli/auth.py @@ -262,6 +262,14 @@ class ProviderConfig: api_key_env_vars=("GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"), base_url_env_var="GLM_BASE_URL", ), + "zai-coding": ProviderConfig( + id="zai-coding", + name="Z.AI / GLM (Coding Plan)", + auth_type="api_key", + inference_base_url="https://api.z.ai/api/anthropic", + api_key_env_vars=("GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"), + base_url_env_var="GLM_BASE_URL", + ), "kimi-coding": ProviderConfig( id="kimi-coding", name="Kimi / Moonshot", @@ -1422,6 +1430,7 @@ def resolve_provider( # Normalize provider aliases _PROVIDER_ALIASES = { "glm": "zai", "z-ai": "zai", "z.ai": "zai", "zhipu": "zai", + "zai-coding": "zai-coding", "zai-coding-plan": "zai-coding", "glm-coding": "zai-coding", "z-ai-coding": "zai-coding", "google": "gemini", "google-gemini": "gemini", "google-ai-studio": "gemini", "x-ai": "xai", "x.ai": "xai", "grok": "xai", "xai-oauth": "xai-oauth", "x-ai-oauth": "xai-oauth", diff --git a/plugins/model-providers/zai-coding/__init__.py b/plugins/model-providers/zai-coding/__init__.py new file mode 100644 index 0000000000000..0a7238a80d981 --- /dev/null +++ b/plugins/model-providers/zai-coding/__init__.py @@ -0,0 +1,33 @@ +"""Z.AI GLM Coding Plan provider profile. + +Separate from the standard `zai` profile because the coding plan +uses the Anthropic-compatible endpoint (api.z.ai/api/anthropic) +instead of the OpenAI-compatible /api/paas/v4 endpoint. + +The coding plan quota is ONLY accessible via the Anthropic endpoint. +""" + +from providers import register_provider +from providers.base import ProviderProfile + + +zai_coding = ProviderProfile( + name="zai-coding", + aliases=("zai-coding-plan", "glm-coding", "z-ai-coding"), + api_mode="anthropic_messages", + env_vars=("GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"), + display_name="Z.AI (GLM Coding Plan)", + description="Z.AI GLM Coding Plan — Anthropic-compatible endpoint", + signup_url="https://z.ai/", + base_url="https://api.z.ai/api/anthropic", + auth_type="api_key", + fallback_models=( + "glm-5.1", + "glm-5-turbo", + "glm-4.7", + "glm-4.5-air", + ), + default_aux_model="glm-4.5-air", +) + +register_provider(zai_coding) diff --git a/plugins/model-providers/zai-coding/plugin.yaml b/plugins/model-providers/zai-coding/plugin.yaml new file mode 100644 index 0000000000000..60c2a4c4af41a --- /dev/null +++ b/plugins/model-providers/zai-coding/plugin.yaml @@ -0,0 +1,5 @@ +name: zai-coding-provider +kind: model-provider +version: 1.0.0 +description: Z.AI GLM Coding Plan (Anthropic-compatible endpoint) +author: Nous Research