Skip to content

feat(llm): add z-ai-coding provider for GLM Coding Plan endpoint#258

Open
givingwu wants to merge 2 commits into
alibaba:mainfrom
givingwu:feat/z-ai-coding-plan-provider
Open

feat(llm): add z-ai-coding provider for GLM Coding Plan endpoint#258
givingwu wants to merge 2 commits into
alibaba:mainfrom
givingwu:feat/z-ai-coding-plan-provider

Conversation

@givingwu

@givingwu givingwu commented Jul 1, 2026

Copy link
Copy Markdown

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

Description

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

Related Issues

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>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.go
  • extensions/vscode/src/shared/providers.ts
  • internal/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants