feat: add zhipu and zhipu-coding provider (#199)

AN Long created

Change summary

internal/providers/configs/zhipu-coding.json | 98 ++++++++++++++++++++++
internal/providers/configs/zhipu.json        | 98 ++++++++++++++++++++++
internal/providers/providers.go              | 16 +++
pkg/catwalk/provider.go                      |  4 
4 files changed, 216 insertions(+)

Detailed changes

internal/providers/configs/zhipu-coding.json 🔗

@@ -0,0 +1,98 @@
+{
+  "name": "Zhipu Coding",
+  "id": "zhipu-coding",
+  "api_key": "$ZHIPU_API_KEY",
+  "api_endpoint": "https://open.bigmodel.cn/api/coding/paas/v4",
+  "type": "openai-compat",
+  "default_large_model_id": "glm-4.7",
+  "default_small_model_id": "glm-4.7-flash",
+  "models": [
+    {
+      "id": "glm-5",
+      "name": "GLM-5",
+      "cost_per_1m_in": 1.0,
+      "cost_per_1m_out": 3.2,
+      "cost_per_1m_in_cached": 0.2,
+      "context_window": 204800,
+      "default_max_tokens": 65536,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.7",
+      "name": "GLM-4.7",
+      "cost_per_1m_in": 0.42,
+      "cost_per_1m_out": 2.2,
+      "cost_per_1m_in_cached": 0.11,
+      "context_window": 204800,
+      "default_max_tokens": 102400,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.7-flash",
+      "name": "GLM-4.7 Flash",
+      "cost_per_1m_in": 0.07,
+      "cost_per_1m_out": 0.4,
+      "cost_per_1m_in_cached": 0.01,
+      "context_window": 200000,
+      "default_max_tokens": 65550,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.6",
+      "name": "GLM-4.6",
+      "cost_per_1m_in": 0.39,
+      "cost_per_1m_out": 1.9,
+      "cost_per_1m_in_cached": 0.11,
+      "context_window": 204800,
+      "default_max_tokens": 102400,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.6v",
+      "name": "GLM-4.6V",
+      "cost_per_1m_in": 0.3,
+      "cost_per_1m_out": 0.9,
+      "context_window": 131072,
+      "default_max_tokens": 65536,
+      "can_reason": true,
+      "supports_attachments": true
+    },
+    {
+      "id": "glm-4.5",
+      "name": "GLM-4.5",
+      "cost_per_1m_in": 0.6,
+      "cost_per_1m_out": 2.2,
+      "cost_per_1m_in_cached": 0.11,
+      "context_window": 131072,
+      "default_max_tokens": 49152,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.5-air",
+      "name": "GLM-4.5-Air",
+      "cost_per_1m_in": 0.13,
+      "cost_per_1m_out": 0.85,
+      "cost_per_1m_in_cached": 0.03,
+      "context_window": 131072,
+      "default_max_tokens": 49152,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.5v",
+      "name": "GLM-4.5V",
+      "cost_per_1m_in": 0.6,
+      "cost_per_1m_out": 1.8,
+      "cost_per_1m_in_cached": 0.11,
+      "context_window": 65536,
+      "default_max_tokens": 8192,
+      "can_reason": true,
+      "supports_attachments": true
+    }
+  ]
+}

internal/providers/configs/zhipu.json 🔗

@@ -0,0 +1,98 @@
+{
+  "name": "Zhipu",
+  "id": "zhipu",
+  "api_key": "$ZHIPU_API_KEY",
+  "api_endpoint": "https://open.bigmodel.cn/api/paas/v4",
+  "type": "openai-compat",
+  "default_large_model_id": "glm-4.7",
+  "default_small_model_id": "glm-4.7-flash",
+  "models": [
+    {
+      "id": "glm-5",
+      "name": "GLM-5",
+      "cost_per_1m_in": 1.0,
+      "cost_per_1m_out": 3.2,
+      "cost_per_1m_in_cached": 0.2,
+      "context_window": 204800,
+      "default_max_tokens": 65536,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.7",
+      "name": "GLM-4.7",
+      "cost_per_1m_in": 0.42,
+      "cost_per_1m_out": 2.2,
+      "cost_per_1m_in_cached": 0.11,
+      "context_window": 204800,
+      "default_max_tokens": 102400,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.7-flash",
+      "name": "GLM-4.7 Flash",
+      "cost_per_1m_in": 0.07,
+      "cost_per_1m_out": 0.4,
+      "cost_per_1m_in_cached": 0.01,
+      "context_window": 200000,
+      "default_max_tokens": 65550,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.6",
+      "name": "GLM-4.6",
+      "cost_per_1m_in": 0.39,
+      "cost_per_1m_out": 1.9,
+      "cost_per_1m_in_cached": 0.11,
+      "context_window": 204800,
+      "default_max_tokens": 102400,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.6v",
+      "name": "GLM-4.6V",
+      "cost_per_1m_in": 0.3,
+      "cost_per_1m_out": 0.9,
+      "context_window": 131072,
+      "default_max_tokens": 65536,
+      "can_reason": true,
+      "supports_attachments": true
+    },
+    {
+      "id": "glm-4.5",
+      "name": "GLM-4.5",
+      "cost_per_1m_in": 0.6,
+      "cost_per_1m_out": 2.2,
+      "cost_per_1m_in_cached": 0.11,
+      "context_window": 131072,
+      "default_max_tokens": 49152,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.5-air",
+      "name": "GLM-4.5-Air",
+      "cost_per_1m_in": 0.13,
+      "cost_per_1m_out": 0.85,
+      "cost_per_1m_in_cached": 0.03,
+      "context_window": 131072,
+      "default_max_tokens": 49152,
+      "can_reason": true,
+      "supports_attachments": false
+    },
+    {
+      "id": "glm-4.5v",
+      "name": "GLM-4.5V",
+      "cost_per_1m_in": 0.6,
+      "cost_per_1m_out": 1.8,
+      "cost_per_1m_in_cached": 0.11,
+      "context_window": 65536,
+      "default_max_tokens": 8192,
+      "can_reason": true,
+      "supports_attachments": true
+    }
+  ]
+}

internal/providers/providers.go 🔗

@@ -36,6 +36,12 @@ var xAIConfig []byte
 //go:embed configs/zai.json
 var zAIConfig []byte
 
+//go:embed configs/zhipu.json
+var zhipuConfig []byte
+
+//go:embed configs/zhipu-coding.json
+var zhipuCodingConfig []byte
+
 //go:embed configs/bedrock.json
 var bedrockConfig []byte
 
@@ -90,6 +96,8 @@ var providerRegistry = []ProviderFunc{
 	vertexAIProvider,
 	xAIProvider,
 	zAIProvider,
+	zhipuProvider,
+	zhipuCodingProvider,
 	kimiCodingProvider,
 	groqProvider,
 	openRouterProvider,
@@ -161,6 +169,14 @@ func zAIProvider() catwalk.Provider {
 	return loadProviderFromConfig(zAIConfig)
 }
 
+func zhipuProvider() catwalk.Provider {
+	return loadProviderFromConfig(zhipuConfig)
+}
+
+func zhipuCodingProvider() catwalk.Provider {
+	return loadProviderFromConfig(zhipuCodingConfig)
+}
+
 func openRouterProvider() catwalk.Provider {
 	return loadProviderFromConfig(openRouterConfig)
 }

pkg/catwalk/provider.go 🔗

@@ -30,6 +30,8 @@ const (
 	InferenceProviderVertexAI     InferenceProvider = "vertexai"
 	InferenceProviderXAI          InferenceProvider = "xai"
 	InferenceProviderZAI          InferenceProvider = "zai"
+	InferenceProviderZhipu        InferenceProvider = "zhipu"
+	InferenceProviderZhipuCoding  InferenceProvider = "zhipu-coding"
 	InferenceProviderGROQ         InferenceProvider = "groq"
 	InferenceProviderOpenRouter   InferenceProvider = "openrouter"
 	InferenceProviderCerebras     InferenceProvider = "cerebras"
@@ -97,6 +99,8 @@ func KnownProviders() []InferenceProvider {
 		InferenceProviderVertexAI,
 		InferenceProviderXAI,
 		InferenceProviderZAI,
+		InferenceProviderZhipu,
+		InferenceProviderZhipuCoding,
 		InferenceProviderGROQ,
 		InferenceProviderOpenRouter,
 		InferenceProviderCerebras,