Skip to content

Commit 4c3ad85

Browse files
committed
fix(zai): restore typed model IDs, add GLM-4.5V tiers test, clarify intl tiers comment
1 parent bd2d22e commit 4c3ad85

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

packages/types/src/providers/zai.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const internationalZAiModels = {
4242
outputPrice: 1.8,
4343
cacheWritesPrice: 0,
4444
cacheReadsPrice: 0.11,
45+
// International pricing tiers for GLM-4.5V are not publicly documented as of 2025-10-20; mainland tiers are defined below.
4546
description: "GLM-4.5V is Zhipu's new generation of visual reasoning models based on the MOE architecture.",
4647
},
4748
"glm-4.5-air": {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ describe("ZAiHandler", () => {
162162
expect(model.info.supportsImages).toBe(true)
163163
expect(model.info.contextWindow).toBe(64_000)
164164
})
165+
166+
it("should include tiers for GLM-4.5V China model", () => {
167+
const info = mainlandZAiModels["glm-4.5v"]
168+
expect(info.tiers?.length).toBe(3)
169+
})
165170
})
166171

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

src/api/providers/zai.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,30 @@ import {
88
} from "@roo-code/types"
99

1010
import type { ApiHandlerOptions } from "../../shared/api"
11+
import type { InternationalZAiModelId, MainlandZAiModelId, ModelInfo } from "@roo-code/types"
1112

1213
import { BaseOpenAiCompatibleProvider } from "./base-openai-compatible-provider"
1314

14-
export class ZAiHandler extends BaseOpenAiCompatibleProvider<string> {
15+
type ZAiModelId = InternationalZAiModelId | MainlandZAiModelId
16+
17+
export class ZAiHandler extends BaseOpenAiCompatibleProvider<ZAiModelId> {
1518
constructor(options: ApiHandlerOptions) {
16-
const isChina = zaiApiLineConfigs[options.zaiApiLine ?? "international_coding"].isChina
17-
const models = (isChina ? mainlandZAiModels : internationalZAiModels) as Record<
18-
string,
19-
import("@roo-code/types").ModelInfo
19+
const line = options.zaiApiLine ?? "international_coding"
20+
const { isChina, baseUrl } = zaiApiLineConfigs[line]
21+
22+
const defaultModelId = isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId
23+
const providerModels = (isChina ? mainlandZAiModels : internationalZAiModels) as unknown as Record<
24+
ZAiModelId,
25+
ModelInfo
2026
>
21-
const defaultModelId = (isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId) as string
2227

2328
super({
2429
...options,
2530
providerName: "Z AI",
26-
baseURL: zaiApiLineConfigs[options.zaiApiLine ?? "international_coding"].baseUrl,
31+
baseURL: baseUrl,
2732
apiKey: options.zaiApiKey ?? "not-provided",
28-
defaultProviderModelId: defaultModelId as any,
29-
providerModels: models as any,
33+
defaultProviderModelId: defaultModelId,
34+
providerModels,
3035
defaultTemperature: ZAI_DEFAULT_TEMPERATURE,
3136
})
3237
}

0 commit comments

Comments
 (0)