Expand description
Read-only AI account usage. Fetches happen only when requested by the caller.
use agentstat::{Client, Credentials, FetchRequest, ProviderId};
let client = Client::builder().build()?;
let request = FetchRequest::new(ProviderId::Codex, Credentials::bearer("existing-token"));
let snapshot = client.fetch(request).await?;
println!("{}", serde_json::to_string_pretty(&snapshot)?);Structs§
- Account
Scope - Optional account identifiers used to route a request.
- Balance
- A provider-reported credit or currency balance.
- Client
- Fetches provider usage through the configured HTTP transport.
- Client
Builder - Configures network transport, safety limits, and optional local access.
- Decimal
- Exact finite decimal, serialized as a decimal string. No binary floating-point money. Input is bounded to 512 digits and an exponent magnitude of 512.
- Fetch
Request - Credentials, routing, and source preferences for one fetch.
- Http
Response - A response from a caller-supplied HTTP executor. Header/body values are never logged.
- Provider
Descriptor - Coverage and availability details for one provider.
- Quota
Window - Usage and reset information for one quota window.
- Secret
- Explicitly expose only when constructing a request. Never serialized; debug is redacted.
- Spend
Summary - Spending over a provider-reported period.
- Usage
Snapshot - Usage, balances, and warnings returned by a provider.
Enums§
- Agent
Stat Error - All failures deliberately omit remote response bodies, URLs, and credential values.
- Coverage
Status - Implementation status of a provider adapter.
- Credential
Source - Where the credentials for a fetch originated.
- Credentials
- Supported credential formats for provider requests.
- Provider
Config - Provider-specific routing. Values are never read from the process environment implicitly.
- Provider
Id - Identifiers for supported and planned provider integrations.
- Quota
Limit - Whether a quota has a known finite limit.
- Source
- Ways to obtain usage data from a provider.
- Unit
- Units used by provider quota and balance values.
- Warning
- Non-fatal issues that left the primary snapshot available.
- Window
Kind - How a quota window is bounded in time.
Traits§
- Http
Executor - Optional integration point for custom networking and deterministic tests. Executors must not follow redirects or retry requests and must honor future cancellation. The default executor uses reqwest; custom executors own their network buffering limits.
Functions§
- provider_
catalog - Returns coverage details for all known providers.
Type Aliases§
- Result
- A crate result with an
AgentStatErroron failure.