Expand description
Uniform usage reporting across all providers.
This module provides the UsageReport type that normalizes token usage
from all LLM providers into a consistent format. After each turn, the
session loop extracts input_tokens and output_tokens from the
UsageMetadata in the LLM response and produces
a uniform UsageReport.
§Provider Parity (Requirement 5.3)
Streaming token output and usage metadata (input/output tokens) SHALL be reported uniformly so the platform can meter cost per provider.
Different providers report usage with different field names:
- Gemini:
prompt_token_count/candidates_token_count - OpenAI:
prompt_tokens/completion_tokens - Anthropic:
input_tokens/output_tokens
All of these are normalized into adk-core’s UsageMetadata by each
provider’s client. This module further simplifies into UsageReport for
the managed runtime’s uniform reporting.
§Integration
The session loop calls UsageReport::from_usage_metadata after each turn
to extract usage information. The platform can then use this for billing,
monitoring, and cost tracking.
Structs§
- Session
Usage Tracker - Accumulated usage tracking for an entire session.
- Usage
Report - Uniform usage report emitted after each turn.