Operate

Token usage

Trace input, output, and reasoning tokens.

Usage tracking is on by default. Any provider that reports AIMessage.usage_metadata is counted.

python
helper = Agent(
    name="helper",
    description="Answers arithmetic.",
    system_prompt="Be brief.",
)
root = Agent(
    name="desk",
    description="Routes helpers.",
    system_prompt="Coordinate the helper.",
    model=resolve_model(),
    sub_agents=[helper],
)
app = root.build(settings=settings)
print(app.chat("What is 2+2?"))
print(app.last_usage)   # this turn
print(app.usage)        # cumulative since build / reset_usage()
app.reset_usage()

Summaries include input_tokens, output_tokens, total_tokens, by_model, and token detail maps (including reasoning tokens when the provider reports them). Disable with settings.usage_tracking = False.