create_assistant()
The fastest way to deploy an assistant. A single function call creates the assistant and deploys it in one step, returning an App ready to chat.
When to use this
Use create_assistant() when you want the fewest lines of code and don't need to reuse the assistant configuration across multiple deploys. For more control, see AssistantBuilder or the Assistant class.
Signature
from custodian_labs import create_assistant
app = create_assistant(
model="gpt-4o",
prompt="You are a helpful assistant.",
examples=None, # optional
api_key=None, # falls back to CUSTODIAN_SDK_API_KEY env var
base_url=None, # falls back to CUSTODIAN_SDK_BASE_URL env var
timeout=30.0,
max_retries=2,
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | str | Yes | — | LLM model name (e.g. "gpt-4o", "gpt-4o-mini") |
prompt | str | Yes | — | System prompt for the assistant |
examples | list[dict] | No | None | Few-shot examples. Each dict must have "user" and "assistant" keys |
api_key | str | No | env var | Your CustodianAI API key |
base_url | str | No | env var | Assistant API base URL |
timeout | float | No | 30.0 | Request timeout in seconds |
max_retries | int | No | 2 | Number of retries on 5xx errors |
Returns: App
Examples
Minimal
from custodian_labs import create_assistant
app = create_assistant(
model="gpt-4o",
prompt="You are a helpful customer support assistant for Acme Corp.",
)
response = app.chat("What are your business hours?")
print(response.response)
With few-shot examples
app = create_assistant(
model="gpt-4o",
prompt="You are a triage assistant. Classify support tickets.",
examples=[
{
"user": "My order hasn't arrived after 2 weeks.",
"assistant": "Category: Shipping. Priority: High.",
},
{
"user": "I'd like to change my email address.",
"assistant": "Category: Account. Priority: Low.",
},
],
)
Multi-turn conversation
App retains session state automatically — each call to .chat() continues the same conversation:
app = create_assistant(model="gpt-4o", prompt="You are a helpful assistant.")
app.chat("My name is Alex.")
response = app.chat("What's my name?")
print(response.response) # "Your name is Alex."
Call app.reset_session() to start a fresh conversation.