Skip to content

[Feature]: complete GLM Coding Plan quota support for open.bigmodel.cn #1168

Description

@c3right

Area

Provider quota / account plans

Current status

This request is partially implemented.

Current dev already contains a Z.AI GLM Coding Plan quota probe in:

src/providers/quota.ts

That implementation currently supports the api.z.ai Coding Plan route and projects GLM quota information into OpenCodex's existing normalized quota model.

The remaining work is to support the independently verified Zhipu BigModel Coding Plan contract at:

https://open.bigmodel.cn

and to parse the actual data.limits[] response shape rather than assuming one fixed set of flattened fields.

Confirmed BigModel endpoint

Live validation against a Zhipu GLM Coding Plan V1 individual subscription succeeded with:

GET https://open.bigmodel.cn/api/monitor/usage/quota/limit
Authorization: <API_KEY>

Important:

Authorization

contains the API key directly for this endpoint.

Do not prepend:

Bearer

unless separately verified for the specific host.

The model-routing base associated with this account can be:

https://open.bigmodel.cn/api/coding/paas/v4

What prevents this today?

The current OpenCodex quota implementation recognizes:

https://api.z.ai
https://api.z.ai/api/coding/paas/v4

but not:

https://open.bigmodel.cn
https://open.bigmodel.cn/api/coding/paas/v4

The current Z.AI probe also assumes a response shape containing fields such as:

fiveHourPercent
fiveHourUsage
weeklyPercent
weeklyUsage

The verified BigModel response instead exposes quota windows through:

data.limits[]

with explicit window metadata.

Therefore the current Z.AI probe should not be treated as complete support for the BigModel Coding Plan contract.

Verified response-driven parsing

The upstream response contains quota entries such as:

type = TOKENS_LIMIT
unit = 3
percentage = <used percentage>
nextResetTime = <reset timestamp>

Observed mapping:

unit = 3 -> rolling five-hour token window
unit = 6 -> weekly token window

The parser should use those explicit units instead of inferring window identity from reset ordering.

For example:

unit=3
percentage=72
nextResetTime=<timestamp>

should normalize to:

fiveHourPercent = 72
fiveHourResetAt = <timestamp>

And, when present:

unit=6
percentage=31
nextResetTime=<timestamp>

should normalize to:

weeklyPercent = 31
weeklyResetAt = <timestamp>

Plan-version behavior

Do not hard-code the presence of weekly or monthly limits based on the product name.

Live validation showed a V1 individual Coding Plan returning only:

5-hour used: 1%
5-hour remaining: 99%
weekly window: absent

That is a valid response.

Different Coding Plan generations may expose additional windows.

The contract should therefore be response-driven:

  • parse only limits actually returned by the upstream;
  • unit=3 is the confirmed rolling five-hour window;
  • unit=6 is the confirmed weekly window when present;
  • missing weekly/monthly windows are normal;
  • unknown future unit values should not be guessed;
  • if useful, unknown verified windows can be preserved as bounded custom windows until their meaning is established.

What OpenCodex should do

1. Recognize BigModel Coding Plan hosts

Extend the canonical host admission for the GLM Coding Plan quota probe to include the verified BigModel route.

At minimum:

https://open.bigmodel.cn/api/coding/paas/v4

The credential must never be sent to lookalike or arbitrary configured hosts.

2. Use the correct BigModel quota endpoint

For BigModel Coding Plan:

GET https://open.bigmodel.cn/api/monitor/usage/quota/limit

with the host-specific authentication contract.

Do not redirect credentials to another host.

3. Parse data.limits[]

Treat the returned limit rows as the source of truth.

Known mappings:

TOKENS_LIMIT + unit=3 -> five-hour window
TOKENS_LIMIT + unit=6 -> weekly window

Use:

percentage
nextResetTime

for normalized usage/reset values.

4. Preserve current Z.AI behavior

Supporting BigModel must not regress the existing:

api.z.ai

quota path.

If the two services expose materially different request/auth/response contracts, keep their parsing branches explicit rather than pretending they are identical because they belong to the same provider family.

5. Fail safely

Quota probing is observational only.

A failed, unsupported, malformed, or unavailable quota request must not affect:

  • model routing;
  • API-key use for inference;
  • normal provider availability.

Do not expose API keys or raw upstream quota bodies through the normal management API or Dashboard.

Expected Dashboard behavior

For an account returning only the V1 five-hour limit:

GLM Coding Plan

5-hour
1% used · 99% remaining
Resets: <local reset time>

For a newer account returning both known windows:

GLM Coding Plan

5-hour
72% used · 28% remaining
Resets: <time>

Weekly
31% used · 69% remaining
Resets: <date/time>

Do not render a fake weekly row when the upstream did not return one.

Acceptance criteria

  • OpenCodex has a GLM/Z.AI quota-probe foundation.
  • open.bigmodel.cn/api/coding/paas/v4 is recognized as an eligible Coding Plan configuration.
  • BigModel quota requests use the verified canonical quota endpoint.
  • BigModel authentication uses its verified host-specific contract.
  • data.limits[] is parsed response-first.
  • unit=3 maps to the rolling five-hour quota.
  • unit=6 maps to the weekly quota when present.
  • Missing weekly/monthly windows are accepted normally.
  • Unknown window units are not silently misclassified.
  • nextResetTime is normalized and displayed when supplied.
  • Existing api.z.ai quota behavior remains covered.
  • Quota-probe failure never breaks inference.
  • Credentials and raw quota payloads remain out of normal logs/UI responses.
  • Tests cover BigModel V1 five-hour-only and multi-window responses.

Checks

  • Current dev implementation was re-audited.
  • Existing Z.AI quota work is acknowledged rather than duplicated.
  • Live BigModel endpoint behavior has been provided by the reporter.
  • BigModel-specific contract implemented and verified.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolOAuth, credentials, Codex pool, quota, failover, plansenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions