Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions hermes_cli/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
33 changes: 33 additions & 0 deletions plugins/model-providers/zai-coding/__init__.py
Original file line number Diff line number Diff line change
@@ -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(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add regression coverage for the end-to-end runtime resolution of this profile: with zai-coding selected, assert the resolved base URL remains https://api.z.ai/api/anthropic and the API mode is anthropic_messages. The runtime mode is derived from the URL at hermes_cli/runtime_provider.py:2057-2062, so profile registration alone does not exercise the routing contract.

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)
5 changes: 5 additions & 0 deletions plugins/model-providers/zai-coding/plugin.yaml
Original file line number Diff line number Diff line change
@@ -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