Skip to main content
@personaai/sdk is the official Node.js/TypeScript client for the Persona Developer Platform API — Agents, Skills, Knowledge bases, MCP connectors, named Stores, persistent memory, and streaming chat, all from your own backend. Every method on every resource client is a thin, typed 1:1 wrapper over a real REST endpoint. There is no hidden behavior: what the SDK sends, and what it returns, is exactly what the API Reference documents for the endpoint it wraps.
Server-side only. Every method sends your Project’s credential — a server-side secret. Never construct PersonaClient in a browser bundle, a mobile app, or a Next.js Client Component. See the Integration Guide for the full reasoning and a per-resource “who calls this, and when” table.

Prerequisites

  • Node.js 18+ (or any runtime with a global fetch, FormData, and ReadableStream — the SDK uses the built-ins, no heavy HTTP dependency). This includes Next.js Edge runtime and Deno/Bun runtimes that expose the standard web APIs.
  • A Project credential shaped "<keyId>.<secret>", minted in Developer Studio. This is what authenticates every call.- TypeScript 5.x if you’re using TypeScript (types ship with the package — the package builds against 5.7; see Compatibility). Plain JavaScript works too — the package ships both ESM and CommonJS builds plus .d.ts types.

Install

The package ships ESM (dist/index.js), CommonJS (dist/index.cjs), and TypeScript declarations (dist/index.d.ts) — import and require both work, and one import covers the client, every resource, and every type. There is no separate @personaai/sdk/types entry point.

Initialization

Create a PersonaClient with a baseUrl and your credential:
Both baseUrl and credential are required — constructing the client without them throws synchronously. baseUrl trailing slashes are stripped automatically.

The two client modes

The same client class serves two different identities, and which one you build determines what you can do:
Full details on every option, defaults, and environment variables live in Configuration.

Minimal working example

Before that Agent can run, it needs a Provider (the LLM endpoint it talks to):

First real operation: streaming chat

Chat runs as a specific end user, so you need a runtime-plane client:

Framework recipes

Express

No special handling — construct the client once at module scope (or a factory), and per-request runtime-plane clients in your route handlers.

NestJS

Wrap PersonaClient in an @Injectable() provider so it plugs into Nest’s DI container like any other third-party client — the SDK itself needs no Nest-specific support.

Next.js — read this one carefully

Next.js blurs server and client code in one codebase more than Express or Nest does, which makes it the one framework people actually leak the credential in by accident.
Only import this SDK in Server Components, Route Handlers (app/api/.../route.ts), or Server Actions. Never in a "use client" component. Constructing PersonaClient in client code bundles your Project credential straight into the JavaScript shipped to the browser.
Because the SDK uses native fetch, it also works in Next.js’s Edge runtime, not just Node — no extra configuration needed. For a live-streaming chat UI, a Route Handler can return a ReadableStream directly, relaying the AG-UI event stream onward to your own browser client:

Where to go next

Out of scope

Project/Members/Credentials management (creating Projects, inviting Members, minting/revoking credentials) is intentionally not part of this SDK — those are Clerk-session (human admin) operations with a completely different auth model than the machine-credential calls this SDK makes. Manage them from Developer Studio instead.