Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 63b5dd8

Browse files
committed
feat: add GLM-5.1 model to Z.ai provider
1 parent c3cae39 commit 63b5dd8

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

packages/types/src/providers/zai.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ZaiApiLine } from "../provider-settings.js"
55
// https://docs.z.ai/guides/llm/glm-4-32b-0414-128k
66
// https://docs.z.ai/guides/llm/glm-4.5
77
// https://docs.z.ai/guides/llm/glm-4.6
8+
// https://docs.z.ai/guides/llm/glm-5.1
89
// https://docs.z.ai/guides/overview/pricing
910
// https://bigmodel.cn/pricing
1011

@@ -135,6 +136,21 @@ export const internationalZAiModels = {
135136
description:
136137
"GLM-5 is Zhipu's next-generation model with a 202k context window and built-in thinking capabilities. It delivers state-of-the-art reasoning, coding, and agentic performance.",
137138
},
139+
"glm-5.1": {
140+
maxTokens: 131_072,
141+
contextWindow: 200_000,
142+
supportsImages: false,
143+
supportsPromptCache: true,
144+
supportsReasoningEffort: ["disable", "medium"],
145+
reasoningEffort: "medium",
146+
preserveReasoning: true,
147+
inputPrice: 1.4,
148+
outputPrice: 4.4,
149+
cacheWritesPrice: 0,
150+
cacheReadsPrice: 0.26,
151+
description:
152+
"GLM-5.1 is Zhipu's most capable model with a 200k context window, 128k max output, and built-in thinking capabilities. It delivers top-tier reasoning, coding, and agentic performance.",
153+
},
138154
"glm-4.7-flash": {
139155
maxTokens: 16_384,
140156
contextWindow: 200_000,
@@ -311,6 +327,21 @@ export const mainlandZAiModels = {
311327
description:
312328
"GLM-5 is Zhipu's next-generation model with a 202k context window and built-in thinking capabilities. It delivers state-of-the-art reasoning, coding, and agentic performance.",
313329
},
330+
"glm-5.1": {
331+
maxTokens: 131_072,
332+
contextWindow: 204_800,
333+
supportsImages: false,
334+
supportsPromptCache: true,
335+
supportsReasoningEffort: ["disable", "medium"],
336+
reasoningEffort: "medium",
337+
preserveReasoning: true,
338+
inputPrice: 0.68,
339+
outputPrice: 2.28,
340+
cacheWritesPrice: 0,
341+
cacheReadsPrice: 0.13,
342+
description:
343+
"GLM-5.1 is Zhipu's most capable model with a 200k context window, 128k max output, and built-in thinking capabilities. It delivers top-tier reasoning, coding, and agentic performance.",
344+
},
314345
"glm-4.7-flash": {
315346
maxTokens: 16_384,
316347
contextWindow: 204_800,

src/api/providers/__tests__/zai.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ describe("ZAiHandler", () => {
9898
expect(model.info.preserveReasoning).toBe(true)
9999
})
100100

101+
it("should return GLM-5.1 international model with thinking support and 128k max output", () => {
102+
const testModelId: InternationalZAiModelId = "glm-5.1"
103+
const handlerWithModel = new ZAiHandler({
104+
apiModelId: testModelId,
105+
zaiApiKey: "test-zai-api-key",
106+
zaiApiLine: "international_coding",
107+
})
108+
const model = handlerWithModel.getModel()
109+
expect(model.id).toBe(testModelId)
110+
expect(model.info).toEqual(internationalZAiModels[testModelId])
111+
expect(model.info.contextWindow).toBe(200_000)
112+
expect(model.info.maxTokens).toBe(131_072)
113+
expect(model.info.supportsReasoningEffort).toEqual(["disable", "medium"])
114+
expect(model.info.reasoningEffort).toBe("medium")
115+
expect(model.info.preserveReasoning).toBe(true)
116+
expect(model.info.supportsImages).toBe(false)
117+
})
118+
101119
it("should return GLM-4.5v international model with vision support", () => {
102120
const testModelId: InternationalZAiModelId = "glm-4.5v"
103121
const handlerWithModel = new ZAiHandler({
@@ -178,6 +196,24 @@ describe("ZAiHandler", () => {
178196
expect(model.info.contextWindow).toBe(131_072)
179197
})
180198

199+
it("should return GLM-5.1 China model with thinking support and 128k max output", () => {
200+
const testModelId: MainlandZAiModelId = "glm-5.1"
201+
const handlerWithModel = new ZAiHandler({
202+
apiModelId: testModelId,
203+
zaiApiKey: "test-zai-api-key",
204+
zaiApiLine: "china_coding",
205+
})
206+
const model = handlerWithModel.getModel()
207+
expect(model.id).toBe(testModelId)
208+
expect(model.info).toEqual(mainlandZAiModels[testModelId])
209+
expect(model.info.contextWindow).toBe(204_800)
210+
expect(model.info.maxTokens).toBe(131_072)
211+
expect(model.info.supportsReasoningEffort).toEqual(["disable", "medium"])
212+
expect(model.info.reasoningEffort).toBe("medium")
213+
expect(model.info.preserveReasoning).toBe(true)
214+
expect(model.info.supportsImages).toBe(false)
215+
})
216+
181217
it("should return GLM-4.7 China model with thinking support", () => {
182218
const testModelId: MainlandZAiModelId = "glm-4.7"
183219
const handlerWithModel = new ZAiHandler({

0 commit comments

Comments
 (0)