interfaces.LLMUsage on LLMResponse.Usage. OpenAI, Anthropic, and Gemini clients populate the fields when the provider returns them.
Usage fields
| Field | Description |
|---|---|
PromptTokens | Input tokens |
CompletionTokens | Output tokens |
TotalTokens | Sum when reported by provider |
CachedPromptTokens | Prompt cache hits (when supported) |
ReasoningTokens | Extended thinking tokens (when supported) |
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.
RunAsync
Token usage is on the finalAgentRunAsyncResult when the run completes — same aggregate as Run.
Per-request usage
For per-LLM-call breakdowns, 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
LLM Providers
Provider-specific usage reporting
Observability
Export usage as metrics