I am using livekit cloud but self hosting livekit ...
# ask-ai
m
I am using livekit cloud but self hosting livekit agents. Would I benefit from livekit inference? What would be the benefit compared to plugins?
t
Thanks for reaching out, Vinod. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether LiveKit Inference would help when you're on LiveKit Cloud but self-hosting agents — and how it compares to using plugins. Short answer: yes, you'd likely benefit. Below are the concrete differences so you can judge for your use case. Key benefits of LiveKit Inference for self-hosted agents • Unified API & simpler integration: one consistent interface for STT, LLM, TTS — no per-provider SDKs or code changes when swapping models. • No provider accounts or keys: authenticate and bill via your LiveKit Cloud account; you don’t need to create/manage OpenAI/ElevenLabs/etc. keys. • Consolidated billing: all model usage billed through LiveKit Cloud (PAYG), not separate invoices from each provider. • Lower and more consistent latency: inference runs in LiveKit Cloud regions and uses LiveKit’s network path, reducing public-internet round trips compared to calling external provider APIs. • Provisioned capacity / reliability: LiveKit offers provisioned capacity with partner providers for more predictable performance under load. • Easy model swapping: change a model string (e.g., for TTS/LLM/STT) without adding dependencies or provider-specific code. When you might prefer plugins • You need provider-specific features not exposed via Inference (for example, custom/cloned voices in ElevenLabs or Cartesia). • You want direct control of provider accounts, keys, or billing and need provider-specific configuration or advanced capabilities only available via the provider SDKs. If helpful, I can: • Suggest which model types to try first for low-latency voice agents (STT → LLM → TTS). • Compare specific providers/models for a given requirement (voice quality, cost, latency). Which of those would you like next? Sources: Introducing LiveKit Inference: A unified model interface for voice AI | Models | LiveKit Docs | Deploying to custom environments | LiveKit docs | Introducing LiveKit Inference: A unified model interface for voice AI | Introducing LiveKit Inference: A unified model interface for voice AI
m
in my case, does livekit inference help reduce latency?
t
Yes — LiveKit Inference will reduce latency for your setup (LiveKit Cloud + self-hosted agents). Why: • Inference runs in the same LiveKit Cloud regions, so requests travel over LiveKit’s network path instead of the public internet, cutting round-trip time and jitter. • LiveKit provides provisioned capacity with partner providers, avoiding public endpoint queues and provider-side throttling that add latency. • Unified concurrency/rate limits are applied at the LiveKit layer, giving more predictable response times under load. If you want, tell me: • where your agents are hosted (region/cloud), and • an example call flow (audio → STT → LLM → TTS), and I’ll estimate which steps will see the biggest latency improvement and suggest model choices to minimize end-to-end delay.
m
my agents are self hosted in aws us-west-2. I use deepgram stt, cartesia tts and openai llm
t
Yes — LiveKit Inference will reduce end-to-end latency for your setup (self-hosted agents in AWS us-west-2 using Deepgram STT, Cartesia TTS, and OpenAI LLM). Why you’ll see improvements • Shorter network path: your agent connects to the nearest LiveKit edge and inference requests traverse LiveKit’s private backbone instead of multiple public Internet hops to each provider. • Provisioned capacity: LiveKit’s dedicated capacity with partners avoids public endpoint queues and throttling that add variable delays. • Unified routing and concurrency: one connection and consistent rate limits at the LiveKit layer reduce per-request setup/retry overhead and make performance more predictable. • Streaming support: LiveKit enables chunked streaming across STT → LLM → TTS so you don’t wait for full outputs between stages. Practical impact for your stack • Deepgram STT: faster and more consistent transcription arrival vs. calling Deepgram’s public endpoint directly. • OpenAI LLM: lower RTT for prompt/response and more predictable latency under load. • Cartesia TTS: reduced TTS generation latency because requests use LiveKit’s optimized route and provisioned access. Next steps I can help with • Estimate expected latency savings given a sample call flow (share typical audio size, target response length, and whether you use streaming). • Suggest specific low-latency model choices and streaming configuration for STT/LLM/TTS. Which would you like first — a rough latency estimate from a sample call flow, or recommended models/config for minimal end-to-end delay? Sources: Introducing LiveKit Inference: A unified model interface for voice AI | Decentraland's Catalyst: using WebRTC to interact in the metaverse | Introducing LiveKit Inference: A unified model interface for voice AI | Live Conversations with AI using ChatGPT and WebRTC | Live Conversations with AI using ChatGPT and WebRTC
p
The weird thing is it works fine on my local docker-compose setup - but fails when running in cloud in a pod on eks
t
Thanks — I hear that it works locally but fails in your EKS pod. I can help troubleshoot; to narrow the cause I need a few details and a couple quick tests. Please provide: 1. Pod logs and any error messages from the failing agent (attach relevant log snippets). 2. Results of an in-pod connectivity test (run inside the pod and paste output): ◦ curl -v https://api.openai.com/v1/ (or Deepgram/Cartesia endpoints you call) ◦ nslookup api.openai.com 1. EKS node instance type(s) (e.g., t3.medium). 2. How secrets/API keys are injected into the pod (Kubernetes secret, mounted file, or env vars). 3. Pod network config: are you using a private subnet without NAT, VPC CNI, or any egress restrictions / network policies? 4. Whether the pod can open outbound WebSocket connections (if your agent uses streaming WS). Quick checks you can run now • From one failing pod: curl -I https://api.openai.com/v1/ and curl -I https://api.deepgram.com/ • Check kubectl describe pod <pod> for Events (CrashLoopBackOff, OOMKilled, ImagePullBackOff). • kubectl exec -it <pod> -- sh and run top or cat /proc/cpuinfo to confirm CPU availability. Based on common causes I’ll look for after you share the info: • CPU throttling on burstable instances (t3/t4 family) causing timeouts. • Missing/mismounted secrets or incorrect env vars. • Egress blocked by subnet/NAT or network policy preventing HTTPS/WS to providers. • Firewall/ports or DNS resolution issues. Send the logs and results and I’ll point to the most likely fix and exact commands/config changes to try. Sources: Introducing LiveKit Inference: A unified model interface for voice AI | Troubleshooting Latency and Timeout Errors with Turn Detection on AWS | Ports and firewall | LiveKit docs | Agent deployment CLI reference | LiveKit docs | Still Have Questions
p
So the pod itself is not getting killed - it is the agent process that is getting killed as per the logs. there are no further error messages..
t
Thanks — that helps. Since the pod stays up but the agent process is killed with no errors, let’s focus on a few likely causes and quick diagnostics to narrow it down. Please collect/run these and paste results or log snippets: 1) Agent exit info • From pod logs, capture the last ~200 lines before the process dies. • From inside the pod, run the agent under a loop to capture its exit code: ◦ kubectl exec -it <pod> -- sh -c 'while true; do ./start-agent || echo "EXIT:$?"; sleep 1; done' ◦ Share the printed EXIT code (e.g., EXIT:137). 2) Check for OOM / kernel kills • kubectl describe pod <pod> — look at Events for OOMKilled or SIGKILL. • On the node, check dmesg or kubelet logs for OOM killer messages (if you have access). 3) Resource limits and usage • Show the pod spec (limits/requests) and the Deployment/StatefulSet manifest. • While the agent runs, capture usage: ◦ kubectl top pod <pod> ◦ kubectl exec -it <pod> -- sh -c 'ps aux --sort=-%mem | head -n 10' and 'ps aux --sort=-%cpu | head -n 10' 4) Check for CPU throttling on the node • Share your node instance type(s). Burstable instances (t3/t4) can be throttled and cause processes to be killed under sustained CPU. • If using burstable types, try a node with fixed CPU (m5/c5) or increase requests/limits. 5) Runtime crashes / segfaults • Run the agent with core dumps enabled to capture a crash: ◦ kubectl exec -it <pod> -- sh -c 'ulimit -c unlimited; ./start-agent' • If a core dump appears, collect it for analysis. 6) Missing env/secret or startup race • Confirm provider keys and required envs are present in the running pod: ◦ kubectl exec -it <pod> -- sh -c 'env | grep -E "OPENAI|DEEPGRAM|CARTESIA|LIVEKIT"' • Run the agent interactively to see any startup warnings. 7) Network / external call timeouts causing process exit • From inside the pod, run quick connectivity tests while agent is running: ◦ curl -I https://api.openai.com/v1/ -s -o /dev/null -w "%{http_code} %{time_total}\n" ◦ curl -I https://api.deepgram.com/ -s -o /dev/null -w "%{http_code} %{time_total}\n" • If those hang or are slow, the agent may hit internal timeouts and exit. 8) Probe / liveness interplay • If you use liveness/readiness probes, share their config — a failing probe can SIGKILL the container process even if the pod remains. If you share: • the agent exit code (from step 1), • pod spec (limits/requests, probes), • node instance types, • and the last 200 log lines before kill, I’ll point to the specific root cause and exact fixes to try (memory/CPU limit changes, core dump analysis, or changing node types). Which of those can you provide first?
p
Agent conversation including tts stt llm calls works fine as long as tool is not invoked -- resources: limits: cpu: '4' memory: 4Gi requests: cpu: '4' memory: 4Gi
t
Thanks — useful detail. You said the agent runs STT/LLM/TTS fine but the process is killed when a tool is invoked. That strongly suggests the tool invocation is triggering a resource or runtime issue. Let’s narrow it quickly. Please provide or check the following (fast tests and info): 1) Exit code when killed • Run the start loop to capture the exit code: kubectl exec -it <pod> -- sh -c 'while true; do ./start-agent || echo "EXIT:$?"; sleep 1; done' • Share the printed EXIT code (e.g., EXIT:137 or EXIT:9). 2) Last logs around the kill (200 lines) • kubectl logs <pod> --tail=200 • Paste the last 50–200 lines before the kill. 3) Is the tool a subprocess or external binary? • Does the agent spawn a child process or call an external binary (ffmpeg, custom model runtime, etc.) when invoking the tool? If yes, name it and confirm it’s included in the container image. 4) Memory / OOM checks (despite limits) • kubectl describe pod <pod> — look for OOMKilled or container restart Events and paste Events. • kubectl top pod <pod> right before invoking the tool (or run in a loop) to capture peak memory. • On the node, check dmesg for OOM killer messages if available. 5) CPU throttling / cgroup kill (if exit code 137) • Confirm node instance types. Burstable instances (t3/t4) can cause throttling. If EXIT:137, try a node with dedicated CPU (m5/c5) or increase CPU limits/requests. 6) Disk/ephemeral storage or ulimits • Does the tool write large temp files? Check ephemeral storage usage: kubectl exec -it <pod> -- sh -c 'df -h /tmp /' • Check ulimits: kubectl exec -it <pod> -- sh -c 'ulimit -a' 7) Permissions / seccomp / AppArmor / ptrace restrictions • If the tool needs special privileges (native binaries, GPU access, creating threads), ensure the podSecurityPolicy / securityContext allows it. 8) Core dumps or segfaults (if EXIT not 137) • Enable core dumps and run once: kubectl exec -it <pod> -- sh -c 'ulimit -c unlimited; ./start-agent' • If a core file appears, collect it. 9) Reproduce interactively • kubectl exec -it <pod> -- sh then run the exact tool invocation command manually to see stderr in real time. If you can first share: • the EXIT code, • the last 100–200 log lines before kill, • whether the tool is an external binary and its name, • node instance types — I’ll pinpoint the most likely root cause and exact fixes (memory/cpu tuning, include binary in image, adjust securityContext, or change node type). Which of those can you share now?
p
pod runs on : c5a.2xlarge.. the exist code is provideded in the intial logs
t
Thanks — I see the pod is on c5a.2xlarge and the exit code is in your initial logs. You're reporting the agent is killed only when a tool is invoked. That points to the tool triggering a runtime or resource issue (not node-level throttling, since c5a has dedicated CPU). Next steps I can take for you — please provide two quick items so I can pinpoint the cause: 1) Paste the exact exit code shown in the initial logs (e.g., EXIT:137, EXIT:9). 2) Tell me which tool is invoked (name and whether it spawns a subprocess/binary like ffmpeg, a local model runtime, or an external network call). If you prefer to run checks first, run these and paste outputs: • kubectl logs <pod> --tail=200 (last 200 lines before crash) • kubectl exec -it <pod> -- sh -c 'ps aux --sort=-%mem | head -n 10; ps aux --sort=-%cpu | head -n 10' (right before invoking the tool) • kubectl exec -it <pod> -- sh -c 'df -h /tmp /; ulimit -a' • If the tool is local binary: try running it interactively inside the pod to capture stderr. Once I have the exit code and tool name (and optionally the log snippet), I’ll tell you the most likely root cause and exact fixes to try (memory tuning, ephemeral storage, securityContext, enabling core dumps, or including the binary). Which do you want to provide now?