Skip to content

feat: add Zhipu Coding Plan provider (domestic China)#78

Merged
slkiser merged 4 commits into
slkiser:mainfrom
mengfanbo123:add-zhipu-provider
May 8, 2026
Merged

feat: add Zhipu Coding Plan provider (domestic China)#78
slkiser merged 4 commits into
slkiser:mainfrom
mengfanbo123:add-zhipu-provider

Conversation

@mengfanbo123
Copy link
Copy Markdown
Contributor

Summary

Adds a new Zhipu quota provider for the domestic China Zhipu Coding Plan (bigmodel.cn), mirroring the existing Z.ai provider (api.z.ai).

What's new

  • New provider: zhipu — queries https://bigmodel.cn/api/monitor/usage/quota/limit
  • Auth resolution: ZHIPU_API_KEY / ZHIPU_CODING_PLAN_API_KEY env vars → opencode.jsonc provider config (zhipu, zhipu-coding-plan, glm-coding-plan) → auth.json
  • Full feature parity with Z.ai provider: TUI sidebar, toast notifications, /quota command status report
  • Same response format as Z.ai (5h/weekly token windows + MCP monthly limit)

Files changed

File Change
src/lib/zhipu.ts New — quota fetcher (mirrors zai.ts)
src/lib/zhipu-auth.ts New — auth resolution (mirrors zai-auth.ts)
src/providers/zhipu.ts New — provider wrapper (mirrors zai.ts)
src/providers/registry.ts Register zhipuProvider
src/lib/provider-metadata.ts Add zhipu canonical ID, labels, synonyms, runtime IDs, shape
src/lib/types.ts Add zhipu-coding-plan to AuthData interface
src/lib/quota-status.ts Add zhipu diagnostics section for /quota command

Usage

Add to opencode.jsonc:

{
  "experimental": {
    "quotaToast": {
      "enabledProviders": ["zai", "zhipu", "kimi-code"]
    }
  }
}

And configure the provider:

{
  "provider": {
    "zhipu-coding-plan": {
      "name": "Zhipu Coding Plan",
      "options": { "apiKey": "{env:ZHIPU_API_KEY}" },
      // ...models...
    }
  }
}

Testing

  • npm run typecheck
  • npm run build
  • Published as @mingxy/[email protected] and tested in production

Why separate provider?

Z.ai (international) and Zhipu (domestic China) use different API endpoints and API keys. They serve different user bases and need independent auth resolution. The domestic endpoint is bigmodel.cn (not api.z.ai).

Adds a new 'zhipu' quota provider for the domestic China Zhipu Coding Plan (bigmodel.cn), mirroring the existing Z.ai (api.z.ai) provider.

- New files: src/lib/zhipu.ts, src/lib/zhipu-auth.ts, src/providers/zhipu.ts

- Updated: registry.ts, provider-metadata.ts, types.ts, quota-status.ts

- Quota API: https://bigmodel.cn/api/monitor/usage/quota/limit

- Auth: ZHIPU_API_KEY env var / opencode.jsonc provider config / auth.json

- Supports TUI sidebar, toast, and /quota command status report
@mengfanbo123
Copy link
Copy Markdown
Contributor Author

4c1b695e-b5e3-442e-8dff-c4c5c185ee4d

@slkiser
Copy link
Copy Markdown
Owner

slkiser commented May 5, 2026

@mengfanbo123 Thanks for the contribution, I'll take a look!

mengfanbo123 and others added 3 commits May 6, 2026 12:10
- Add zhipu entry to provider-metadata catalog test (between zai and nanogpt)
- Add zhipu section to quota-status inline snapshot (between zai and synthetic)
- Add zhipu auth/query mocks for quota-status tests
@slkiser
Copy link
Copy Markdown
Owner

slkiser commented May 8, 2026

@mengfanbo123 Thanks for the contribution

@slkiser slkiser merged commit bc5c20e into slkiser:main May 8, 2026
6 checks passed
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.

2 participants