Skip to content

Budget

Cost and token control for agent execution. Constrains how much an agent (or a session, chain, or batch) is allowed to spend.

Budget

Budget

Bases: BaseModel

Budget configuration for a Runtime.

BudgetScope

Scoped budget carved out of a parent — used by Runtime.budget_scope() and ChainStep.budget to limit cost on a per-step or per-segment basis.

BudgetScope

Scoped budget context — runs inside deduct from both scope and runtime.

Usage::

async with runtime.budget_scope(max_cost_usd=0.10) as scoped:
    result = await scoped.run("Filter items", ...)
    print(scoped.budget_used_usd)

run async

run(goal: str, **kwargs: Any) -> RunResult

Run with scoped budget enforcement.