PAIPAI

API Reference

Audit the public APIs. Grouped by package, named as you import them.

Learn in Getting started and the guides. Come here to see what exists and the constructor / hook signature. Package child pages are the audit surface when a public API changes.

Every public schema (identity, tool input/output, suspend, resume) is Zod.

Call these first

@pai/core

Server. Do not import this in the browser.

ExportPurpose
defineAgentAgent: model, identity, instructions, tools, commands
defineToolServer tool, client-routed tool, or suspend tool
defineCommandUI/server operation, no model turn
defineSubagentToolParent tool that runs a child agent
createPaiApp registry. Options include scopeKey, userKey, mapError, live
InferPaiContract / InferAgentContractContract types for the client
createAgentRuntimeOne agent, no HTTP. Prefer createPai
composeLifecycleRun hooks
createContextCompactionBuilt-in compaction
defineCapabilityNamed capability (sandbox uses this)

Full @pai/core page

HTTP and clients

PackageExportPurpose
@pai/expresscreatePaiExpressReceiverMount createPai on Express
@pai/receiver-httpcreateHttpAgentReceiverFramework-neutral routes
@pai/client-httpcreatePaiHttpClientBrowser/Node HTTP + SSE
@pai/clientcreateAgentClient, ThreadTransport-agnostic thread API
@pai/clientThreadBusyErrorSend while the thread is busy
@pai/receiver-socketiocreatePaiSocketIoServerSocket.IO door
@pai/client-socketiocreatePaiSocketIoClientSocket.IO client

Same createPai app. HTTP/SSE is the default.

@pai/react

CallablePurpose
createPaiReactRoot, Provider, agent() — package import
Pai.agent("main").useChat()Transcript, send, stop
useComposer()Draft text and attachments
Pai.agent("main").useThreads()Thread list
Pai.agent("main").useThread()Handle, useClient
ToolTool cards
useClientToolBrowser tools
useFileUrlAttachment URLs
useSubagentChild-thread ref

Full @pai/react page · Chat · Tool UI

Persistence and live

PackageExportPurpose
@pai/storage-mongocreateMongoThreadStoreProduction threads. Call initialize()
@pai/storage-inmemorycreateInMemoryThreadStoreTests and the first app
@pai/storageThreadStoreProvider contract
@pai/files-mongocreateMongoFileProviderGridFS attachments
@pai/files-inmemorycreateInMemoryFileProviderTests
@pai/filesFileProviderProvider contract
@pai/realtime-rediscreateRedisThreadLiveProviderCross-process watch
@pai/realtime-inmemorycreateInMemoryThreadLiveProvider()Tests (no extra options)
@pai/realtimeThreadLiveProviderProvider contract

In-memory thread storage is the createPai default. See Serve.

Sandbox

PackageExportPurpose
@pai/sandboxsandboxTools, sandboxCapabilityAgent tools + binding
@pai/sandbox-gkecreateGkeSandboxProviderGKE provider
@pai/sandbox/memorycreateInMemorySandboxTool tests

Sandbox guide

Testing

PackageExportPurpose
@pai/test-utilsrunToolOne execute
@pai/test-utilscreateTestUtilsMock model + selectors
@pai/test-utilscreateTestRuntime, stubToolsRuntime tests
@pai/test-utilsrunAgentEvalEvals
@pai/react-test-utilscreateReactTestUtilstoolProps, createClientHarness

Testing

Other

PackageExportPurpose
@pai/clipai generate client, pai generate skillsTyped client folder; compiled skills module
@pai/observabilitycreatePaiOpenTelemetryTraces
@pai/langfusecreateLangfuseSpanProcessorLangfuse export
@pai/skillsdefineSkillsSkill catalog and skill tool
@pai/skills/generategenerateSkillsCompile skill folders from Node
@pai/skills-officeofficeSkillsWord, Excel, and PowerPoint skills (need a sandbox)
@pai/protocolPaiMessage, ThreadState, AgentContractShared contracts
@pai/code-modecodeModeToolModel-written scripts over allowed tools

On this page