tall-lamp-87106
08/19/2025, 6:37 AMtall-airline-16756
08/19/2025, 6:38 AMtall-airline-16756
08/19/2025, 6:38 AM<BASE_API_URL>/api/project/{PROJECT_ID}/sessions/{SESSION_ID}
.
• Programmatic Access via SDKs: Another option is the get_rtc_stats()
method in the LiveKit RTC SDKs. It helps you collect WebRTC stats, including publisher and subscriber info, which is great for figuring out bandwidth usage and connection minutes.
If you want me to walk you through any of these or need more details, just let me know—I’m here to help!
Sources: Say hello to improved Cloud analytics | livekit-rtc/livekit/rtc/room.py | livekit-ffi/src/server/requests.rs | packages/livekit-rtc/src/proto/room_pb.ts | Say hello to improved Cloud analyticstall-lamp-87106
08/19/2025, 6:43 AMget_rtc_stats()
method in the LiveKit RTC SDKs. It helps you collect WebRTC stats, including publisher and subscriber info, which is great for figuring out bandwidth usage and connection minutes.
Can I call it from agent? or how to get thistall-lamp-87106
08/19/2025, 6:44 AMget_rtc_stats()
method in the LiveKit RTC SDKs. It helps you collect WebRTC stats, including publisher and subscriber info, which is great for figuring out bandwidth usage and connection minutes.
Can I call it from agent? or how to get thistall-airline-16756
08/19/2025, 6:44 AMget_rtc_stats()
method from an agent in LiveKit to grab some useful RTC statistics, like publisher and subscriber stats. It’s available right on the Room object. Here’s a quick example to show you how it works:
async def entrypoint(ctx: JobContext):
session = AgentSession(llm=openai.realtime.RealtimeModel())
await session.start(Agent(instructions="You are a helpful assistant"), room=ctx.room)
# Log the session stats every 5 minutes
while True:
rtc_stats = await ctx.room.get_session_stats()
all_stats = chain(
(("PUBLISHER", stats) for stats in rtc_stats.publisher_stats),
(("SUBSCRIBER", stats) for stats in rtc_stats.subscriber_stats),
)
for source, stats in all_stats:
stats_kind = stats.WhichOneof("stats")
<http://logger.info|logger.info>(f"RtcStats - {stats_kind} - {source}", extra={"stats": MessageToDict(stats)})
await asyncio.sleep(5 * 60)
Just a heads-up: make sure the room is connected before you call this method, otherwise it’ll throw a RuntimeError. If anything’s unclear or you want a hand setting this up, just let me know—I’m here to help!
Sources: livekit-rtc/livekit/rtc/_proto/stats_pb2.pyi | examples/primitives/room_stats.pytall-airline-16756
08/19/2025, 6:44 AMget_rtc_stats()
method from an agent in LiveKit. This handy method is part of the Room object and gives you RTC statistics, including both publisher and subscriber stats. These stats are super useful for figuring out bandwidth usage and connection minutes.
Here’s a quick example to show you how it works:
async def entrypoint(ctx: JobContext):
session = AgentSession(llm=openai.realtime.RealtimeModel())
await session.start(Agent(instructions="You are a helpful assistant"), room=ctx.room)
# Log the session stats every 5 minutes
while True:
rtc_stats = await ctx.room.get_session_stats()
all_stats = chain(
(("PUBLISHER", stats) for stats in rtc_stats.publisher_stats),
(("SUBSCRIBER", stats) for stats in rtc_stats.subscriber_stats),
)
for source, stats in all_stats:
stats_kind = stats.WhichOneof("stats")
<http://logger.info|logger.info>(f"RtcStats - {stats_kind} - {source}", extra={"stats": MessageToDict(stats)})
await asyncio.sleep(5 * 60)
Just a heads-up: make sure your room is connected before calling this method, because it will raise a RuntimeError if it’s not. If you have any questions or want me to walk you through it, just let me know—I’m here to help!