Skip to main content
Using a WebSocket connection, your voice agent can interact in real-time with your custom LLM, enabling dynamic and responsive conversational capabilities based on your specific requirements.

Sample Code

A sample code using FastAPI websocket and asyncio. Make sure to use the AsyncOpenAI client to prevent OpenAI from blocking the asyncio thread during token streaming. This ensures messages are sent immediately via websocket.