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

Commit 0822a1f

Browse files
committed
feat: add GLM-4.7 model with preserved thinking support for Z.ai provider
1 parent 6b141fb commit 0822a1f

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

packages/types/src/providers/zai.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ 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-4.7
9+
// https://docs.z.ai/guides/capabilities/thinking-mode
810
// https://docs.z.ai/guides/overview/pricing
911
// https://bigmodel.cn/pricing
1012

@@ -107,6 +109,21 @@ export const internationalZAiModels = {
107109
description:
108110
"GLM-4.6 is Zhipu's newest model with an extended context window of up to 200k tokens, providing enhanced capabilities for processing longer documents and conversations.",
109111
},
112+
"glm-4.7": {
113+
maxTokens: 98_304,
114+
contextWindow: 200_000,
115+
supportsImages: false,
116+
supportsPromptCache: true,
117+
supportsNativeTools: true,
118+
defaultToolProtocol: "native",
119+
preserveReasoning: true,
120+
inputPrice: 0.6,
121+
outputPrice: 2.2,
122+
cacheWritesPrice: 0,
123+
cacheReadsPrice: 0.11,
124+
description:
125+
"GLM-4.7 is Zhipu's latest model with preserved thinking capabilities, allowing reasoning content to be retained across turns for improved coherence and cache efficiency.",
126+
},
110127
"glm-4-32b-0414-128k": {
111128
maxTokens: 98_304,
112129
contextWindow: 131_072,
@@ -221,6 +238,21 @@ export const mainlandZAiModels = {
221238
description:
222239
"GLM-4.6 is Zhipu's newest model with an extended context window of up to 200k tokens, providing enhanced capabilities for processing longer documents and conversations.",
223240
},
241+
"glm-4.7": {
242+
maxTokens: 98_304,
243+
contextWindow: 204_800,
244+
supportsImages: false,
245+
supportsPromptCache: true,
246+
supportsNativeTools: true,
247+
defaultToolProtocol: "native",
248+
preserveReasoning: true,
249+
inputPrice: 0.29,
250+
outputPrice: 1.14,
251+
cacheWritesPrice: 0,
252+
cacheReadsPrice: 0.057,
253+
description:
254+
"GLM-4.7 is Zhipu's latest model with preserved thinking capabilities, allowing reasoning content to be retained across turns for improved coherence and cache efficiency.",
255+
},
224256
} as const satisfies Record<string, ModelInfo>
225257

226258
export const ZAI_DEFAULT_TEMPERATURE = 0.6

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
66
import {
77
type InternationalZAiModelId,
88
type MainlandZAiModelId,
9+
type ModelInfo,
910
internationalZAiDefaultModelId,
1011
mainlandZAiDefaultModelId,
1112
internationalZAiModels,
@@ -96,6 +97,23 @@ describe("ZAiHandler", () => {
9697
expect(model.info.maxTokens).toBe(16_384)
9798
expect(model.info.contextWindow).toBe(131_072)
9899
})
100+
101+
it("should return GLM-4.7 international model with preserved thinking support", () => {
102+
const testModelId: InternationalZAiModelId = "glm-4.7"
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+
// GLM-4.7 should have preserveReasoning enabled for interleaved thinking mode
112+
// This allows reasoning_content to be passed back during tool call continuation
113+
expect((model.info as ModelInfo).preserveReasoning).toBe(true)
114+
expect(model.info.contextWindow).toBe(200_000)
115+
expect(model.info.supportsNativeTools).toBe(true)
116+
})
99117
})
100118

101119
describe("China Z AI", () => {
@@ -161,6 +179,23 @@ describe("ZAiHandler", () => {
161179
expect(model.info.maxTokens).toBe(16_384)
162180
expect(model.info.contextWindow).toBe(131_072)
163181
})
182+
183+
it("should return GLM-4.7 China model with preserved thinking support", () => {
184+
const testModelId: MainlandZAiModelId = "glm-4.7"
185+
const handlerWithModel = new ZAiHandler({
186+
apiModelId: testModelId,
187+
zaiApiKey: "test-zai-api-key",
188+
zaiApiLine: "china_coding",
189+
})
190+
const model = handlerWithModel.getModel()
191+
expect(model.id).toBe(testModelId)
192+
expect(model.info).toEqual(mainlandZAiModels[testModelId])
193+
// GLM-4.7 should have preserveReasoning enabled for interleaved thinking mode
194+
// This allows reasoning_content to be passed back during tool call continuation
195+
expect((model.info as ModelInfo).preserveReasoning).toBe(true)
196+
expect(model.info.contextWindow).toBe(204_800)
197+
expect(model.info.supportsNativeTools).toBe(true)
198+
})
164199
})
165200

166201
describe("International API", () => {

0 commit comments

Comments
 (0)