Repository navigation
Credentials and Accounts
Your application supplies credentials and chooses the account. agentstat does not log in, refresh tokens, extract browser cookies, or switch accounts on your behalf.
| Credential | Use it when | Example |
|---|---|---|
Credentials::bearer(token) |
The adapter expects an existing OAuth or bearer token | Codex subscription, Antigravity HTTPS |
Credentials::api_key(key) |
The adapter expects a provider API key | OpenAI Admin cost report, OpenCode Go in current source |
Credentials::cookie(header) |
The adapter expects the full browser Cookie request header |
OpenCode Console, Cursor dashboard |
Credentials::None |
An explicitly enabled local probe supplies its own CLI login | Antigravity agy, CodeRabbit |
Codex and Claude subscription quotas need their existing OAuth access tokens. Ordinary inference API keys do not grant subscription quota access. A provider may expose more than one credential path; see Provider Coverage and the detailed usage guide before choosing one.
Supported native files can be read only when both local-files and allow_local_files(true) are set:
let client = agentstat::Client::builder().allow_local_files(true).build()?;
let request = client
.load_local_credentials(
agentstat::ProviderId::Codex,
agentstat::local::CredentialLocation::Native,
)
.await?;Native file locations:
| CLI | Location |
|---|---|
| Codex |
CODEX_HOME/auth.json, otherwise ~/.codex/auth.json
|
| Claude Code |
CLAUDE_CONFIG_DIR/.credentials.json, otherwise ~/.claude/.credentials.json
|
| Cursor CLI | Linux: $XDG_CONFIG_HOME/cursor/auth.json or ~/.config/cursor/auth.json; macOS: ~/.cursor/auth.json; Windows: %APPDATA%/Cursor/auth.json
|
The crate does not read macOS Keychain, Cursor's IDE database, or other OS credential stores. If your CLI uses one of those, supply an existing token explicitly. Local CLI probes also require a Cargo feature and runtime opt-in; they are Unix-only.
FetchRequest::scope(AccountScope { ... }) carries account, organization, or workspace IDs when an adapter supports them. Examples:
- Codex workspace routing uses
AccountScope.account_id. - OpenCode Console uses
AccountScope.workspace_id(wrk_…ororg_…). Without it, discovery succeeds only when exactly one workspace is available. - Claude web usage needs a cookie and
ProviderConfig::Claude { organization_id }. - Other adapters use typed configurations such as
ProviderConfig::Antigravity { project_id }.
Unsupported scope or configuration is rejected. A fetch never silently falls back to another account, credential, or source.
Pass secrets through your application's secret store or a temporary environment variable. Avoid putting them in source, command arguments, shell history, issues, or screenshots. Use an interactive silent prompt for a local one-off test:
read -r -s -p "Token: " AGENTSTAT_TOKEN; echo
export AGENTSTAT_TOKEN
# Run your application here.
unset AGENTSTAT_TOKENSee Troubleshooting for authentication and permission failures. For a vulnerability or exposed credential, follow the security policy.
Repository · Rust API docs · Issues · Releases · Security