Skip to content

Latest commit

 

History

History
197 lines (159 loc) · 5.74 KB

zai.md

File metadata and controls

197 lines (159 loc) · 5.74 KB

Z.ai

Tracks Z.ai (Zhipu AI) usage quotas for GLM coding plans.

These API endpoints are not documented in Z.ai's public API reference. They are used internally by the subscription management UI and work with both OAuth tokens and API keys.

Overview

  • Protocol: REST (plain JSON)
  • Base URL: https://api.z.ai/
  • CN Base URL: https://open.bigmodel.cn/ when apiRegion is cn
  • Auth: API key via environment variable (ZAI_API_KEY, fallback GLM_API_KEY) or account JSON
  • Session utilization: percentage (0-100)
  • Weekly utilization: percentage (0-100)
  • Web searches: count-based (used / limit)
  • Reset periods: 5 hours (session), 7 days (weekly), monthly (web searches, from subscription renewal date)

Setup

  1. Subscribe to a GLM Coding plan and get your API key from the Z.ai console
  2. Set ZAI_API_KEY (fallback: GLM_API_KEY)

OpenBurn is a GUI app. A one-off export ... in a terminal session will not be visible when you launch OpenBurn from Spotlight/Launchpad. Persist it, then restart OpenBurn.

zsh (~/.zshrc):

export ZAI_API_KEY="YOUR_API_KEY"

fish (universal var):

set -Ux ZAI_API_KEY "YOUR_API_KEY"
  1. Enable the Z.ai plugin in OpenBurn settings

Optional account JSON fields:

{
  "apiKey": "YOUR_API_KEY",
  "apiHost": "https://api.z.ai",
  "quotaUrl": "https://api.z.ai/api/monitor/usage/quota/limit",
  "apiRegion": "cn"
}
  • apiHost changes both subscription and quota base URLs.
  • quotaUrl overrides only the quota endpoint.
  • apiRegion: "cn" uses https://open.bigmodel.cn.
  • apiKey may include or omit the Bearer prefix.

Endpoints

GET /api/biz/subscription/list

Returns the user's active subscription(s). Used to extract the plan name.

Headers

Header Required Value
Authorization yes Bearer <api_key>
Accept yes application/json

Response

{
  "code": 200,
  "data": [
    {
      "id": "169359",
      "customerId": "71321768207710758",
      "productName": "GLM Coding Max",
      "description": "-All Pro plan benefits\n-4× Pro plan usage...",
      "status": "VALID",
      "purchaseTime": "2026-01-12 16:55:13",
      "valid": "2026-02-12 16:55:13-2026-03-12 16:55:13",
      "autoRenew": 1,
      "initialPrice": 30.0,
      "actualPrice": 30.0,
      "currentPeriod": 2,
      "currentRenewTime": "2026-01-12",
      "nextRenewTime": "2026-02-12",
      "billingCycle": "monthly",
      "inCurrentPeriod": true,
      "paymentChannel": "STRIPE"
    }
  ],
  "success": true
}

Used fields:

  • productName — plan display name (e.g. "GLM Coding Max")
  • nextRenewTime — monthly reset date for web search quota (ISO date, e.g. "2026-03-12")

GET /api/monitor/usage/quota/limit

Returns session token usage and web search quotas.

Headers

Header Required Value
Authorization yes Bearer <api_key>
Accept yes application/json

Response

{
  "code": 200,
  "data": {
    "limits": [
      {
        "type": "TOKENS_LIMIT",
        "unit": 3,
        "number": 5,
        "usage": 800000000,
        "currentValue": 127694464,
        "remaining": 672305536,
        "percentage": 15,
        "nextResetTime": 1770648402389
      },
      {
        "type": "TIME_LIMIT",
        "unit": 5,
        "number": 1,
        "usage": 4000,
        "currentValue": 1828,
        "remaining": 2172,
        "percentage": 45,
        "usageDetails": [
          {
            "modelCode": "search-prime",
            "usage": 1433
          },
          {
            "modelCode": "web-reader",
            "usage": 462
          },
          {
            "modelCode": "zread",
            "usage": 0
          }
        ]
      }
    ]
  },
  "success": true
}

TOKENS_LIMIT:

  • usage — total token limit (e.g. 800M)
  • currentValue — tokens consumed
  • remaining — tokens remaining
  • percentage — usage as percentage (0-100)
  • nextResetTime — epoch milliseconds of next reset
  • unit: 3, number: 5 — 5-hour rolling period (session)
  • unit: 6, number: 7 — 7-day rolling period (weekly)

TIME_LIMIT:

  • usage — total web search/reader call limit (e.g. 4000)
  • currentValue — calls consumed
  • remaining — calls remaining
  • percentage — usage as percentage (0-100)
  • usageDetails — per-model breakdown (search-prime, web-reader, zread)
  • unit: 5, number: 1 — monthly period (no nextResetTime; resets on the 1st of each month at 00:00 UTC)

Displayed Lines

Line Description
Session Token usage as percentage (0-100%) with 5h reset timer
Weekly Token usage as percentage (0-100%) with 7-day reset timer
Web Searches Web search/reader call count (used / limit), resets on the 1st of each month

Errors

Condition Message
No API key "No ZAI_API_KEY found. Set up environment variable first."
401/403 "API key invalid. Check your Z.ai API key."
HTTP error "Usage request failed (HTTP {status}). Try again later."
Network error "Usage request failed. Check your connection."
Invalid JSON "Usage response invalid. Try again later."