interfaces.LLMUsage on LLMResponse.Usage. OpenAI, Anthropic, and Gemini clients populate the fields when the provider returns them.
An agent run can involve multiple LLM calls — the initial generation, then one more per tool round as the model processes tool results and decides next steps. AgentRunResult.LLMUsage is the sum across all rounds, giving you a single number for the full cost of a run.
Usage fields
CachedPromptTokens is populated by OpenAI automatically (server-side caching, no client option needed) and by Anthropic only when llm.WithPromptCaching(true) is set — it’s 0 for Anthropic otherwise, since caching is disabled by default there.
Run
AgentRunResult.LLMUsage is the sum across all LLM calls in that run — including tool rounds. Use it for cost estimates, quotas, and logging:
Stream
The same aggregate appears onLLMUsage in the AgentEventTypeRunFinished event — Result is an *AgentRunResult:
include_usage surfaces totals on RUN_FINISHED. Example: Stream.
Per-request usage
For per-LLM-call breakdowns — to log each round individually, enforce mid-run budgets, or build cost dashboards — useAfterLLMHook and inspect in.Response.Usage on each iteration:
Example
Simple Agent
SHOW_LLM_USAGE footer
Related
Reasoning
ReasoningTokens from extended thinking
Streaming
Usage on RUN_FINISHED events