Quick start
export GLM_API_KEY=... # or ZAI_API_KEY / Z_AI_API_KEY
bunx zai-usage # quota overview
What it reads
Four undocumented Z.ai endpoints, using your GLM Coding Plan API key only. Nothing is written anywhere; the optional AI coach receives aggregate metrics only — never your prompts or code (details).
GET /api/monitor/usage/quota/limit— plan level, 5-hour token %, monthly tool-call %GET /api/monitor/usage/model-usage— per-model tokens and calls per windowGET /api/biz/customer-package-reset/list— reset packs and your customerId (auto-discovery)GET /api/platform-charge-zai/bill/day— the day-level billing ledger everything else is computed from
Modes
| Mode | What it tells you |
|---|---|
| (default) | 5-hour quota %, per-model rolling windows, reset packs |
usage | per-model tokens/calls across Hour/24h/7d/30d/current month |
week / month | behavioral review: this span vs previous, 8 tip rules, AI coach |
bill [YYYY-MM] | month ledger: list-price spend, billed vs plan-covered, cache savings, MoM |
benefits · codingplan-benefits | lifetime plan value since first billed month (--since YYYY-MM) |
prices | price points learned from your own ledger |
estimate | what a hypothetical workload would cost on list prices |
runway | how long until the 5h window / monthly calls run out at current pace |
compare | diff two accounts (e.g. Lite vs Pro) side by side |
export | raw ledger as CSV or JSONL |
check | agent gate: --json, exit codes, thresholds for automations |
Flags and annotated output for every mode are in the full guide.
Install
# run without installing
bunx zai-usage
npx zai-usage
# or install the single file
curl -fsSL -o ~/.local/bin/zai-usage \
https://raw.githubusercontent.com/LogicIncZo/zai-usage/main/zai-usage.ts
chmod +x ~/.local/bin/zai-usage