feat(llm): add z-ai-coding provider for GLM Coding Plan endpoint#258
feat(llm): add z-ai-coding provider for GLM Coding Plan endpoint#258givingwu wants to merge 2 commits into
Conversation
Z.AI (智谱) subscribers to the GLM Coding Plan must route requests through the dedicated coding endpoint (https://open.bigmodel.cn/api/coding/paas/v4) for them to be billed against the subscription quota. The existing z-ai provider points at the generic pay-as-you-go endpoint (https://open.bigmodel.cn/api/paas/v4), so Coding Plan keys silently drain the wallet balance instead of consuming the plan quota, surfacing as a spurious "1113 余额不足" error even when the plan is barely used. Add a dedicated z-ai-coding provider following the existing *-tokenplan pattern (dashscope/dashscope-tokenplan, tencent-tokenhub/hy-tokenplan). It reuses Z_AI_API_KEY — the same key authenticates against both endpoints, so selecting this provider is all that's needed to activate the plan. The model list is restricted to the models officially supported by the Coding Plan to avoid selecting a non-plan model that falls back to wallet billing. - internal/llm/providers.go: register z-ai-coding preset - extensions/vscode/src/shared/providers.ts: mirror the preset (kept in sync with the Go registry per the file header) - internal/llm/providers_test.go: update the sorted provider list assertion Co-Authored-By: Oz <oz-agent@warp.dev>
|
|
|
✅ OpenCodeReview: No comments generated. Looks good to me. |
Subscribers to the Z.AI (Zhipu) GLM Coding Plan must route requests through the dedicated coding endpoint (https://open.bigmodel.cn/api/coding/paas/v4) to bill against the plan quota. The default z-ai preset points at the generic pay-as-you-go endpoint, so coding-plan keys silently drain the wallet and surface a spurious "1113 余额不足" error — a recurring trap for new users. Add a provider-specific callout at the end of the Docs config section showing the one-line fix that works today on any released version: ocr config set providers.z-ai.url https://open.bigmodel.cn/api/coding/paas/v4 This complements the z-ai-coding provider added in the previous commit: the provider gives a native first-class option going forward, while this doc tip rescues users already running released builds. Copy/localized for zh/en/ja. Co-Authored-By: Oz <oz-agent@warp.dev>
lizhengfeng101
left a comment
There was a problem hiding this comment.
Code Review
Thanks for the contribution — the problem statement is clear and the fix is well-motivated. A few items to address before merge:
1. Remove comments from the TypeScript provider preset
extensions/vscode/src/shared/providers.ts — the preset objects are plain data (JSON-like). The other entries in this array have no comments; this one shouldn't either. Please remove the comment block:
// GLM Coding Plan (智谱编程套餐). Dedicated coding endpoint bills against
// the subscription quota instead of the pay-as-you-go wallet. The same key
// authenticates both endpoints, so Z_AI_API_KEY is reused.2. Use a dedicated env var instead of reusing Z_AI_API_KEY
The existing tokenplan providers each define their own env var:
| Provider | EnvVar |
|---|---|
dashscope |
DASHSCOPE_API_KEY |
dashscope-tokenplan |
DASHSCOPE_TOKENPLAN_KEY |
tencent-tokenhub |
TENCENT_HUNYUAN_KEY |
hy-tokenplan |
TENCENT_HUNYUAN_TOKENPLAN_KEY |
Please follow the same convention — e.g. introduce Z_AI_CODING_API_KEY (or similar) so that users who have both a pay-as-you-go key and a Coding Plan key can configure them independently without collision.
3. Do not modify pages/ for a provider addition
Changes under pages/ (i18n files, DocsPage.tsx) are outside the scope of a provider registration PR. Provider additions should only touch:
internal/llm/providers.goextensions/vscode/src/shared/providers.tsinternal/llm/providers_test.go
Please revert the pages/ changes. Documentation updates for providers can be handled separately if needed.
4. Confirm: is the model list identical to z-ai on purpose?
The z-ai-coding model list (glm-5.2, glm-5.1, glm-5-turbo, glm-4.7) is exactly the same as the generic z-ai provider. The PR description says the list is "restricted to the models officially supported by the Coding Plan" — does the Coding Plan actually support all four of these models? If the plan only covers a subset, the list should be narrowed accordingly.
Z.AI (智谱) subscribers to the GLM Coding Plan must route requests through the dedicated coding endpoint (https://open.bigmodel.cn/api/coding/paas/v4) for them to be billed against the subscription quota. The existing z-ai provider points at the generic pay-as-you-go endpoint (https://open.bigmodel.cn/api/paas/v4), so Coding Plan keys silently drain the wallet balance instead of consuming the plan quota, surfacing as a spurious "1113 余额不足" error even when the plan is barely used.
Add a dedicated z-ai-coding provider following the existing *-tokenplan pattern (dashscope/dashscope-tokenplan, tencent-tokenhub/hy-tokenplan). It reuses Z_AI_API_KEY — the same key authenticates against both endpoints, so selecting this provider is all that's needed to activate the plan. The model list is restricted to the models officially supported by the Coding Plan to avoid selecting a non-plan model that falls back to wallet billing.
Description
Type of Change
How Has This Been Tested?
make testpasses locallyChecklist
go fmt,go vet)Related Issues