Getting Started
How Persuit developers build a small Persi agent with PAI.
You are building a Persi agent within Persuit: it has users, workspaces, tools, and a UI. PAI is the layer that makes that agent durable. This guide uses a small standalone app to show the same contracts without the rest of Persuit.
Want to skip the overview? Go straight to First app.
What you will have
- A server agent that answers on a durable thread (tools come next in Tools)
- An HTTP API the browser talks to
- A thread that stores the conversation
- A React chat that streams the reply
The path
- First app — define an agent, mount it on Express, send a message from Node.
- React chat — the same agent in a browser.
After that, the guides cover tools, identity, files, sandboxes, and tests.
How these docs are organized
- Getting started — a working agent in one sitting.
- Guides — one short page per feature. Nested pages (Testing, Tools, React) are the working set when the short page is not enough.
- API reference — every public export, named as you import it. Use it to audit what exists.
Four words
Keep these four words. Almost every PAI API is one of them:
- Agent — what the model is allowed to do (instructions, tools, identity).
- App —
createPai({ agents }). One process can host several agents. - Thread — one durable conversation. Messages, tool calls, and files live here.
- Run — one turn of model work on a thread (a send).
Identity is decided on the server. The client never picks the workspace. Your Express resolveIdentity function is that decision.
browser → Express (who is this?) → PAI (run the agent) → thread
↑
your session / JWTA production-shaped stack
The getting-started app uses in-memory storage so it runs with no database. Persi's multi-process deployment uses production providers, with files and sandboxes configured as needed:
| Concern | Local | Production |
|---|---|---|
| Threads | in-memory (default) | @pai/storage-mongo |
| Live updates | in-process (default) | @pai/realtime-redis |
| Files | @pai/files-inmemory | @pai/files-mongo |
| Sandbox | omit until you need it | @pai/sandbox + @pai/sandbox-gke |
| HTTP | @pai/express | same |
| UI | @pai/react | same, often with pai generate client |
You do not change the agent when you change providers.
Next
Build the first app.