enough-dentist-75383
11/12/2025, 1:15 PMtall-airline-16756
11/12/2025, 1:15 PMtall-airline-16756
11/12/2025, 1:16 PMlog_metrics helper function that comes with the LiveKit Agents SDK. Let me walk you through how to set it up:
1. Listen for the metrics_collected Event:
First, subscribe to the metrics_collected event on your session. This way, you’ll be able to capture metrics related to STT, TTS, or LLM operations as they happen.
2. Use the log_metrics Helper:
Next, simply pass the metrics object you receive to metrics.log_metrics() if you’re using Python, or metrics.logMetrics() for JavaScript/TypeScript. This handy function takes care of formatting and logging the right fields depending on the type of metric.
Here’s a quick example in Python:
from livekit.agents import metrics, MetricsCollectedEvent
@session.on("metrics_collected")
def _on_metrics_collected(ev: MetricsCollectedEvent):
metrics.log_metrics(ev.metrics) # This logs STT, TTS, and LLM metrics automatically
What Gets Logged?
• STT Metrics: This includes audio_duration (the input audio length) and duration (how long processing took).
• TTS Metrics: You’ll see ttfb (time to first byte), audio_duration, and character count logged.
• LLM Metrics: This covers ttft (time to first token), token usage, and throughput.
If you want to dive deeper into your metrics, you can use the UsageCollector class to gather data over time, or enable OpenTelemetry for more detailed tracing. I hope this helps you get started smoothly—feel free to reach out if you have any questions!
Sources: Logs, metrics, and telemetry | LiveKit docs | livekit-agents/livekit/agents/metrics/base.py | examples/src/basic_agent.ts | metrics/metrics_stt.pyenough-dentist-75383
11/12/2025, 1:26 PMtall-airline-16756
11/12/2025, 1:27 PMlivekit-agents version 1.2.5? For instance:
• Are there any version conflicts or missing dependencies that you've noticed?
• Do any specific error messages pop up during installation or when you're running it?
Once I have these details, I'll be better equipped to guide you through a solution. Looking forward to helping you get this sorted!
Sources: Python Agents Core Architecture | livekit/livekit_composite | DeepWiki | package-lock.json | AI Service Plugin Ecosystem | livekit/livekit_composite | DeepWikienough-dentist-75383
11/12/2025, 1:27 PMtall-airline-16756
11/12/2025, 1:27 PM