Create Your First Custodian Agent
A Custodian Agent is one configured AI assistant — a model, a system prompt, and
optional examples, knowledge files, and tools. In the SDK it is the Custodian class.
This page shows the fastest way to deploy one and chat with it.
Before you begin
Fastest path: createCustodian()
createCustodian() creates and deploys a Custodian Agent in a single call and returns
an App you can chat with.
import { createCustodian } from "@custodianlabs/sdk";
const app = await createCustodian({
model: "gpt-4o",
prompt: "You are a helpful assistant for onboarding new users.",
});
console.log(app.chatUrl);
const reply = await app.chat("What should a new admin do first?");
console.log(reply?.response);
You can pass few-shot examples and enable inline privacy masking here too:
const app = await createCustodian({
model: "gpt-4o",
prompt: "You are a terse, no-fluff support agent.",
privacyEnabled: true,
examples: [
{ user: "Is my data safe?", assistant: "Yes. Data is encrypted at rest and in transit." },
],
});
Continue the conversation
The returned App retains the chat session automatically, so a follow-up message
keeps the earlier context:
const followUp = await app.chat("Can you say that in one sentence?");
console.log(followUp?.response);
See Chat Sessions for the details.
The chat response
app.chat() resolves to a ChatResponse (or null in interactive mode):
| Field | Description |
|---|---|
response | The agent's reply text. |
sessionId | The session identifier returned by the API. |
retrievedContexts | Data source chunks used for the response, if any. |
messages | Conversation messages returned by the API. |
selectedAgent | For agent teams: which agent answered. null for a single Custodian Agent. |
handoffPath / contributingAgents | For agent teams: routing detail. |
rawPayload | The unmodified API response. |
Configure sharing at deploy time
Sharing is set when the app is deployed, not on the Custodian Agent itself:
import { Custodian } from "@custodianlabs/sdk";
const custodian = new Custodian({ model: "gpt-4o", systemPrompt: "You are helpful." });
const app = await custodian.deploy({ shareMode: "private" });
// or: { shareMode: "password", sharePassword: "s3cret" }
shareMode | Behavior |
|---|---|
"public" | Anyone with the link can chat. Default. |
"private" | Only the owner can access it. |
"password" | Access requires sharePassword. |
Interactive terminal chat
Call .chat() with no argument to start an interactive REPL (Node.js TTY only):
await app.chat();
// Type "exit" or "quit" to end the session.
Next steps
- Custodian Agent Class — configure and deploy with more control.
- Builder API — the same configuration with a fluent chain.
- Data Sources and RAG — ground answers in your files.
- Agent Teams — route across multiple specialized agents.