rapid-honey-43838
02/27/2026, 8:52 AMtall-airline-16756
02/27/2026, 8:52 AMtall-airline-16756
02/27/2026, 8:52 AMmin_endpointing_delay and false_interruption_timeout to trigger responses faster while minimizing false-interruptions.
• Choose stable compute and deployment patterns
◦ Run agents on non-burstable instance types (for example, m5/c5/c6i) to avoid CPU credit throttling that causes timeouts and unpredictable latency.
◦ Avoid burstable instances (t3/t4g) unless you actively monitor CPU credit balance.
◦ On LiveKit Cloud, use serverless agents with cold-start prevention enabled to keep warm capacity.
• Containerization and resource isolation
◦ Run agents in dedicated containers so inference work isn’t contending with unrelated processes.
◦ Pre-download model assets into containers and run as non-root users for consistent startup times.
• Monitor the right metrics
◦ Track Time To First Token (TTFT): time from end-of-speech to first LLM token. Aim for < 300 ms where possible.
◦ Track Time To First Byte (TTFB) for TTS audio: aim for < 200 ms where possible.
◦ Use Agents Metrics APIs and LiveKit observability to find which step (STT, LLM, TTS, network) is the dominant bottleneck.
• Provider and plan selection
◦ Prefer providers optimized for real-time workloads (examples include OpenAI, Deepgram, Cartesia).
◦ Consider higher-tier LiveKit plans (Ship or Scale) to reduce cold starts and increase concurrency limits.
Quick troubleshooting checklist (if you’re seeing intermittent latency spikes)
• Is agent CPU pegged or throttled? (If using burstable instances, check CPU credits.)
• Are inference requests routed over the public internet or over LiveKit Inference’s private backbone?
• Are STT/TTS/LLM providers in the same region as your agents?
• Are models cold-starting frequently? (Check container/process start times.)
• Inspect TTFT and TTFB traces to identify which stage causes most delay.
Questions so I can give a targeted plan
• Where are your agents currently deployed? (self-hosted region/instance types or LiveKit Cloud)
• Which STT, TTS, and LLM providers and models are you using?
• Do you see consistent latency or intermittent spikes? Can you share sample TTFT/TTFB numbers?
• Are you using serverless agents or long-running containers?
• Are you already using LiveKit Inference or planning to migrate to it?
If you share the answers above (region/instance type/providers/current metrics), I’ll propose a concrete optimization plan with specific configuration values and steps to measure improvement.
Sources: How can I reduce latency in voice agents using STT, TTS and LLM? | LiveKit | Agents Framework | livekit/livekit_composite | DeepWiki | examples/frontdesk | livekit/livekit_composite | DeepWiki | Building Performant Voice Agents in India | LiveKit | Introducing LiveKit Inference: A unified model interface for voice AIrapid-honey-43838
02/27/2026, 9:16 AMtall-airline-16756
02/27/2026, 9:17 AMlk cloud auth) to manage API keys and deployments.
• Make sure your environment can reach LiveKit Cloud (or your self-hosted LiveKit if applicable).
Basic usage examples
• Python (LLM):
from livekit.agents import AgentSession
session = AgentSession(
llm="openai/gpt-4.1-mini"
)
• Node.js (LLM):
import { AgentSession } from "@livekit/agents";
const session = new AgentSession({
llm: "openai/gpt-4.1-mini"
});
• Specify STT (example: Cartesia, with language tag):
session = AgentSession(
stt="cartesia/ink-whisper:en"
)
const session = new AgentSession({
stt: "cartesia/ink-whisper:en"
});
Custom configuration
• Use typed classes in the inference module to set provider or extra model parameters.
Python example:
from livekit.agents import AgentSession, inference
session = AgentSession(
llm=inference.LLM(
model="openai/gpt-5-mini",
provider="openai",
extra_kwargs={"reasoning_effort": "low"}
)
)
Node.js example:
import { AgentSession, inference } from "@livekit/agents";
const session = new AgentSession({
llm: new inference.LLM({
model: "openai/gpt-5-mini",
provider: "openai",
modelOptions: { reasoning_effort: "low" }
})
});
(Note: Node uses modelOptions instead of extra_kwargs.)
Supported models & providers
• LLMs: OpenAI, Google/Gemini, DeepSeek, Kimi (via Baseten), etc.
• STT: Deepgram, AssemblyAI, Cartesia, ElevenLabs, etc.
• TTS: Cartesia, ElevenLabs, etc.
• For full lists and IDs, see the LLM/STT/TTS model pages in the LiveKit docs: https://docs.livekit.io/agents/models/
Key features & benefits
• Unified API key and consolidated billing for multiple providers.
• Global co-location and provisioned capacity to reduce latency and avoid public endpoint congestion.
• Centralized concurrency management in the LiveKit Cloud dashboard.
• Dynamic routing (coming soon) for automatic low-latency provider selection.
Getting started resources
• Voice AI quickstart: https://docs.livekit.io/agents/start/voice-ai-quickstart/
• Models overview and per-provider model pages: https://docs.livekit.io/agents/models/
• Starter repo (example): https://github.com/livekit-examples/agent-starter-python
If you want a targeted setup, tell me:
• Are you using LiveKit Cloud or self-hosting?
• Which STT, LLM, and TTS providers or model IDs do you plan to use?
• Do you want a minimal voice demo (quickstart) or a production-ready agent with monitoring and scaling?
Share those details and I’ll give step-by-step instructions tailored to your environment (including CLI commands, AgentSession configs, and suggestions for latency/scale).
Sources: Tom Shapland - LiveKit Blog | Models overview | LiveKit Documentation | Voice AI quickstart | LiveKit Documentation | OpenAI and LiveKit | LiveKit Documentation | Cartesia STT | LiveKit Documentationrapid-honey-43838
02/27/2026, 9:21 AMtall-airline-16756
02/27/2026, 9:21 AMopenai/gpt-4.1-mini or a real‑time optimized family). Tune up to larger models only when you need capability over latency.
◦ STT: low‑latency, streaming STT like cartesia/ink-whisper:en or Deepgram for real‑time fidelity.
◦ TTS: provider/model that supports streaming audio and small chunk sizes (Cartesia/ElevenLabs variants).
• AgentSession example (sensible production defaults)
◦ Use explicit inference classes when you want provider or parameter control:
▪︎ Python:
from livekit.agents import AgentSession, inference
session = AgentSession(
stt=inference.STT(model="cartesia/ink-whisper:en"),
llm=inference.LLM(model="openai/gpt-4.1-mini"),
tts=inference.TTS(model="cartesia/voice-v2")
)
• Node.js: same mappings, using modelOptions for extra parameters.
• Turn detection & VAD
◦ Prewarm VAD and STT processes on startup.
◦ Typical turn detection tuning:
▪︎ `min_endpointing_delay`: low value to reduce wait after speech end (example starting: 50–150 ms).
▪︎ `false_interruption_timeout`: short but forgiving (example starting: 150–300 ms) to avoid prematurely cutting users off.
◦ Enable preemptive generation when safe for your use case to start LLM inference before the user fully finishes speaking.
• Concurrency & scaling
◦ Use LiveKit Cloud concurrency controls (provisioned capacity) to guarantee model throughput.
◦ Horizontally scale agents by spinning additional containers/instances rather than overloading a single large host.
• Instance and container sizing
◦ CPU/memory tuned to model and STT/TTS workload; prefer steady VM families (m5/c5) sized to handle peak concurrency per container.
◦ Avoid burstable `t3`/`t4g` families due to CPU‑credit throttling risk.
• Networking
◦ Keep agents and model providers in same region. If using LiveKit Cloud, leverage its co‑location/prioritized routing.
◦ Use secure, high‑throughput NICs and monitor network queueing.
• Monitoring & alerts
◦ Instrument and alert on:
▪︎ Time To First Token (TTFT) — from end of user speech to first LLM token. Target < 300 ms for low‑latency experiences.
▪︎ Time To First Byte (TTFB) for TTS audio. Target < 200 ms where possible.
▪︎ Request error rates, provider latency percentiles (p50/p95/p99).
▪︎ CPU, memory, and container start times (to detect cold starts).
◦ Use Agents Metrics API and LiveKit observability dashboards to map stage‑by‑stage latency (STT → LLM → TTS).
• Failover and provider diversification
◦ Configure fallback providers/models for each inference type (STT/LLM/TTS) so you can reroute if a provider has high latency.
◦ Use LiveKit Inference’s provider selection to prefer low‑latency routes.
• Billing & cost controls
◦ Track per‑model consumption via LiveKit Cloud billing/usage dashboards.
◦ Use smaller, faster models for real‑time interactions; reserve larger models for background or high‑value tasks.
Optional tuning for lower latency (aggressive)
• Turn detection: lower min_endpointing_delay further and favor preemptive generation.
• Use ultra‑low latency STT providers (streaming STT) and LLMs optimized for real‑time.
• Pin agents in very low network‑hop regions (same AZ as model provider).
• Increase provisioned concurrency and use dedicated instances for hot paths.
Optional tuning for cost efficiency (conservative)
• Use smaller LLMs for baseline conversation and selectively call larger models for complex tasks (routing by intent).
• Batch background tasks and non‑real‑time processing to cheaper compute.
• Scale down reserved capacity during off‑peak hours.
Checklist to validate production readiness
• Agents warm on deploy (no frequent cold starts).
• TTFT and TTFB steady and within targets at p95.
• No CPU throttling (no burstable instances unless monitored).
• Fallback providers configured and tested.
• Monitoring/alerts cover latency, errors, and cold starts.
If you’d like, I can:
• Generate a copy‑paste AgentSession config tuned to your expected concurrency and latency targets.
• Recommend instance/container sizing given expected calls per second.
• Walk through a staging checklist (deploy → smoke tests → latency profiling).
Tell me which of the following applies and I’ll produce a tailored config:
• You’re on LiveKit Cloud or self‑hosting?
• Expected concurrent calls per second and average call duration.
• Primary STT/LLM/TTS providers you plan to use.rapid-honey-43838
02/27/2026, 9:23 AMtall-airline-16756
02/27/2026, 9:23 AMfrom livekit.agents import AgentSession, inference
session = AgentSession(
stt=inference.STT(model="deepgram/streaming"), # replace with exact model id from LiveKit docs
llm=inference.LLM(model="openai/gpt-4.1-mini"), # or your preferred low-latency LLM
tts=inference.TTS(model="elevenlabs/voice-v2") # replace with chosen voice id
)
• Node.js:
import { AgentSession, inference } from "@livekit/agents";
const session = new AgentSession({
stt: new inference.STT({ model: "deepgram/streaming" }),
llm: new inference.LLM({ model: "openai/gpt-4.1-mini" }),
tts: new inference.TTS({ model: "elevenlabs/voice-v2" })
});
• Replace model IDs with the exact IDs listed in LiveKit’s model pages for Deepgram and ElevenLabs.
Turn detection & VAD
• Prewarm VAD and STT processes on startup to avoid cold starts.
• Suggested starting tuning:
◦ min_endpointing_delay: 50–150 ms (lower gives faster responses; increase if you see fragmenting).
◦ false_interruption_timeout: 150–300 ms (avoids accidental cutoffs).
• Enable preemptive generation where appropriate to start LLM work while the user is finishing their utterance.
Container/instance choices
• Use non‑burstable instances (m5/c5/c6i) or LiveKit serverless with cold‑start prevention.
• Run each agent in a dedicated container with predownloaded assets; keep agents long‑running rather than ephemeral.
Concurrency & scaling
• Horizontally scale by spinning additional agent containers instead of overloading a single host.
• Use LiveKit Cloud’s provisioned concurrency to guarantee throughput to Deepgram/ElevenLabs.
• Set per-agent max concurrency based on CPU and network profiling; typical starting point is 5–20 concurrent calls per medium instance, then tune.
Networking & region
• Co‑locate agents with your provider region (same region/AZ) or use LiveKit Cloud co‑location.
• Ensure low‑latency NICs and monitor packet loss — network issues amplify STT/TTS latency.
Monitoring & metrics (must-haves)
• Track Time To First Token (TTFT) — end of user speech to first LLM token.
• Track Time To First Byte (TTFB) for TTS audio.
• Monitor STT latency (streaming lag), LLM latency, and TTS generation time separately to pinpoint bottlenecks.
• Alert on p95/p99 latency increases and on error rates for Deepgram/ElevenLabs calls.
Quality vs latency tradeoffs
• If you need lower latency: choose lighter ElevenLabs voices and lower TTS chunk sizes, and prefer lower‑latency STT model variants.
• If you need higher quality: pick richer ElevenLabs voices and allow slightly higher buffering (but measure TTFB impact).
Failure handling & fallbacks
• Configure a fallback TTS voice/model (another ElevenLabs voice or a lighter Cartesia voice) if response time exceeds a threshold.
• Retry logic: exponential backoff for transient provider failures; consider failing over to alternate provider if latency > threshold.
Operational checklist before production
• Validate TTFT and TTFB at expected load (p50/p95/p99).
• Confirm no CPU throttling (avoid burstable instances).
• Verify agents stay warm and do not cold-start under normal traffic.
• Test fallback path and error handling for both STT and TTS.
If you want, I can:
• Provide exact model IDs from the LiveKit model pages for Deepgram and ElevenLabs.
• Generate a ready-to-copy AgentSession config tuned for a target concurrency (tell me expected concurrent calls and region).
• Suggest instance/container sizing based on expected calls per second and average call duration.
Which of these would be most helpful next?