able-egg-38713
12/26/2025, 10:15 AMtall-airline-16756
12/26/2025, 10:15 AMtall-airline-16756
12/26/2025, 10:15 AMable-egg-38713
12/26/2025, 10:18 AMtall-airline-16756
12/26/2025, 10:18 AMsession.input.set_audio_enabled(False) and session.output.set_audio_enabled(False)
▪︎ Node: session.input.setAudioEnabled(false) and session.output.setAudioEnabled(false)
◦ If the agent is speaking, call session.interrupt() to stop speech immediately.
• When the user unmutes:
◦ Re-enable audio I/O (True / true) to resume listening and speaking.
This keeps the agent session alive, avoids process shutdown, and allows instant resume. Would you like a short code snippet for your environment (Node or Python) or help wiring this to your frontend mute event?
Sources: Text and transcriptions | LiveKit docsable-egg-38713
12/26/2025, 10:19 AMtall-airline-16756
12/26/2025, 10:19 AMable-egg-38713
12/26/2025, 10:34 AMtall-airline-16756
12/26/2025, 10:34 AMgetStats() / localParticipant.getStats() in JS) to read inbound-rtp / outbound-rtp reports and calculate bitrate over time (bytesSent/bytesReceived → bits/sec).
◦ Example (JS): poll room.localParticipant.getStats() and compute delta of bytes over time to estimate bps per track.
◦ Note: SDK stats let you estimate per-track bandwidth but are not the official billing meter.
• Server / Console
◦ For billing-accurate metrics (total downstream bandwidth, connection minutes), use LiveKit Cloud analytics / Console where total usage is recorded and exported.
Would you like a short example snippet for your environment (Node or browser JS or Python) to start polling stats and computing bandwidth and connection time?
Sources: Understanding and Estimating Pricing for Video Conference and Livestream Us... | Announcing LiveKit Cloud | client-sdk-js | livekit/livekit_composite | DeepWiki | Say hello to improved Cloud analytics | LiveKit Pricingable-egg-38713
12/26/2025, 10:35 AMtall-airline-16756
12/26/2025, 10:35 AMimport time
from livekit import Room, RoomEvent
start_time = None
async def on_connected(_):
global start_time
start_time = time.time()
async def on_disconnected(_):
duration_s = time.time() - start_time
print(f"Connection duration: {duration_s:.1f} seconds")
room = Room()
room.on(RoomEvent.CONNECTED, on_connected)
room.on(RoomEvent.DISCONNECTED, on_disconnected)
# join the room as usual...
This mirrors billed connection minutes (server measures join → disconnect), so client timestamps are an accurate approximation.
Bandwidth estimation (per-track)
1. Poll track stats exposed by the SDK (these wrap WebRTC getStats). Compute byte deltas over time to get bps.
2. Example pattern:
import asyncio
import time
async def sample_bandwidth(local_participant, interval=1.0):
prev = {}
while True:
stats = await local_participant.get_stats() # list of reports
now = time.time()
for r in stats:
# look for outbound-rtp / inbound-rtp reports
if r.type in ("outbound-rtp", "inbound-rtp"):
key = (r.type, r.ssrc)
bytes_val = getattr(r, "bytesSent", None) or getattr(r, "bytesReceived", 0)
if key in prev:
prev_bytes, prev_time = prev[key]
delta_b = bytes_val - prev_bytes
delta_t = now - prev_time
bps = (delta_b * 8) / delta_t if delta_t > 0 else 0
direction = "sent" if r.type == "outbound-rtp" else "recv"
print(f"{direction} track {r.kind} ssrc={r.ssrc}: {bps:.0f} bps")
prev[key] = (bytes_val, now)
await asyncio.sleep(interval)
Notes and tips
• Use outbound-rtp reports for local published tracks and inbound-rtp for received tracks.
• Sum bps across tracks/subscribers to estimate downstream usage; upstream is local outbound.
• SDK stats are estimates (WebRTC-derived). Billing-grade totals (downstream bytes, connection minutes) are recorded server-side and available in LiveKit Cloud Console/analytics.
If you want, tell me whether you need:
• a complete runnable example (join flow + stats sampling), or
• code for agent sessions specifically (how to sample when agent is connected).able-egg-38713
12/26/2025, 10:51 AMtall-airline-16756
12/26/2025, 10:51 AMable-egg-38713
12/26/2025, 10:54 AMtall-airline-16756
12/26/2025, 10:54 AMable-egg-38713
12/26/2025, 10:55 AMtall-airline-16756
12/26/2025, 10:55 AMable-egg-38713
12/26/2025, 10:58 AMtall-airline-16756
12/26/2025, 10:58 AMable-egg-38713
12/26/2025, 10:58 AMtall-airline-16756
12/26/2025, 10:59 AMable-egg-38713
12/26/2025, 11:02 AMtall-airline-16756
12/26/2025, 11:02 AMget_egress_info() or participant stats into GB and cost, or
• Recompute your sample bill using GiB (1024^3) instead of GB (10^9). Which would be most helpful? Sources: LiveKit Pricing | Understanding and Estimating Pricing for Video Conference and Livestream Us... | Text and transcriptions | LiveKit docs | Deploying to production | LiveKit Docs | Server-side | livekit/livekit_composite | DeepWikiable-egg-38713
12/26/2025, 11:06 AMtall-airline-16756
12/26/2025, 11:06 AMsession.input.set_audio_enabled(False) and session.output.set_audio_enabled(False) to stop media while keeping the agent alive.
• Stop the agent when truly idle:
◦ Disconnect the agent if you expect long idle periods (this stops minute billing but requires restart on resume).
• Use short-lived agents when possible:
◦ Start agents on demand for interactions and shut them down after inactivity (implement idle timeout).
• Warm/cold strategy:
◦ Keep a small pool of warm agents for low-latency needs and spin up additional agents on demand.
2) Reduce WebRTC/participant minutes
• Only keep human participants connected when needed:
◦ Disconnect or move silent/idle users out of media rooms (use a lightweight signaling-only presence channel if you need presence without media).
• Aggregate sessions:
◦ For review/listen-only scenarios, consider recording once and serving playback instead of keeping everyone connected.
3) Reduce bandwidth (egress) costs
• Lower media bitrates:
◦ Use lower audio bitrates (e.g., 32–48 kbps for voice) and adaptive bitrate settings.
• Publish fewer tracks:
◦ Avoid sending unnecessary secondary tracks (e.g., multiple audio streams, high-res video).
• Use selective forwarding:
◦ Only subscribe participants to tracks they need; avoid forwarding every track to every participant.
• Pause output when user mutes:
◦ Disable agent output when the user mutes to stop downstream egress.
• Use recording/transcoding wisely:
◦ Store recordings server-side rather than streaming to many participants live.
4) Architect for efficient egress
• Fan-out considerations:
◦ Bandwidth is billed per downstream stream. Reduce number of simultaneous subscribers to heavy streams, or use a single mixed stream where appropriate.
• Use multicast/streaming for large audiences:
◦ For many listeners, consider converting a live room to a broadcast/streaming egress (CDN) to reduce repeated egress from LiveKit.
5) Monitor, measure, and automate
• Instrument join/disconnect timestamps and per-track stats (Python SDK get_stats() / admin API) to analyze hot spots.
• Use dashboard analytics to reconcile billed minutes and egress.
• Implement auto-scaling and idle timeouts based on real usage patterns.
6) Pricing-aware features
• Prefer free upstream (send) where possible — design interactions that minimize downstream server egress.
• Bundle sessions: group short interactions into fewer, longer sessions when agent-minute startup overhead is costly.
If you want, I can:
• Estimate potential savings for your workload if you share typical session length, concurrent users, and audio bitrate, or
• Provide a Python snippet to auto-pause agent I/O on user mute and log timestamps for billing reconciliation. Which would you like?able-egg-38713
12/26/2025, 11:17 AMtall-airline-16756
12/26/2025, 11:17 AM