boundless-author-7811
04/16/2026, 9:32 AMtall-airline-16756
04/16/2026, 9:32 AMtall-airline-16756
04/16/2026, 9:32 AMboundless-author-7811
04/16/2026, 9:34 AMtall-airline-16756
04/16/2026, 9:34 AMinput_tokens, input_cached_tokens, output_tokens) for billing.
I can compute a final cost — please tell me which per-1M rates to use for:
• Input (uncached) rate
• Cached input rate
• Output rate
If you’d like, I can use example rates and show the full numeric total. Which do you prefer?
Sources: https://livekit.com/pricing.md| | Build voice, video, and physical AI | LiveKit, with interactive elementsboundless-author-7811
04/16/2026, 9:36 AMtall-airline-16756
04/16/2026, 9:36 AMboundless-author-7811
04/16/2026, 9:46 AMtall-airline-16756
04/16/2026, 9:47 AMmetrics_collected (or provider-specific metrics) event on your AgentSession; the metrics payload includes input_tokens, input_cached_tokens, and output_tokens.
• For OpenAI-style providers, the model response also returns prompt_tokens (input), completion_tokens (output), and `total_tokens`; LiveKit passes these through.
• You can aggregate or report per-call usage with the UsageCollector utility, which processes metrics_collected events and sums token counts per call/service.
Example (Python-style):
@session.on("metrics_collected")
def on_metrics(metrics):
print("input_tokens:", metrics.input_tokens)
print("input_cached_tokens:", metrics.input_cached_tokens)
print("output_tokens:", metrics.output_tokens)
Notes:
• Use input_tokens and input_cached_tokens together to compute billed input (uncached = `input_tokens - input_cached_tokens`; cached billed separately).
• Audio/text subfields (e.g., input_audio_tokens, input_text_tokens) are components of the totals; use the totals for billing unless you have separate audio/text rates.
If you want, tell me your SDK/language and I’ll give a short code example for that environment.
Sources: Realtime model metrics | LiveKit Documentation | OpenAI LLM models | LiveKit Documentation | Agents (Python) | livekit/livekit_composite | DeepWiki, with interactive elementsboundless-author-7811
04/16/2026, 9:48 AMtall-airline-16756
04/16/2026, 9:49 AMsession_usage_updated — here's what it is and how to use it.
• Purpose: session_usage_updated notifies you of aggregated usage changes for an AgentSession (e.g., updated totals for input tokens, cached input tokens, output tokens, and potentially audio/text subfields). It’s useful for tracking session-level billing and showing live usage to users.
• How it differs from `metrics_collected`:
◦ metrics_collected is emitted per LLM call or metric collection interval and contains granular metrics for that event.
◦ session_usage_updated provides the updated session-wide totals (cumulative) after those granular metrics are applied.
• What to read from it:
◦ Use the session totals (input_tokens, input_cached_tokens, output_tokens) from session_usage_updated for session-level billing and reporting.
◦ To compute per-call billed amounts, subtract the previous session totals from the new totals to get per-call delta, then apply your pricing (uncached = input − cached; cached billed at cached rate; output billed at output rate).
• Example flow:
a. Listen for session_usage_updated.
b. On each event, compute delta = new_totals − previous_totals.
c. Apply pricing to the delta tokens (uncached vs cached vs output).
d. Update UI or billing records with the computed delta cost and new cumulative totals.
If you want, tell me which SDK/language you use and I’ll give a brief code snippet showing how to listen for session_usage_updated and compute the per-call delta.
, with interactive elements