OmniRoute/open-sse/mcp-server/__tests__/glmCodingProviderConfig.test.ts
Chris Staley d01266c642 fix: remove glm-4.7-flashx from GLM Coding provider (429 insufficient balance)
Live-tested all GLM Coding models against the /api/coding/paas/v4
endpoint. glm-4.7-flashx returns 429 "Insufficient balance or no
resource package" and is not listed on the /models endpoint.

All other models (glm-5.1, glm-5, glm-5-turbo, glm-4.7, glm-4.7-flash,
glm-4.6v, glm-4.6, glm-4.5v, glm-4.5, glm-4.5-air) return 200.
2026-03-29 15:13:07 -06:00

86 lines
3 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { getRegistryEntry } from "../../config/providerRegistry.ts";
import { PROVIDER_ID_TO_ALIAS, getModelsByProviderId, getProviderModels } from "../../config/providerModels.ts";
import { supportsToolCalling } from "../../services/modelCapabilities.ts";
import { getPricingForModel } from "../../../src/shared/constants/pricing.ts";
describe("GLM Coding provider registry surfaces", () => {
it("registers the GLM Coding provider with the expected transport metadata", () => {
const entry = getRegistryEntry("glm");
expect(entry).toBeDefined();
expect(entry?.id).toBe("glm");
expect(entry?.alias).toBe("glm");
expect(entry?.format).toBe("claude");
expect(entry?.baseUrl).toBe("https://api.z.ai/api/anthropic/v1/messages");
expect(entry?.authType).toBe("apikey");
expect(entry?.authHeader).toBe("x-api-key");
expect(entry?.headers?.["Anthropic-Version"]).toBe("2023-06-01");
});
it("exposes the same GLM model inventory through registry-derived model helpers", () => {
const byProviderId = getModelsByProviderId("glm");
const byAlias = getProviderModels("glm");
expect(PROVIDER_ID_TO_ALIAS.glm).toBe("glm");
expect(byProviderId).toEqual(byAlias);
expect(byProviderId.map((model) => model.id)).toEqual([
"glm-5.1",
"glm-5",
"glm-5-turbo",
"glm-4.7-flash",
"glm-4.7",
"glm-4.6v",
"glm-4.6",
"glm-4.5v",
"glm-4.5",
"glm-4.5-air",
]);
});
it("applies the doc-backed GLM-5.1 context window override", () => {
const glm51 = getModelsByProviderId("glm").find((model) => model.id === "glm-5.1");
const glm5 = getModelsByProviderId("glm").find((model) => model.id === "glm-5");
expect(glm51).toBeDefined();
expect(glm51?.contextLength).toBe(204800);
expect(glm5?.contextLength).toBeUndefined();
});
it("keeps representative GLM Coding models tool-call capable and priced", () => {
expect(supportsToolCalling("glm/glm-5")).toBe(true);
expect(supportsToolCalling("glm/glm-4.7-flash")).toBe(true);
expect(supportsToolCalling("glm/glm-4.5-air")).toBe(true);
expect(getPricingForModel("glm", "glm-5")).toEqual({
input: 1.0,
output: 3.2,
cached: 0.2,
reasoning: 4.8,
cache_creation: 1.0,
});
expect(getPricingForModel("glm", "glm-4.7-flash")).toEqual({
input: 0,
output: 0,
cached: 0,
reasoning: 0,
cache_creation: 0,
});
expect(getPricingForModel("glm", "glm-4.5-air")).toEqual({
input: 0.2,
output: 1.1,
cached: 0.03,
reasoning: 1.1,
cache_creation: 0.2,
});
});
it("keeps the repo-derived GLM inventory internally aligned across registry and pricing surfaces", () => {
const modelIds = getModelsByProviderId("glm").map((model) => model.id);
for (const modelId of modelIds) {
expect(getPricingForModel("glm", modelId), `missing pricing for ${modelId}`).toBeTruthy();
}
});
});