From f9053eca65ce53e2056d2c65ac784805c059607d Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Mon, 20 Oct 2025 18:29:37 -0600 Subject: [PATCH 1/7] feat(zai): add GLM-4.5-X, AirX, Flash; sync with Z.ai docs; keep canonical api line keys --- packages/types/src/providers/zai.ts | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/packages/types/src/providers/zai.ts b/packages/types/src/providers/zai.ts index b4049b81228..399530093c1 100644 --- a/packages/types/src/providers/zai.ts +++ b/packages/types/src/providers/zai.ts @@ -32,6 +32,40 @@ export const internationalZAiModels = { description: "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.", }, + "glm-4.5-x": { + maxTokens: 98_304, + contextWindow: 131_072, + supportsImages: false, + supportsPromptCache: true, + inputPrice: 0.6, + outputPrice: 2.2, + cacheWritesPrice: 0, + cacheReadsPrice: 0.11, + description: + "GLM-4.5-X is a high-performance variant optimized for strong reasoning with ultra-fast responses.", + }, + "glm-4.5-airx": { + maxTokens: 98_304, + contextWindow: 131_072, + supportsImages: false, + supportsPromptCache: true, + inputPrice: 0.2, + outputPrice: 1.1, + cacheWritesPrice: 0, + cacheReadsPrice: 0.03, + description: "GLM-4.5-AirX is a lightweight, ultra-fast variant delivering strong performance with lower cost.", + }, + "glm-4.5-flash": { + maxTokens: 98_304, + contextWindow: 131_072, + supportsImages: false, + supportsPromptCache: true, + inputPrice: 0, + outputPrice: 0, + cacheWritesPrice: 0, + cacheReadsPrice: 0, + description: "GLM-4.5-Flash is a free, high-speed model excellent for reasoning, coding, and agentic tasks.", + }, "glm-4.6": { maxTokens: 98_304, contextWindow: 204_800, @@ -113,6 +147,40 @@ export const mainlandZAiModels = { }, ], }, + "glm-4.5-x": { + maxTokens: 98_304, + contextWindow: 131_072, + supportsImages: false, + supportsPromptCache: true, + inputPrice: 0.29, + outputPrice: 1.14, + cacheWritesPrice: 0, + cacheReadsPrice: 0.057, + description: + "GLM-4.5-X is a high-performance variant optimized for strong reasoning with ultra-fast responses.", + }, + "glm-4.5-airx": { + maxTokens: 98_304, + contextWindow: 131_072, + supportsImages: false, + supportsPromptCache: true, + inputPrice: 0.1, + outputPrice: 0.6, + cacheWritesPrice: 0, + cacheReadsPrice: 0.02, + description: "GLM-4.5-AirX is a lightweight, ultra-fast variant delivering strong performance with lower cost.", + }, + "glm-4.5-flash": { + maxTokens: 98_304, + contextWindow: 131_072, + supportsImages: false, + supportsPromptCache: true, + inputPrice: 0, + outputPrice: 0, + cacheWritesPrice: 0, + cacheReadsPrice: 0, + description: "GLM-4.5-Flash is a free, high-speed model excellent for reasoning, coding, and agentic tasks.", + }, "glm-4.6": { maxTokens: 98_304, contextWindow: 204_800, From 81c33176bc4a337a33fda0ad8a32c0cfc5ab31b2 Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Mon, 20 Oct 2025 18:36:56 -0600 Subject: [PATCH 2/7] feat(zai): add GLM-4.5V vision model (supportsImages, pricing, 16K max output); add tests --- packages/types/src/providers/zai.ts | 24 ++++++++++++++++++++ src/api/providers/__tests__/zai.spec.ts | 30 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/packages/types/src/providers/zai.ts b/packages/types/src/providers/zai.ts index 399530093c1..db9af28d6db 100644 --- a/packages/types/src/providers/zai.ts +++ b/packages/types/src/providers/zai.ts @@ -66,6 +66,18 @@ export const internationalZAiModels = { cacheReadsPrice: 0, description: "GLM-4.5-Flash is a free, high-speed model excellent for reasoning, coding, and agentic tasks.", }, + "glm-4.5v": { + maxTokens: 16_384, + contextWindow: 131_072, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 0.6, + outputPrice: 1.8, + cacheWritesPrice: 0, + cacheReadsPrice: 0.11, + description: + "GLM-4.5V is Z.AI's multimodal visual reasoning model (image/video/text/file input), optimized for GUI tasks, grounding, and document/video understanding.", + }, "glm-4.6": { maxTokens: 98_304, contextWindow: 204_800, @@ -181,6 +193,18 @@ export const mainlandZAiModels = { cacheReadsPrice: 0, description: "GLM-4.5-Flash is a free, high-speed model excellent for reasoning, coding, and agentic tasks.", }, + "glm-4.5v": { + maxTokens: 16_384, + contextWindow: 131_072, + supportsImages: true, + supportsPromptCache: true, + inputPrice: 0.29, + outputPrice: 0.93, + cacheWritesPrice: 0, + cacheReadsPrice: 0.057, + description: + "GLM-4.5V is Z.AI's multimodal visual reasoning model (image/video/text/file input), optimized for GUI tasks, grounding, and document/video understanding.", + }, "glm-4.6": { maxTokens: 98_304, contextWindow: 204_800, diff --git a/src/api/providers/__tests__/zai.spec.ts b/src/api/providers/__tests__/zai.spec.ts index bb892960889..c132e19a4ee 100644 --- a/src/api/providers/__tests__/zai.spec.ts +++ b/src/api/providers/__tests__/zai.spec.ts @@ -84,6 +84,21 @@ describe("ZAiHandler", () => { expect(model.info).toEqual(internationalZAiModels[testModelId]) expect(model.info.contextWindow).toBe(204_800) }) + + it("should return GLM-4.5v international model with vision support", () => { + const testModelId: InternationalZAiModelId = "glm-4.5v" + 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.supportsImages).toBe(true) + expect(model.info.maxTokens).toBe(16_384) + expect(model.info.contextWindow).toBe(131_072) + }) }) describe("China Z AI", () => { @@ -134,6 +149,21 @@ describe("ZAiHandler", () => { expect(model.info).toEqual(mainlandZAiModels[testModelId]) expect(model.info.contextWindow).toBe(204_800) }) + + it("should return GLM-4.5v China model with vision support", () => { + const testModelId: MainlandZAiModelId = "glm-4.5v" + 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.supportsImages).toBe(true) + expect(model.info.maxTokens).toBe(16_384) + expect(model.info.contextWindow).toBe(131_072) + }) }) describe("Default behavior", () => { From a0621e4d86a29c8d48173a0ec74d1d038c646b12 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 21 Oct 2025 18:28:11 +0000 Subject: [PATCH 3/7] feat(types,zai): sync Z.AI international model map and tests - Update pricing, context window, and capabilities for: glm-4.5-x, glm-4.5-airx, glm-4.5-flash, glm-4.5v, glm-4.6 - Add glm-4-32b-0414-128k - Align tests with new model specs --- packages/types/src/providers/zai.ts | 29 +++++++++++++++++-------- src/api/providers/__tests__/zai.spec.ts | 4 ++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/packages/types/src/providers/zai.ts b/packages/types/src/providers/zai.ts index db9af28d6db..21e8800cf8c 100644 --- a/packages/types/src/providers/zai.ts +++ b/packages/types/src/providers/zai.ts @@ -37,10 +37,10 @@ export const internationalZAiModels = { contextWindow: 131_072, supportsImages: false, supportsPromptCache: true, - inputPrice: 0.6, - outputPrice: 2.2, + inputPrice: 2.2, + outputPrice: 8.9, cacheWritesPrice: 0, - cacheReadsPrice: 0.11, + cacheReadsPrice: 0.45, description: "GLM-4.5-X is a high-performance variant optimized for strong reasoning with ultra-fast responses.", }, @@ -49,17 +49,17 @@ export const internationalZAiModels = { contextWindow: 131_072, supportsImages: false, supportsPromptCache: true, - inputPrice: 0.2, - outputPrice: 1.1, + inputPrice: 1.1, + outputPrice: 4.5, cacheWritesPrice: 0, - cacheReadsPrice: 0.03, + cacheReadsPrice: 0.22, description: "GLM-4.5-AirX is a lightweight, ultra-fast variant delivering strong performance with lower cost.", }, "glm-4.5-flash": { maxTokens: 98_304, contextWindow: 131_072, supportsImages: false, - supportsPromptCache: true, + supportsPromptCache: false, inputPrice: 0, outputPrice: 0, cacheWritesPrice: 0, @@ -67,7 +67,7 @@ export const internationalZAiModels = { description: "GLM-4.5-Flash is a free, high-speed model excellent for reasoning, coding, and agentic tasks.", }, "glm-4.5v": { - maxTokens: 16_384, + maxTokens: 98_304, contextWindow: 131_072, supportsImages: true, supportsPromptCache: true, @@ -80,7 +80,7 @@ export const internationalZAiModels = { }, "glm-4.6": { maxTokens: 98_304, - contextWindow: 204_800, + contextWindow: 200_000, supportsImages: false, supportsPromptCache: true, inputPrice: 0.6, @@ -90,6 +90,17 @@ export const internationalZAiModels = { description: "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.", }, + "glm-4-32b-0414-128k": { + maxTokens: 98_304, + contextWindow: 131_072, + supportsImages: false, + supportsPromptCache: false, + inputPrice: 0.1, + outputPrice: 0.1, + cacheWritesPrice: 0, + cacheReadsPrice: 0, + description: "GLM-4-32B is a 32 billion parameter model with 128k context length, optimized for efficiency.", + }, } as const satisfies Record export type MainlandZAiModelId = keyof typeof mainlandZAiModels diff --git a/src/api/providers/__tests__/zai.spec.ts b/src/api/providers/__tests__/zai.spec.ts index c132e19a4ee..4c5c0b75240 100644 --- a/src/api/providers/__tests__/zai.spec.ts +++ b/src/api/providers/__tests__/zai.spec.ts @@ -82,7 +82,7 @@ describe("ZAiHandler", () => { const model = handlerWithModel.getModel() expect(model.id).toBe(testModelId) expect(model.info).toEqual(internationalZAiModels[testModelId]) - expect(model.info.contextWindow).toBe(204_800) + expect(model.info.contextWindow).toBe(200_000) }) it("should return GLM-4.5v international model with vision support", () => { @@ -96,7 +96,7 @@ describe("ZAiHandler", () => { expect(model.id).toBe(testModelId) expect(model.info).toEqual(internationalZAiModels[testModelId]) expect(model.info.supportsImages).toBe(true) - expect(model.info.maxTokens).toBe(16_384) + expect(model.info.maxTokens).toBe(98_304) expect(model.info.contextWindow).toBe(131_072) }) }) From 03a0111186c138a846804443d195e6c510793553 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 21 Oct 2025 18:45:04 +0000 Subject: [PATCH 4/7] fix(zai): align handler generics with expanded model ids to satisfy CI compile step --- src/api/providers/zai.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/providers/zai.ts b/src/api/providers/zai.ts index ce5aab9dd9f..a72be571d4f 100644 --- a/src/api/providers/zai.ts +++ b/src/api/providers/zai.ts @@ -5,6 +5,7 @@ import { mainlandZAiDefaultModelId, type InternationalZAiModelId, type MainlandZAiModelId, + type ModelInfo, ZAI_DEFAULT_TEMPERATURE, zaiApiLineConfigs, } from "@roo-code/types" @@ -13,11 +14,11 @@ import type { ApiHandlerOptions } from "../../shared/api" import { BaseOpenAiCompatibleProvider } from "./base-openai-compatible-provider" -export class ZAiHandler extends BaseOpenAiCompatibleProvider { +export class ZAiHandler extends BaseOpenAiCompatibleProvider { constructor(options: ApiHandlerOptions) { const isChina = zaiApiLineConfigs[options.zaiApiLine ?? "international_coding"].isChina - const models = isChina ? mainlandZAiModels : internationalZAiModels - const defaultModelId = isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId + const models = (isChina ? mainlandZAiModels : internationalZAiModels) as unknown as Record + const defaultModelId = (isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId) as string super({ ...options, From e0cb1bbc6ff15aa910d09868ed51faa071b52918 Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Tue, 21 Oct 2025 14:15:28 -0600 Subject: [PATCH 5/7] chore(zai): remove tier pricing blocks for Z.ai models --- packages/types/src/providers/zai.ts | 77 +++---------------------- src/api/providers/__tests__/zai.spec.ts | 2 +- 2 files changed, 8 insertions(+), 71 deletions(-) diff --git a/packages/types/src/providers/zai.ts b/packages/types/src/providers/zai.ts index 21e8800cf8c..de70ab27e75 100644 --- a/packages/types/src/providers/zai.ts +++ b/packages/types/src/providers/zai.ts @@ -2,11 +2,14 @@ import type { ModelInfo } from "../model.js" import { ZaiApiLine } from "../provider-settings.js" // Z AI +// 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/overview/pricing +// https://bigmodel.cn/pricing export type InternationalZAiModelId = keyof typeof internationalZAiModels -export const internationalZAiDefaultModelId: InternationalZAiModelId = "glm-4.5" +export const internationalZAiDefaultModelId: InternationalZAiModelId = "glm-4.6" export const internationalZAiModels = { "glm-4.5": { maxTokens: 98_304, @@ -59,7 +62,7 @@ export const internationalZAiModels = { maxTokens: 98_304, contextWindow: 131_072, supportsImages: false, - supportsPromptCache: false, + supportsPromptCache: true, inputPrice: 0, outputPrice: 0, cacheWritesPrice: 0, @@ -67,7 +70,7 @@ export const internationalZAiModels = { description: "GLM-4.5-Flash is a free, high-speed model excellent for reasoning, coding, and agentic tasks.", }, "glm-4.5v": { - maxTokens: 98_304, + maxTokens: 16_384, contextWindow: 131_072, supportsImages: true, supportsPromptCache: true, @@ -104,7 +107,7 @@ export const internationalZAiModels = { } as const satisfies Record export type MainlandZAiModelId = keyof typeof mainlandZAiModels -export const mainlandZAiDefaultModelId: MainlandZAiModelId = "glm-4.5" +export const mainlandZAiDefaultModelId: MainlandZAiModelId = "glm-4.6" export const mainlandZAiModels = { "glm-4.5": { maxTokens: 98_304, @@ -117,26 +120,6 @@ export const mainlandZAiModels = { cacheReadsPrice: 0.057, description: "GLM-4.5 is Zhipu's latest featured model. Its comprehensive capabilities in reasoning, coding, and agent reach the state-of-the-art (SOTA) level among open-source models, with a context length of up to 128k.", - tiers: [ - { - contextWindow: 32_000, - inputPrice: 0.21, - outputPrice: 1.0, - cacheReadsPrice: 0.043, - }, - { - contextWindow: 128_000, - inputPrice: 0.29, - outputPrice: 1.14, - cacheReadsPrice: 0.057, - }, - { - contextWindow: Infinity, - inputPrice: 0.29, - outputPrice: 1.14, - cacheReadsPrice: 0.057, - }, - ], }, "glm-4.5-air": { maxTokens: 98_304, @@ -149,26 +132,6 @@ export const mainlandZAiModels = { cacheReadsPrice: 0.02, description: "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.", - tiers: [ - { - contextWindow: 32_000, - inputPrice: 0.07, - outputPrice: 0.4, - cacheReadsPrice: 0.014, - }, - { - contextWindow: 128_000, - inputPrice: 0.1, - outputPrice: 0.6, - cacheReadsPrice: 0.02, - }, - { - contextWindow: Infinity, - inputPrice: 0.1, - outputPrice: 0.6, - cacheReadsPrice: 0.02, - }, - ], }, "glm-4.5-x": { maxTokens: 98_304, @@ -227,32 +190,6 @@ export const mainlandZAiModels = { cacheReadsPrice: 0.057, description: "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.", - tiers: [ - { - contextWindow: 32_000, - inputPrice: 0.21, - outputPrice: 1.0, - cacheReadsPrice: 0.043, - }, - { - contextWindow: 128_000, - inputPrice: 0.29, - outputPrice: 1.14, - cacheReadsPrice: 0.057, - }, - { - contextWindow: 200_000, - inputPrice: 0.29, - outputPrice: 1.14, - cacheReadsPrice: 0.057, - }, - { - contextWindow: Infinity, - inputPrice: 0.29, - outputPrice: 1.14, - cacheReadsPrice: 0.057, - }, - ], }, } as const satisfies Record diff --git a/src/api/providers/__tests__/zai.spec.ts b/src/api/providers/__tests__/zai.spec.ts index 4c5c0b75240..14e3e246538 100644 --- a/src/api/providers/__tests__/zai.spec.ts +++ b/src/api/providers/__tests__/zai.spec.ts @@ -96,7 +96,7 @@ describe("ZAiHandler", () => { expect(model.id).toBe(testModelId) expect(model.info).toEqual(internationalZAiModels[testModelId]) expect(model.info.supportsImages).toBe(true) - expect(model.info.maxTokens).toBe(98_304) + expect(model.info.maxTokens).toBe(16_384) expect(model.info.contextWindow).toBe(131_072) }) }) From ddffad3fc9b537b9b69583068e868b1f83fe65b6 Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Tue, 21 Oct 2025 14:34:43 -0600 Subject: [PATCH 6/7] fix(zai): simplify names in zaiApiLineConfigs for clarity --- packages/types/src/providers/zai.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/types/src/providers/zai.ts b/packages/types/src/providers/zai.ts index de70ab27e75..ad3495e883d 100644 --- a/packages/types/src/providers/zai.ts +++ b/packages/types/src/providers/zai.ts @@ -197,12 +197,12 @@ export const ZAI_DEFAULT_TEMPERATURE = 0 export const zaiApiLineConfigs = { international_coding: { - name: "International Coding Plan", + name: "International", baseUrl: "https://api.z.ai/api/coding/paas/v4", isChina: false, }, china_coding: { - name: "China Coding Plan", + name: "China", baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4", isChina: true, }, From 234136e60c6e40fd0c22ac41b69eda7d53064675 Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Tue, 21 Oct 2025 14:37:42 -0600 Subject: [PATCH 7/7] chore(zai): set default temperature to 0.6 --- packages/types/src/providers/zai.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/types/src/providers/zai.ts b/packages/types/src/providers/zai.ts index ad3495e883d..2b156cfb51f 100644 --- a/packages/types/src/providers/zai.ts +++ b/packages/types/src/providers/zai.ts @@ -193,7 +193,7 @@ export const mainlandZAiModels = { }, } as const satisfies Record -export const ZAI_DEFAULT_TEMPERATURE = 0 +export const ZAI_DEFAULT_TEMPERATURE = 0.6 export const zaiApiLineConfigs = { international_coding: {