truagents package is the first-party Python client for the TruAgents public API. It handles OAuth 2.0 token acquisition and refresh, retries with Retry-After awareness, and typed exceptions — so you skip hand-rolling the flow and focus on your integration logic. Under the hood it wraps the OpenAPI spec with a typed HTTP client and an exception hierarchy over the RFC 6749 error taxonomy.
Install
Quickstart
UseClient for synchronous code:
AsyncClient inside an async framework:
client_id and client_secret under Settings → API Keys. See Authentication for the full flow, environments, and rotation policy.
What the SDK handles for you
- OAuth tokens. Access tokens are acquired on demand, cached in memory, and refreshed before expiry. If the refresh token is revoked mid-flight, the SDK mints a fresh session via
client_credentialsautomatically. Concurrent callers deduplicate onto a single in-flight token request. - Retries and rate limits. Transient network errors and 5xx responses retry with exponential backoff.
429 Too Many Requestsresponses honor theRetry-Afterheader. Other 4xx failures do not retry. - Typed exceptions. All errors inherit from
TruAgentsError. CatchAuthError,RateLimited,NotFound,InvalidRequest,ServerError, orNetworkErroron the specific concern that matters instead of parsing error strings. - Observability hooks. Register
on_request,on_response, andon_errorcallbacks to route SDK activity into your existing logging and metrics pipelines. - Sync and async parity.
ClientandAsyncClientexpose the same surface; choose based on your host framework.
Custom retry policy
Override the default retry behavior by passing aRetryPolicy:
Observability hooks
Route SDK activity into your logging or metrics pipeline by registering hook callbacks:Development vs. production
Point the SDK at the development environment by overridingbase_url:
SDK resources
- PyPI: pypi.org/project/truagents
- Source: github.com/ablt-ai/truagents-sdk
- Issues: github.com/ablt-ai/truagents-sdk/issues

