Python SDKGuideIntroduction

The Regent Python SDK is the canonical client for backend services and AI agents written in Python. It wraps the REST API with typed Pydantic models, an async HTTP layer, and structured error handling.

Packageregent on PyPI
Python3.11+ (async/await throughout)
HTTPhttpx
ModelsPydantic v2
Sourceabay94/regent-sdk-python
LicenseMIT

Design philosophy

  • Async-first. Every method is a coroutine. No sync wrappers, no thread pools.
  • Typed end-to-end. Request/response models are Pydantic; method signatures use precise types.
  • Composable, not monolithic. Sub-clients (identity, payment, audit, guardian) expose a focused surface per protocol service.
  • Errors as data. Every failure is a structured RegentAPIError with a code, message, request ID, and details — no string parsing required.

Surface area

from regent import RegentClient
 
async with RegentClient(base_url=..., api_key=...) as r:
    r.identity   # register/get/revoke agents, resolve DIDs
    r.payment    # create mandates, authorize payments
    r.audit      # ingest events, list events, fetch batches
    r.guardian   # latest score, score history, alerts

Each sub-client mirrors a backend service. Methods are 1:1 with REST endpoints — if you know the API, you know the SDK.

Minimal example

import asyncio
from decimal import Decimal
from regent import RegentClient, AuthorizeRequest, IngestEventRequest
 
async def main():
    async with RegentClient(
        base_url="https://api.regentprotocol.org",
        api_key="rgnt_...",
    ) as r:
        auth = await r.payment.authorize(
            mandate_id="cab07ae3-...",
            request=AuthorizeRequest(amount=Decimal("50"), currency="USD"),
        )
        await r.audit.ingest_event(IngestEventRequest(
            event_id=f"action-{auth.jti}",
            agent_id="agent_b1c59d23...",
            event_type="action.completed",
            payload={"amount": "50", "jti": auth.jti},
        ))
 
asyncio.run(main())

That’s it — a full authorize-then-log cycle in ten lines.