Skip to content

Commit cf0a323

Browse files
lidge-junLucinegogo
andcommitted
feat(providers): add the Zhipu BigModel provider under a non-colliding id
Registers Zhipu's domestic BigModel pay-as-you-go endpoint (open.bigmodel.cn/api/paas/v4) as `zhipu-bigmodel`, distinct from the existing `zai` coding-plan preset. The id matters: `glm` and `glm-cn` are already bound in FREE_PROVIDER_DIRECTORY, and routedProviderConfig() canonicalizes a saved provider onto the registry baseUrl. Reusing either id would silently retarget an existing config's endpoint and send its API key to a different host. Metadata is complete rather than minimal: jawcodeBundle connects the `zai` bundle so the GLM families inherit authoritative context windows, glm-4.6's 204,800 window is declared explicitly so it survives a lookup miss, modalities are declared per model, and the thinking toggle maps efforts onto `thinking: {type}` instead of a rejected reasoning_effort. liveModels is deliberately absent until someone verifies the endpoint answers. Co-authored-by: Lucinegogo <[email protected]>
1 parent e0b9598 commit cf0a323

3 files changed

Lines changed: 56 additions & 2 deletions

File tree

‎src/generated/jawcode-model-metadata.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ const PROVIDER_ALIASES: Record<string, string> = {
2929
"gemini-antigravity": "google",
3030
"moonshot": "moonshot",
3131
"minimax": "minimax",
32-
"minimax-cn": "minimax"
32+
"minimax-cn": "minimax",
33+
"zhipu-bigmodel": "zai"
3334
} as const;
3435

3536
type Row = readonly [id: string, contextWindow?: number | null, maxTokens?: number | null, input?: string | null, reasoning?: 0 | 1 | null, wireModelId?: string | null, costInput?: number | null, costOutput?: number | null, costCacheRead?: number | null, costCacheWrite?: number | null];

