PAIPAI

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

PackagePurposeMain APIs
@pai/coreBackend agent definitions, runtime, direct clients, and backend tools.defineAgent, defineTool, createAgentRuntime
@pai/openai-codexExperimental Responses provider backed by an explicitly authorized ChatGPT subscription credential.createOpenAICodexAuth, createOpenAICodex
@pai/xai-grokExperimental xAI provider backed by an explicitly authorized Grok subscription credential.createXaiGrokAuth, createXaiGrok
@pai/clientTransport-agnostic thread facade, state live, pending actions, and client-tool snapshots.createAgentClient, AgentClient, Thread
@pai/reactTyped React providers, hooks, and render helpers.createPaiReact, Pai.Provider, ThreadProvider, useChat
@pai/client-httpHTTP/SSE client transport, convenience client, and safe HTTP fallback errors.createPaiHttpClient, createHttpAgentTransport, PaiHttpError
@pai/storageDurable thread storage contract and storage provider surface.ThreadStore
@pai/realtimeOptional cross-process live event provider contract.ThreadLiveProvider
@pai/filesFile provider contract for immutable transcript attachments.FileProvider
@pai/sandboxShared filesystem tools and a provider contract for local or isolated remote execution.sandbox, sandboxCapability, sandboxTools, SandboxProvider
@pai/receiver-httpFramework-neutral HTTP routes, safe error mapping, and trusted request/stream diagnostics.createHttpAgentReceiver, HttpAgentErrorMapper, HttpAgentErrorHandler
@pai/honoHono adapter for PAI fetch handlers.createPaiHonoReceiver
@pai/expressExpress adapter for the PAI HTTP receiver.createPaiExpressReceiver
@pai/protocolPublic 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:

On this page