feat: add GLM-5.1 model to Z.ai provider

This commit is contained in:
Roo Code 2026-04-08 10:18:03 +00:00
parent c3cae397a1
commit 63b5dd86b6
2 changed files with 67 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import { ZaiApiLine } from "../provider-settings.js"
// https://docs.z.ai/guides/llm/glm-4-32b-0414-128k
// https://docs.z.ai/guides/llm/glm-4.5
// https://docs.z.ai/guides/llm/glm-4.6
// https://docs.z.ai/guides/llm/glm-5.1
// https://docs.z.ai/guides/overview/pricing
// https://bigmodel.cn/pricing
@ -135,6 +136,21 @@ export const internationalZAiModels = {
description:
"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.",
},
"glm-5.1": {
maxTokens: 131_072,
contextWindow: 200_000,
supportsImages: false,
supportsPromptCache: true,
supportsReasoningEffort: ["disable", "medium"],
reasoningEffort: "medium",
preserveReasoning: true,
inputPrice: 1.4,
outputPrice: 4.4,
cacheWritesPrice: 0,
cacheReadsPrice: 0.26,
description:
"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.",
},
"glm-4.7-flash": {
maxTokens: 16_384,
contextWindow: 200_000,
@ -311,6 +327,21 @@ export const mainlandZAiModels = {
description:
"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.",
},
"glm-5.1": {
maxTokens: 131_072,
contextWindow: 204_800,
supportsImages: false,
supportsPromptCache: true,
supportsReasoningEffort: ["disable", "medium"],
reasoningEffort: "medium",
preserveReasoning: true,
inputPrice: 0.68,
outputPrice: 2.28,
cacheWritesPrice: 0,
cacheReadsPrice: 0.13,
description:
"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.",
},
"glm-4.7-flash": {
maxTokens: 16_384,
contextWindow: 204_800,

View file

@ -98,6 +98,24 @@ describe("ZAiHandler", () => {
expect(model.info.preserveReasoning).toBe(true)
})
it("should return GLM-5.1 international model with thinking support and 128k max output", () => {
const testModelId: InternationalZAiModelId = "glm-5.1"
const handlerWithModel = new ZAiHandler({
apiModelId: testModelId,
zaiApiKey: "test-zai-api-key",
zaiApiLine: "international_coding",
})
const model = handlerWithModel.getModel()
expect(model.id).toBe(testModelId)
expect(model.info).toEqual(internationalZAiModels[testModelId])
expect(model.info.contextWindow).toBe(200_000)
expect(model.info.maxTokens).toBe(131_072)
expect(model.info.supportsReasoningEffort).toEqual(["disable", "medium"])
expect(model.info.reasoningEffort).toBe("medium")
expect(model.info.preserveReasoning).toBe(true)
expect(model.info.supportsImages).toBe(false)
})
it("should return GLM-4.5v international model with vision support", () => {
const testModelId: InternationalZAiModelId = "glm-4.5v"
const handlerWithModel = new ZAiHandler({
@ -178,6 +196,24 @@ describe("ZAiHandler", () => {
expect(model.info.contextWindow).toBe(131_072)
})
it("should return GLM-5.1 China model with thinking support and 128k max output", () => {
const testModelId: MainlandZAiModelId = "glm-5.1"
const handlerWithModel = new ZAiHandler({
apiModelId: testModelId,
zaiApiKey: "test-zai-api-key",
zaiApiLine: "china_coding",
})
const model = handlerWithModel.getModel()
expect(model.id).toBe(testModelId)
expect(model.info).toEqual(mainlandZAiModels[testModelId])
expect(model.info.contextWindow).toBe(204_800)
expect(model.info.maxTokens).toBe(131_072)
expect(model.info.supportsReasoningEffort).toEqual(["disable", "medium"])
expect(model.info.reasoningEffort).toBe("medium")
expect(model.info.preserveReasoning).toBe(true)
expect(model.info.supportsImages).toBe(false)
})
it("should return GLM-4.7 China model with thinking support", () => {
const testModelId: MainlandZAiModelId = "glm-4.7"
const handlerWithModel = new ZAiHandler({