handsome-manchester-97799
06/05/2025, 12:36 PMtall-airline-16756
06/05/2025, 12:36 PMtall-airline-16756
06/05/2025, 12:37 PMUsageCollector class provided by the LiveKit Agents framework. This class tracks various metrics, including:
• LLM prompt tokens
• LLM completion tokens
• TTS (text-to-speech) character count
• STT (speech-to-text) audio duration (in seconds)
To use it, you can create an instance of UsageCollector and pass metrics to it:
collector = UsageCollector()
collector(metrics) # or collector.collect(metrics)
To retrieve the aggregated usage summary, you can use:
summary = collector.get_summary()
The UsageSummary object will provide the total counts for each metric type tracked during the agent's operation.
Sources: livekit.agents.metrics.usage_collector API documentation | livekit.agents.metrics API documentationhandsome-manchester-97799
06/05/2025, 12:37 PMtall-airline-16756
06/05/2025, 12:37 PMUsageCollector class is available in LiveKit Agents v1.0 and is part of the agents.metrics module. It allows you to collect and track usage metrics across different agent components, such as:
• LLM prompt tokens
• LLM prompt cached tokens
• LLM completion tokens
• TTS (text-to-speech) character count
• STT (speech-to-text) audio duration
Key features include:
• A constructor to initialize a new UsageCollector instance
• A collect(metrics) method to process and update metrics
• A summary accessor to retrieve a UsageSummary object with the collected metrics
If you need further assistance with implementing this in v1.0, feel free to ask!
Sources: Tree View: | dse-workbench | UsageCollector | LiveKit Agentshandsome-manchester-97799
06/05/2025, 1:12 PMUsageCollectortall-airline-16756
06/05/2025, 1:12 PMUsageCollector in LiveKit Agents v1.0, you can use the following import statement:
from livekit.agents.metrics.usage_collector import UsageCollector
This class is located in the livekit/agents/metrics/usage_collector.py file and is used to collect and track usage metrics for various components, such as LLM, TTS, and STT.
Sources: Tree View: | dse-workbench