Skip to main content

Builder API

CustodianBuilder configures a Custodian Agent with a fluent, chainable style. It is an alternative to the Custodian Agent Class — both create and deploy an App.

Example

import { CustodianBuilder } from "@custodianlabs/sdk";

const app = await new CustodianBuilder()
.withModel("gpt-4o")
.withPrompt("You are a helpful finance assistant.")
.withExamples([
{
user: "When is an invoice overdue?",
assistant: "An invoice is overdue after the due date passes without payment.",
},
])
.deploy();

const reply = await app.chat("Give me a short overdue invoice policy.");
console.log(reply?.response);

Methods

MethodPurpose
.withModel(model)Set the model. Required.
.withPrompt(prompt)Set the system prompt. Required.
.withName(name)Set a display name.
.withDescription(description)Set a description.
.withTools(tools)Enable built-in tools. See Built-in Tools.
.withInputSchema(schema)JSON Schema for structured input.
.withResponseSchema(schema)JSON Schema for structured output.
.withExamples(examples)Set few-shot examples (replaces any previously set).
.withDataSourceFile(file)Attach a RAG file. Call multiple times for multiple files.
.withPrivacyEnabled(enabled)Turn inline PII masking on or off.
.deploy(options?)Create and deploy. Returns App.
.chat()Deploy, then start an interactive terminal chat.

.deploy() accepts the same { name, shareMode, sharePassword } options as the Custodian Agent Class.

Authentication

CustodianBuilder reads CUSTODIAN_SDK_API_KEY and CUSTODIAN_SDK_BASE_URL from the environment. It does not accept apiKey / baseUrl arguments — use the Custodian class if you need to pass credentials explicitly.

AssistantBuilder is a deprecated alias for CustodianBuilder. Use CustodianBuilder in new code.

Next steps