API Reference
Public API grouped by package.
This reference is grouped by package so every API shows where it is imported from.
PAI's public schema surface is Zod. Agent scope, client data, tool inputs, tool outputs, suspend payloads, resume payloads, and client tool payloads are declared with Zod schemas and inferred with Zod types.
Packages
| Package | Purpose | Main APIs |
|---|---|---|
@pai/core | Backend agent definitions, runtime, direct clients, and backend tools. | defineAgent, defineTool, createAgentRuntime |
@pai/openai-codex | Experimental Responses provider backed by an explicitly authorized ChatGPT subscription credential. | createOpenAICodexAuth, createOpenAICodex |
@pai/xai-grok | Experimental xAI provider backed by an explicitly authorized Grok subscription credential. | createXaiGrokAuth, createXaiGrok |
@pai/client | Transport-agnostic thread facade, state live, pending actions, and client-tool snapshots. | createAgentClient, AgentClient, Thread |
@pai/react | Typed React providers, hooks, and render helpers. | createPaiReact, Pai.Provider, ThreadProvider, useChat |
@pai/client-http | HTTP/SSE client transport, convenience client, and safe HTTP fallback errors. | createPaiHttpClient, createHttpAgentTransport, PaiHttpError |
@pai/storage | Durable thread storage contract and storage provider surface. | ThreadStore |
@pai/realtime | Optional cross-process live event provider contract. | ThreadLiveProvider |
@pai/files | File provider contract for immutable transcript attachments. | FileProvider |
@pai/sandbox | Shared filesystem tools and a provider contract for local or isolated remote execution. | sandbox, sandboxCapability, sandboxTools, SandboxProvider |
@pai/receiver-http | Framework-neutral HTTP routes, safe error mapping, and trusted request/stream diagnostics. | createHttpAgentReceiver, HttpAgentErrorMapper, HttpAgentErrorHandler |
@pai/hono | Hono adapter for PAI fetch handlers. | createPaiHonoReceiver |
@pai/express | Express adapter for the PAI HTTP receiver. | createPaiExpressReceiver |
@pai/protocol | Public message/state contracts, agent types, and portable errors. | AgentContract, PaiMessage, ThreadState |
Most HTTP applications use @pai/core on the backend, @pai/client-http in TypeScript clients, and @pai/react in React apps. Provider and adapter packages are installed only where needed.
Use the guides first if you are learning the framework: