Skip to content

Commit e5f5438

Browse files
hungthai1401hannesrudolph
authored andcommitted
feat: add GLM-4.5V model support with image capabilities for z.ai provider
1 parent 4e6c717 commit e5f5438

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

packages/types/src/providers/zai.ts

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ export const internationalZAiModels = {
3232
description:
3333
"GLM-4.5-Air is the lightweight version of GLM-4.5. It balances performance and cost-effectiveness, and can flexibly switch to hybrid thinking models.",
3434
},
35+
"glm-4.5v": {
36+
maxTokens: 16_384,
37+
contextWindow: 64_000,
38+
supportsImages: true,
39+
supportsPromptCache: true,
40+
inputPrice: 0.6,
41+
outputPrice: 1.8,
42+
cacheWritesPrice: 0,
43+
cacheReadsPrice: 0.11,
44+
description:
45+
"GLM-4.5V is Zhipu's new generation of visual reasoning models based on the MOE architecture.",
46+
},
3547
"glm-4.6": {
3648
maxTokens: 98_304,
3749
contextWindow: 204_800,
@@ -43,7 +55,7 @@ export const internationalZAiModels = {
4355
cacheReadsPrice: 0.11,
4456
description:
4557
"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.",
46-
},
58+
}
4759
} as const satisfies Record<string, ModelInfo>
4860

4961
export type MainlandZAiModelId = keyof typeof mainlandZAiModels
@@ -113,6 +125,38 @@ export const mainlandZAiModels = {
113125
},
114126
],
115127
},
128+
"glm-4.5v": {
129+
maxTokens: 16_384,
130+
contextWindow: 64_000,
131+
supportsImages: true,
132+
supportsPromptCache: true,
133+
inputPrice: 0.6,
134+
outputPrice: 1.8,
135+
cacheWritesPrice: 0,
136+
cacheReadsPrice: 0.11,
137+
description:
138+
"GLM-4.5V is Zhipu's new generation of visual reasoning models based on the MOE architecture.",
139+
tiers: [
140+
{
141+
contextWindow: 32_000,
142+
inputPrice: 0.21,
143+
outputPrice: 0.4,
144+
cacheReadsPrice: 0.06
145+
},
146+
{
147+
contextWindow: 64_000,
148+
inputPrice: 0.6,
149+
outputPrice: 1.8,
150+
cacheReadsPrice: 0.11
151+
},
152+
{
153+
contextWindow: Infinity,
154+
inputPrice: 0.6,
155+
outputPrice: 1.8,
156+
cacheReadsPrice: 0.11
157+
},
158+
],
159+
},
116160
"glm-4.6": {
117161
maxTokens: 98_304,
118162
contextWindow: 204_800,
@@ -150,7 +194,7 @@ export const mainlandZAiModels = {
150194
cacheReadsPrice: 0.057,
151195
},
152196
],
153-
},
197+
}
154198
} as const satisfies Record<string, ModelInfo>
155199

156200
export const ZAI_DEFAULT_TEMPERATURE = 0

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ describe("ZAiHandler", () => {
8484
expect(model.info).toEqual(internationalZAiModels[testModelId])
8585
expect(model.info.contextWindow).toBe(204_800)
8686
})
87+
88+
it("should return GLM-4.5V international model with image support", () => {
89+
const testModelId: InternationalZAiModelId = "glm-4.5v"
90+
const handlerWithModel = new ZAiHandler({
91+
apiModelId: testModelId,
92+
zaiApiKey: "test-zai-api-key",
93+
zaiApiLine: "international",
94+
})
95+
const model = handlerWithModel.getModel()
96+
expect(model.id).toBe(testModelId)
97+
expect(model.info).toEqual(internationalZAiModels[testModelId])
98+
expect(model.info.supportsImages).toBe(true)
99+
expect(model.info.contextWindow).toBe(64_000)
100+
})
87101
})
88102

89103
describe("China Z AI", () => {
@@ -134,6 +148,20 @@ describe("ZAiHandler", () => {
134148
expect(model.info).toEqual(mainlandZAiModels[testModelId])
135149
expect(model.info.contextWindow).toBe(204_800)
136150
})
151+
152+
it("should return GLM-4.5V China model with image support", () => {
153+
const testModelId: MainlandZAiModelId = "glm-4.5v"
154+
const handlerWithModel = new ZAiHandler({
155+
apiModelId: testModelId,
156+
zaiApiKey: "test-zai-api-key",
157+
zaiApiLine: "china",
158+
})
159+
const model = handlerWithModel.getModel()
160+
expect(model.id).toBe(testModelId)
161+
expect(model.info).toEqual(mainlandZAiModels[testModelId])
162+
expect(model.info.supportsImages).toBe(true)
163+
expect(model.info.contextWindow).toBe(64_000)
164+
})
137165
})
138166

139167
describe("Default behavior", () => {

0 commit comments

Comments
 (0)