Expand description
§Coding Plan Usage / Quota Query
Query the remaining quota and consumption statistics for the GLM Coding
Plan via the monitor API GET /api/monitor/usage/quota/limit.
The Coding Plan applies two quota windows — a five-hour time window
(TIME_LIMIT) and a weekly token window (TOKENS_LIMIT) — and reports the
configured cap, consumed percentage, and next reset time for each. This
module surfaces them as strongly-typed CodingPlanUsageResponse.
Verified against the official glm-plan-usage plugin
(https://docs.bigmodel.cn/cn/coding-plan/extension/usage-query-plugin)
and the community CLI https://github.com/JinHanAI/coding-plan-monitor.
§Quick start
use zai_rs::client::ZaiClient;
use zai_rs::usage::CodingPlanUsageRequest;
let resp = CodingPlanUsageRequest::new().send_via(&client).await?;
let usage = resp.summary();
if let Some(five_hour) = usage.time_limit() {
tracing::info!(
"5h window: {}/{} used ({} remaining, {}%), resets at {}",
five_hour.used,
five_hour.quota,
five_hour.remaining,
five_hour.percentage,
five_hour
.next_reset_at
.as_ref()
.map_or_else(|| "?".to_string(), |datetime| datetime.to_rfc3339())
);
}
if let Some(weekly) = usage.tokens_limit() {
tracing::info!(
"weekly tokens: {} remaining of {}",
weekly.remaining,
weekly.quota
);
}§Switching to the international endpoint
Override the monitor family base on the ZaiClient builder:
use zai_rs::client::{ApiFamily, ZaiClient};
use zai_rs::usage::CodingPlanUsageRequest;
static INTL: &str = "https://api.z.ai/api/monitor";
let client = ZaiClient::builder("your-api-key")
.endpoint(ApiFamily::Monitor, INTL)
.build()?;
let resp = CodingPlanUsageRequest::new().send_via(&client).await?;Structs§
- Coding
Plan Quota Limit - One quota window reported by the monitor endpoint.
- Coding
Plan Quota Summary - Easy-to-use quota-window view derived from
CodingPlanQuotaLimit. - Coding
Plan Usage Data datapayload returned by the quota-limit endpoint.- Coding
Plan Usage Detail - Per-model usage breakdown returned for some quota windows.
- Coding
Plan Usage Request - Coding Plan usage / quota query request
(
GET /api/monitor/usage/quota/limit). - Coding
Plan Usage Response - Standard
{code, msg, success, data}envelope used by the monitor API. - Coding
Plan Usage Summary - Easy-to-use Coding Plan usage view.
Enums§
- Coding
Plan Quota Kind - Normalized quota-window kind.
Functions§
- query
- Query the Coding Plan usage endpoint via
clientand return the typed raw response. - query_
summary - Query the Coding Plan usage endpoint via
clientand return a normalized summary.