PAIPAI

@pai/client

Transport-agnostic thread facade, live state, pending action, and client-tool snapshot APIs.

@pai/client is the framework-agnostic TypeScript facade. It owns AgentClient, Thread, RunHandle, pending action helpers, local state reduction, and transport event handling. HTTP apps usually use createPaiHttpClient() from @pai/client-http, which wraps this facade with the HTTP/SSE transport.

pnpm add @pai/client

Exports

APIPurpose
createAgentClient()Create a client from an AgentClientTransport.
AgentClientTop-level client for manifests, threads, and thread lists.
ThreadThread handle for send, refresh, watch, queueing, files, and pending actions.
ThreadStateNative PaiMessage[] transcript plus normalized runs, queue, usage, and thread attributes.
PendingActionViewCommand sidecar resolved from an exact message and native tool part.
ClientToolDefinitionSnapshotLow-level serialized definition for frontend-defined tools.
Thread error classesPortable busy, conflict, ownership, pagination, and retry errors.

React apps should usually create an HTTP client with @pai/client-http and pass it to @pai/react.

On this page