- TokenMetricsPlugin: Records token usage statistics from ModelOutputThunk.usage
Classes
CLASS TokenMetricsPlugin
Records token usage metrics from generation outputs.
This plugin hooks into the generation_post_call event to automatically
record token usage metrics when the usage field is populated on
ModelOutputThunk instances.
The plugin reads the standardized usage field (OpenAI-compatible format)
and records metrics following OpenTelemetry Gen-AI semantic conventions.
Methods:
FUNC record_token_metrics
payload: Contains the model_output (ModelOutputThunk) with usage datacontext: Plugin context (unused)