Skip to main content

Custodian Labs Python SDK

The fastest way to deploy AI agents with privacy built in. Describe your agent in a few lines of Python. Custodian handles the RAG pipeline, hosting, conversation memory and PII masking, and gives you a live chat link to share.

Features

  • Deploy in a few lines: one deploy() call gives you a hosted AI agent, an API, and a shareable chat page.
  • RAG built in: add PDF, DOCX, XLSX, CSV or TXT files; parsing, chunking, embeddings and search are handled for you.
  • Privacy built in: privacy_enabled=True masks names, phone numbers and other PII before the LLM sees them, and restores them in the reply.
  • Conversation memory: follow-up questions keep their context automatically.
  • Multi-agent teams: route questions to the right expert, or have agents work together in a workflow.
  • GuardianLayer: mask PII in your own text and files (CSV, XLSX, DOCX, PDF, TXT).

Install

pip install custodian-labs

Requires Python 3.10+.

Set your API key

Get a key from the Dashboard, then either put it in a .env file in your project folder:

CUSTODIAN_SDK_API_KEY=your-api-key

or set it in your terminal:

export CUSTODIAN_SDK_API_KEY="your-api-key"

In Google Colab or Jupyter, set it in a cell before using the SDK:

import os
from getpass import getpass

os.environ["CUSTODIAN_SDK_API_KEY"] = getpass("Enter your Custodian Labs API key: ")

Quickstart

from custodian_labs import Custodian

ai_agent = Custodian(
    name="Contract Assistant",
    model="gpt-6-luna",
    system_prompt="Answer questions about the contract provided.",
)
ai_agent.add_data_source_file("contract.pdf")  # RAG over your own files

app = ai_agent.deploy()
print(app.chat_url)  # hosted chat page you can share

reply = app.chat("Who are the parties in this contract?")
print(reply.response)

app.chat()  # or chat interactively in your terminal

Few-shot examples

Teach the agent your tone and format:

ai_agent.add_examples([
    {"user": "How do I reset my password?", "assistant": "Go to Settings > Security > Reset password."},
])

Builder style

from custodian_labs import CustodianBuilder

app = (
    CustodianBuilder()
    .with_name("Support AI")
    .with_model("gpt-6-luna")
    .with_prompt("You are a helpful support agent.")
    .with_privacy()
    .deploy()
)

Sharing

Links are public by default. Protect them with a password, or keep them private to your API key:

app = ai_agent.deploy(share_mode="password", share_password="choose-a-password")

Collections

Group your deployments at deploy time (collection="Support") — you can reorganize them later in the My AIs dashboard.

app = ai_agent.deploy(collection="Support")

Multi-agent teams

Several agents behind one app. Each keeps its own prompt and files.

from custodian_labs import Custodian, CustodianSquad

car_specialist = Custodian(
    name="car_specialist",
    model="gpt-6-luna",
    system_prompt="Answer questions about the cars in the uploaded file.",
    topics=["car", "suv", "mpg", "maintenance"],
)
car_specialist.add_data_source_file("car_info.csv")

finance_advisor = Custodian(
    name="finance_advisor",
    model="gpt-6-luna",
    system_prompt="Explain loans, payments and running costs.",
    topics=["loan", "finance", "payment", "interest"],
)

team = CustodianSquad(
    name="Car Team",
    custodians=[car_specialist, finance_advisor],
    routing_mode="single",  # single | workflow | chain
)
app = team.deploy()

reply = app.chat("Which SUV has the lowest maintenance cost?")
print(reply.selected_agent, reply.response)
Routing mode Which agents answer
single One agent: the one whose topics match the message
workflow All agents in order; each answer is passed to the next
chain Starts with the matching agent, then hands off to the agents it lists in can_handoff_to

GuardianLayer: mask PII in text and files

from custodian_labs import GuardianLayer

guardian = GuardianLayer()

result = guardian.deidentify_text_outputs(
    "John Smith lives in Boston and his phone number is 617-555-0100.",
    masking_type="placeholder",  # redact | placeholder | transform
    pii_entities=["ALL"],
)
print(result.outputs[0].text)

masked = guardian.deidentify_file("customers.csv", masking_type="redact")
with open("masked_customers.csv", "wb") as f:
    f.write(masked.content)

Plans

The Free plan includes up to 5 deployed agents and runs on gpt-6-luna. Pro adds more agents, multi-agent teams, more models and higher usage limits. See the Dashboard for current plans.

Learn more

Metadata

Release files for custodian-labs 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for custodian-labs 0.3.4
File Size Uploaded Provenance Actions
custodian_labs-0.3.4.tar.gz 701.3 kB Without provenance Details for custodian_labs-0.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for custodian-labs 0.3.4
File Interpreter ABI Platform Actions
custodian_labs-0.3.4-py3-none-any.whl Python 3 none any Details for custodian_labs-0.3.4-py3-none-any.whl

Total release size: 766.1 kB

Release files / custodian_labs-0.3.4.tar.gz

Download URL custodian_labs-0.3.4.tar.gz
Size 701.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ac4f32b174cf04fae5a06d7d5ed2582c588930a6b56fc966c6eb00b0ccb1213d
BLAKE2b-256 checksum
How to use checksums
30937f4a5fde87d19753a51278bed2b7c64f49b3fe6c05cd70ea12ee8bb4d1c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / custodian_labs-0.3.4-py3-none-any.whl

Download URL custodian_labs-0.3.4-py3-none-any.whl
Size 64.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9368093a95d1ffb561e1bf1f3f61afbea18424112ef06a08c5a6d1601c6ac682
BLAKE2b-256 checksum
How to use checksums
2b1813b9e16a9ae84827a7814108dbbfc8885e71de48436ac35999676f6e4c46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for custodian-labs 0.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page