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

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.0
File Size Uploaded Provenance Actions
custodian_labs-0.3.0.tar.gz 651.5 kB Without provenance Details for custodian_labs-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 677.7 kB

Release files / custodian_labs-0.3.0.tar.gz

Download URL custodian_labs-0.3.0.tar.gz
Size 651.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bae1f0403e84e3e84ab9a2cec9fd48fdcb5ce262de31a32af3331ed0ec7206e4
BLAKE2b-256 checksum
How to use checksums
43f3ec8aafbc35299b3555845f734782effc9314a2990c4ef6c9a9154d9bb484
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.1

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

Download URL custodian_labs-0.3.0-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61d47f78beb2a93b8b1b898abb4a9656d6d586b919abd2c4c7f311e1838c2b6c
BLAKE2b-256 checksum
How to use checksums
cc08ca61a32a5cdbc84b171691af7a269858a35d858e7f61ad94807bf89c87e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.1

Security for custodian-labs 0.3.0

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