why we don't use webRtc while connecting agent ser...
# ask-ai
s
why we don't use webRtc while connecting agent server to stt, llm or tts and use websocket
t
Thanks for reaching out, Ayush. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking why the agent server uses WebSocket (not WebRTC) to talk to STT, LLM, or TTS services. Good question — here's the short, practical reason and how the pieces fit together. • WebRTC is built for browser/client media transport (low‑latency audio/video between user and server). It’s optimized for client-facing media and uses UDP-based media channels, which is ideal for delivering user audio/video but not intended for backend API-to-backend API communication. • WebSocket is full‑duplex TCP and is the standard for streaming server-to-server APIs. STT/LLM/TTS providers expose streaming inference over WebSockets, so using WebSocket gives simple, reliable bidirectional streams that match those APIs. • Practically LiveKit uses a hybrid: ◦ WebRTC between the user’s device and the LiveKit agent (for audio/video). ◦ WebSocket between the agent server and external AI services (STT/LLM/TTS) to stream input/output to/from those models. • Using WebSocket avoids the added complexity of running WebRTC in server environments and aligns with how AI providers expose real‑time endpoints. If you want, I can illustrate a simple data flow diagram or show example message sequences for the WebSocket stream to an LLM/STT/TTS. Which would help more? Sources: An open source stack for real-time multimodal AI | OpenAI and LiveKit partner to turn Advanced Voice into an API | livekit/livekit_composite | DeepWiki | OpenAI and LiveKit | LiveKit Docs