Install and authenticate
Two official SDKs wrap the same platform with the same features. Pick the one that matches where your code runs.
| Python | TypeScript / JavaScript |
|---|---|
| Backends, data pipelines, notebooks, scripts | Node.js, serverless, edge, web apps, CLIs |
pip install custodian-labs | npm install @custodianlabs/sdk |
| Python 3.10+ | Node.js 18+, or any runtime with fetch |
Install
- Python
- TypeScript
pip install custodian-labs # upgrade: pip install -U custodian-labs
from custodian_labs import Custodian # install name custodian-labs, import name custodian_labs
npm install @custodianlabs/sdk # or: pnpm add / yarn add @custodianlabs/sdk
import { Custodian } from "@custodianlabs/sdk"; // ESM
// const { Custodian } = require("@custodianlabs/sdk"); // CommonJS
Zero runtime dependencies. Types are included.
Authenticate
Both SDKs read your key from CUSTODIAN_SDK_API_KEY and send it as an X-API-Key
header. Get a key from the Dashboard.
export CUSTODIAN_SDK_API_KEY="custodian_labs_..."
# PowerShell: $env:CUSTODIAN_SDK_API_KEY="custodian_labs_..."
The SDKs don't load .env files. Load yours first, for example with python-dotenv or
dotenv.
To pass credentials explicitly, which overrides the environment:
- Python
- TypeScript
Custodian(model="gpt-6-luna", system_prompt="...", api_key="custodian_labs_...")
GuardianLayer(api_key="custodian_labs_...")
new Custodian({ model: "gpt-6-luna", systemPrompt: "...", apiKey: process.env.MY_KEY });
new AgentTeam({ agents: [...], apiKey: process.env.MY_KEY }); // set once for the whole squad
new GuardianLayer({ apiKey: process.env.MY_KEY });
CustodianBuilder reads the environment only. Use the Custodian class to pass a key
explicitly.
| Variable | Default |
|---|---|
CUSTODIAN_SDK_API_KEY | None. Required. |
CUSTODIAN_SDK_BASE_URL | https://platform.custodianlabs.io/v1 |
CUSTODIAN_MASKING_BASE_URL | https://privacy.custodianlabs.io (Guardian Layer) |
All variables: Environment variables.
Don't put your key in browser or mobile code. Call the SDK from a backend, serverless function or edge handler. See Use API keys securely.
Class names
The SDKs are not line-for-line ports. These names differ:
| Python | TypeScript |
|---|---|
CustodianSquad | AgentTeam |
DeployedApp (aliases: App, CustodianSquadApp) | TeamApp |
Custodian (also used for squad members) | Agent (squad members) |
AISDKError | CustodianError |
TypeScript also has createCustodian(), which creates and deploys in one call.
Since the unified deployment model, every deployment is a DeployedApp — a single
Custodian deploys as a 1-member squad (routing_mode="single"). Use
CustodianClient.deployed(id) to attach to an existing
deployment by ID without re-deploying.
Reference
| Python | TypeScript | |
|---|---|---|
| One agent | Custodian | Custodian |
| Fluent builder | CustodianBuilder | CustodianBuilder |
| Multi-agent | CustodianSquad | AgentTeam |
| Guardian Layer | GuardianLayer | GuardianLayer |