personaai is the official Python client for everything on this page — auth header injection, typed
resource methods for Agents/Skills/Knowledge/MCP/Providers/Threads/Files, and streaming AG-UI chat,
all wrapping the same REST + AG-UI API described in the API Reference. It ships
both a sync client (PersonaClient) and an async client (AsyncPersonaClient) built on the
same httpx-based transport — use whichever matches your
framework.
Prerequisites
- Python 3.9+ (3.9–3.13 are tested — see Compatibility).
- A Project credential minted in Developer Studio,
shaped
"<keyId>.<secret>". This is the only thing that authenticates the SDK. - A base URL —
https://api.persona.hasanraiyan.mein production.
httpx>=0.27 (installed automatically). No
requests, no aiohttp, no separate AG-UI protocol package.
Install
Installed under the PyPI name
persona-agent-sdk (personaai was already too
close to an unrelated existing PyPI project’s name) but imported as
personaai in code — from personaai import PersonaClient.Initialize a client
Both clients take the same arguments — two positional (base_url, credential), then keyword
options. See Configuration for the full reference.
Minimal working example
with PersonaClient(...) as persona: /
async with AsyncPersonaClient(...) as persona: — which closes the underlying httpx client for
you on exit.
First streaming chat call
Chat runs an Agent as the asserted external user, streaming AG-UI events over SSE. It requires a runtime-plane client (external_user_id set) — a bare Project credential has no Subject to chat
as, and the server rejects it with 400 EXTERNAL_USER_REQUIRED.