‎src/providers/registry.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ const THINKING_TOGGLE_MAP: Record<string, string> = {
180180
const OPENCODE_GO_THINKING_TOGGLE_MODELS = [
181181
"mimo-v2.5", "mimo-v2.5-pro", "mimo-v2-omni", "mimo-v2-pro", "glm-5", "glm-5.1",
182182
];
183+
/**
184+
* Zhipu's domestic BigModel platform. Text families first, then the vision member: modalities are
185+
* declared per model because `noVisionModels` means the opposite of "text only" here — it routes
186+
* images through the proxy's vision sidecar (src/codex/catalog/provider-fetch.ts), a claim nobody
187+
* has verified for BigModel-hosted GLM.
188+
*/
189+
const ZHIPU_BIGMODEL_TEXT_MODELS = ["glm-4.6", "glm-4.7", "glm-4.7-flash", "glm-5", "glm-5.1"];
190+
const ZHIPU_BIGMODEL_MODELS = [...ZHIPU_BIGMODEL_TEXT_MODELS, "glm-4.6v"];
191+
const ZHIPU_BIGMODEL_INPUT_MODALITIES: Record<string, string[]> = {
192+
...Object.fromEntries(ZHIPU_BIGMODEL_TEXT_MODELS.map(id => [id, ["text"]])),
193+
"glm-4.6v": ["text", "image"],
194+
};
195+
const ZHIPU_BIGMODEL_THINKING_TOGGLE_MODELS = ["glm-4.6", "glm-4.7", "glm-5", "glm-5.1"];
183196
const THINKING_BUDGET_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
184197
const THINKING_BUDGET_MODELS = [
185198
"qwen3.5-397b", "qwen3.6-35b",
@@ -785,6 +798,45 @@ export const PROVIDER_REGISTRY: readonly ProviderRegistryEntry[] = [
785798
modelReasoningEfforts: Object.fromEntries(ZAI_GLM_52_MODELS.map(id => [id, ZAI_GLM_52_REASONING_EFFORTS])),
786799
preserveReasoningContentModels: ZAI_GLM_52_MODELS,
787800
},
801+
// Zhipu's domestic BigModel platform: OpenAI-compatible pay-as-you-go on open.bigmodel.cn — a
802+
// different host and billing product from the `zai` coding-plan subscription above.
803+
// The id is deliberately NOT `glm` or `glm-cn`: both are already bound in FREE_PROVIDER_DIRECTORY
804+
// (to api.z.ai and to the BigModel *coding* path), and routedProviderConfig() canonicalizes a
805+
// saved provider onto the registry baseUrl — reusing either id would silently retarget an
806+
// existing config's endpoint and send its API key to another host.
807+
// Evidence: docs.bigmodel.cn/api-reference (OpenAI-compatible chat completions),
808+
// docs.bigmodel.cn/cn/guide/models/text/glm-4.6 (thinking: {type: enabled|disabled}).
809+
// Originally proposed in #536 by @Lucinegogo.
810+
{
811+
id: "zhipu-bigmodel",
812+
label: "Zhipu AI — BigModel",
813+
baseUrl: "https://open.bigmodel.cn/api/paas/v4",
814+
adapter: "openai-chat",
815+
authKind: "key",
816+
dashboardUrl: "https://bigmodel.cn/console/usercenter/apikeys",
817+
defaultModel: "glm-4.6",
818+
models: ZHIPU_BIGMODEL_MODELS,
819+
// The GLM families here are the same ones the `zai` metadata bundle already describes, so the
820+
// bundle owns context windows and modalities for the whole list instead of a hand-copied table.
821+
jawcodeBundle: "zai",
822+
// Declared explicitly for the default model so its window survives a bundle-lookup miss:
823+
// without it, catalog normalization falls back to a generic 128k and compacts ~76,800 early.
824+
modelContextWindows: { "glm-4.6": 204_800 },
825+
modelInputModalities: ZHIPU_BIGMODEL_INPUT_MODALITIES,
826+
// GLM exposes a binary thinking knob, not an effort ladder: the adapter emits
827+
// `thinking: {type}` for these ids and would otherwise send a rejected reasoning_effort.
828+
thinkingToggleModels: ZHIPU_BIGMODEL_THINKING_TOGGLE_MODELS,
829+
modelReasoningEfforts: Object.fromEntries(
830+
ZHIPU_BIGMODEL_THINKING_TOGGLE_MODELS.map(id => [id, THINKING_TOGGLE_EFFORTS]),
831+
),
832+
modelReasoningEffortMap: Object.fromEntries(
833+
ZHIPU_BIGMODEL_THINKING_TOGGLE_MODELS.map(id => [id, THINKING_TOGGLE_MAP]),
834+
),
835+
preserveReasoningContentModels: ZHIPU_BIGMODEL_THINKING_TOGGLE_MODELS,
836+
// No liveModels: GET /api/paas/v4/models has not been observed to answer on this host, and a
837+
// false live claim yields an empty picker at runtime. Flip it on once someone verifies it.
838+
note: "Domestic BigModel pay-as-you-go endpoint (open.bigmodel.cn)",
839+
},
788840
{ id: "nanogpt", label: "NanoGPT", baseUrl: "https://nano-gpt.com/api/v1", adapter: "openai-chat", authKind: "key", dashboardUrl: "https://nano-gpt.com/api" },
789841
{ id: "synthetic", label: "Synthetic", baseUrl: "https://api.synthetic.new/openai/v1", adapter: "openai-chat", authKind: "key", dashboardUrl: "https://synthetic.new" },
790842
// SiliconFlow publishes an OpenAI-compatible chat endpoint and a dynamic model catalog. Do not

‎tests/provider-registry-parity.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function nativeTemplate(): Record<string, unknown> {
3232
const EXPECTED_KEY_PROVIDER_IDS = [
3333
"anthropic-apikey", "openai-apikey", "umans", "opencode-go", "neuralwatt", "openrouter", "orcarouter", "bizrouter", "groq", "google", "google-vertex", "azure-openai",
3434
"deepseek", "cerebras", "together", "fireworks", "firepass", "moonshot",
35-
"huggingface", "nvidia", "venice", "zai", "nanogpt", "synthetic", "siliconflow", "qwen-cloud", "tencent-coding-plan",
35+
"huggingface", "nvidia", "venice", "zai", "zhipu-bigmodel", "nanogpt", "synthetic", "siliconflow", "qwen-cloud", "tencent-coding-plan",
3636
"qianfan", "alibaba", "alibaba-token-plan", "alibaba-token-plan-intl", "parallel", "zenmux", "litellm", "ollama-cloud", "mistral",
3737
"minimax", "minimax-cn", "kimi-code", "opencode-zen", "vercel-ai-gateway",
3838
"opencode-free", "xiaomi", "kilo", "mimo-free", "cloudflare-ai-gateway", "cloudflare-workers-ai", "gitlab-duo",
@@ -721,6 +721,7 @@ describe("provider registry parity", () => {
721721
moonshot: "moonshot",
722722
minimax: "minimax",
723723
"minimax-cn": "minimax",
724+
"zhipu-bigmodel": "zai",
724725
});
725726
expect(resolveJawcodeProvider("gemini")).toBe("google");
726727
expect(resolveJawcodeProvider("minimax-cn")).toBe("minimax");

0 commit comments

Comments
 (0)