Repository navigation
API Reference
The complete Rust API documentation is on docs.rs. This page is a map of the main types and common patterns. The published docs.rs build describes 0.1.0; check the source documentation for unreleased changes.
| Type | Purpose |
|---|---|
Client and ClientBuilder
|
Configure HTTP transport, deadlines, local access, and fetch operations |
ProviderId |
Select an adapter; its descriptor reports feature and support status |
FetchRequest |
Pair provider, credentials, scope, source, and provider configuration |
Credentials |
Bearer token, API key, cookie, or no direct credential for an allowed probe |
AccountScope, ProviderConfig
|
Route a fetch to the intended account, workspace, organization, or project |
UsageSnapshot |
Normalized windows, balances, spend, metadata, and warnings |
AgentStatError |
Typed failures without credential values or remote response bodies |
let client = agentstat::Client::builder().build()?;
let request = agentstat::FetchRequest::new(
agentstat::ProviderId::Codex,
agentstat::Credentials::bearer(token),
);
let snapshot = client.fetch(request).await?;The library does not read environment variables itself in this path. Your application obtains token and chooses when to call fetch.
let results = client.fetch_many(requests).await;
for result in results {
match result {
Ok(snapshot) => println!("{:?}: {} windows", snapshot.provider, snapshot.windows.len()),
Err(error) => eprintln!("fetch failed: {error}"),
}
}Results remain in input order, and each request has its own Result. Reuse one client for pooling. See Reading Results for field semantics and Credentials and Accounts for secure routing.
ClientBuilder::http_client_builder configures proxy and TLS behavior. endpoint_override deliberately trusts an alternative origin for one provider and accepts HTTPS or loopback HTTP without embedded credentials, fragments, or query parameters. HttpExecutor supports custom networking; it receives sensitive requests, so its implementation must respect redirect, retry, body-size, and cancellation behavior. The usage guide has details.
Repository · Rust API docs · Issues · Releases · Security