Expand description
The Zai backend: the GLM coding plan’s monitor probe against
{host_root}/api/monitor/usage/quota/limit, authenticated by the
account’s flat token stamped onto ANTHROPIC_AUTH_TOKEN (no Bearer
prefix).
The configured base url carries the /api/anthropic chat prefix,
so the monitor URL derives from the scheme+host alone. Every Z.ai
monitor endpoint answers HTTP 200 regardless of outcome - a wrong
key and a wrong path share the status with a healthy response - so
the verdict lives inside the {success, code, msg} envelope.
Re-exports§
use std::time::SystemTime;🔒use async_trait::async_trait;🔒use reqwest::header::ACCEPT;🔒use reqwest::header::AUTHORIZATION;🔒use reqwest::header::HeaderMap;🔒use reqwest::header::HeaderValue;🔒use forge_primitives::usage::oauth::OauthUsageError;🔒use forge_primitives::usage::zai::QuotaLimitData;🔒use forge_primitives::usage::zai::QuotaLimitEntry;🔒use forge_primitives::usage::zai::QuotaLimitResponse;🔒use forge_primitives::usage::UsageSnapshot;🔒use forge_primitives::usage::UsageSourceKind;🔒use forge_primitives::usage::UsageWindow;🔒use crate::helpers::BaseUrlCredential;🔒use crate::helpers::MissingBase;🔒use crate::helpers::OAUTH_TIMEOUT;🔒use crate::helpers::base_url_credential;🔒use crate::helpers::redacted_body;🔒use crate::helpers::redacted_message;🔒use crate::helpers::system_time_from_epoch;🔒use crate::AccountEnv;🔒use crate::BillingModel;🔒use crate::ProbeError;🔒use crate::Provider;🔒use crate::ProviderBackend;🔒use crate::ProviderHost;🔒
Structs§
- Zai
- The Zai
[[accounts]] providertoken.
Enums§
- Mapper 🔒
Functions§
- choose_
mapper 🔒 - The mapper the account’s env earns, paired with the credential that earns it: the base-url pair earns the monitor mapper, and a missing base url carries its error to the probe’s Unmappable surface. Pure so the routing stays unit-pinned - the probe cannot be driven against the network offline.
- monitor_
headers 🔒 - monitor_
host 🔒 - The scheme+host of an account’s
ANTHROPIC_BASE_URL- everything before the first path segment. The Z.ai monitor paths live off the site root (https://api.z.ai), never under the/api/anthropicchat prefix the base carries. - monitor_
probe 🔒 - One round-trip against
{host_root}/api/monitor/usage/quota/limitfor a Z.ai GLM coding plan account. SharesOauthUsageErrorwith the window probes so the loader and poller classify failures the same way regardless of provider. - monitor_
url 🔒 - quota_
from_ 🔒body - Parse a Z.ai monitor body. The HTTP layer carries no verdict - a
wrong key and a wrong path arrive as HTTP 200 - so the envelope is
decoded unconditionally and keyed on
success/code. A body-level 401 (wrong key) surfaces asOauthUsageError::Unauthorizedso it bails the boot probe like a real auth rejection; every other failure keeps the envelope’smsg. - snapshot_
from_ 🔒zai_ quota - Map a Z.ai quota-limit payload into a
forge_primitives::usage::UsageSnapshot. - window_
from_ 🔒entry