Skip to main content

Crate agentstat

Crate agentstat 

Source
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§

AccountScope
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.
ClientBuilder
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.
FetchRequest
Credentials, routing, and source preferences for one fetch.
HttpResponse
A response from a caller-supplied HTTP executor. Header/body values are never logged.
ProviderDescriptor
Coverage and availability details for one provider.
QuotaWindow
Usage and reset information for one quota window.
Secret
Explicitly expose only when constructing a request. Never serialized; debug is redacted.
SpendSummary
Spending over a provider-reported period.
UsageSnapshot
Usage, balances, and warnings returned by a provider.

Enums§

AgentStatError
All failures deliberately omit remote response bodies, URLs, and credential values.
CoverageStatus
Implementation status of a provider adapter.
CredentialSource
Where the credentials for a fetch originated.
Credentials
Supported credential formats for provider requests.
ProviderConfig
Provider-specific routing. Values are never read from the process environment implicitly.
ProviderId
Identifiers for supported and planned provider integrations.
QuotaLimit
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.
WindowKind
How a quota window is bounded in time.

Traits§

HttpExecutor
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 AgentStatError on failure.