Create Your First Custodian
Use the Custodian class to create, deploy, and chat with your first Custodian in a few lines of Python.
This is the fastest way to get started. For more control over the lifecycle, see Custodian Class later.
Before You Begin
Make sure you have:
Create a Python File
Create a file named first_custodian.py:
from custodian_labs import Custodian
custodian = Custodian(
model="gpt-4o",
system_prompt="You are a helpful assistant for onboarding new users.",
privacy_enabled=True,
)
app = custodian.deploy()
print(app.chat_url)
reply = app.chat("What should a new admin do first?")
if reply is not None:
print(reply.response)
Run the Custodian
In your terminal, run:
python first_custodian.py
The SDK will:
- Create a Custodian with your model and prompt.
- Deploy the Custodian as an
App. - Send your message to the deployed app.
- Print the Custodian's response.
Continue the Conversation
The deployed App retains the active chat session automatically. Add a follow-up message:
response = app.chat("Can you explain that in one sentence?")
print(response.response)
The Custodian receives the earlier conversation context without requiring you to manage the session ID manually.
Configure Sharing at Deploy Time
Sharing is set when you deploy the container, not on the Custodian itself:
app = custodian.deploy(share_mode="private") # private / public / password
app = custodian.deploy(share_mode="password", share_password="s3cret")
Recommended: Start an Interactive Chat
Call .chat() without a message to continue chatting from your terminal:
app.chat()
Type exit or quit to end the interactive session.
Next Steps
- Custodian Class: configure and deploy with more control.
- Builder API: create with chained methods.
- Custodian Squads: route work across multiple Custodians.
- Data Sources and RAG: add knowledge files to a Custodian.
- Chat Sessions: manage multi-turn conversations.