Skip to main content
This quickstart walks the ten-line path: create an agent, stream a run for one of your end users, and read that user’s spend. Use the language selector to switch between Python and TypeScript.

Before you start

Get an API key from celesto.ai under Settings > Security. Set it as CELESTO_API_KEY before you run the examples. Pick a stable string for the end user you are running on behalf of, such as "usr_8837" or an email. Celesto uses that string as the record key; you never store a Celesto ID.

Install the Python SDK

Create an agent and stream a run

Create managed_agent.py:
managed_agent.py
Run it:
The script prints the agent’s answer as it streams, then a summary line showing how much this user has spent and their cap.

What just happened

  • agents.create cut version 1 of support-bot. Every later update cuts a new version and leaves the old ones readable.
  • runs.stream yielded RunEvent objects: run.started, message.delta (partial text), message.completed, usage, and finally run.completed or run.failed. Event names this SDK does not know are ignored.
  • end_users.get returned the same "usr_8837" string you passed in. spent_usd and cap_usd are Decimal, not float.

Wait instead of streaming

runs.create waits and hands you the settled run:
wait.py

Set a budget

Give one user a cap, or set the default for everyone:
budget.py
Passing a float raises TypeError rather than sending it. Pass a Decimal or a string.

Next step

Read the managed agents reference for every namespace and every operation.
Last modified on August 14, 2026