Call agents from your backend
Deploy once, then chat many times. In production, deployment and chat usually happen in different places.
Deploy once, chat many times
Deploy once and save the app ID
Deploy from a script or CI job, not on every request.
app = Custodian(model="gpt-6-luna", system_prompt="...").deploy(name="support-bot")
print(app.app_id) # save this, e.g. as SUPPORT_BOT_APP_ID
Chat with that ID from your server
Use the Platform API:
curl -X POST "https://platform.custodianlabs.io/v1/apps/$SUPPORT_BOT_APP_ID/chat" \
-H "X-API-Key: $CUSTODIAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Where is my order?", "session_id": "session_ab12cd34ef56"}'
Keep each user's session
Store each user's session_id with their conversation, and send it back on their next
message so the agent remembers the context.
Keep the key on the server
browser → your backend → Custodian Labs (X-API-Key) → your backend → browser
Your API key is a secret. Never ship it to a browser or mobile app. Your backend owns authentication, logging and rate limits for your users. See Use API keys securely.
If you just need a chat page, the share link is already hosted and needs no backend.
Stream to a browser
The examples repo has a WebSocket bridge that relays chat between a browser page and a deployed agent while keeping the key on the server: websocket_examples.
Retries and timeouts
The SDKs retry network errors and 5xx responses for you. Over raw HTTP, retry those
with a short backoff and don't retry 4xx. See Error handling.