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")

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.2.5

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.2.5
File Size Uploaded Provenance Actions
custodian_labs-0.2.5.tar.gz 647.6 kB Without provenance Details for custodian_labs-0.2.5.tar.gz

Built distribution (wheel)

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

Total release size: 671.2 kB

Release files / custodian_labs-0.2.5.tar.gz

Download URL custodian_labs-0.2.5.tar.gz
Size 647.6 kB
Tags Source
SHA-256 checksum
How to use checksums
64ea3305e75e17113f2f4f34278cb8ccbfb2929a5f0a4febdf51ad231a8b1d05
BLAKE2b-256 checksum
How to use checksums
ce58a686be71947cf8bf9825f490c1ff79cee1891fc2ac90edb208325c56bebc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

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

Download URL custodian_labs-0.2.5-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46d32198709aea29984ab78ce4e2fdc923e63e3c1b68834c0c0f673fd948fb29
BLAKE2b-256 checksum
How to use checksums
6736285a763bd3f4fba085a64386f9ec18d4436905f97a51b3d1509033f46771
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for custodian-labs 0.2.5

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