stale-family-24843
08/29/2025, 2:19 PMtall-airline-16756
08/29/2025, 2:19 PMtall-airline-16756
08/29/2025, 2:19 PMpip install "livekit-agents[openai]~=1.2" and make sure your OpenAI API key is set up in the OPENAI_API_KEY environment variable.
2. Basic Configuration: Kick things off by initializing the session with the openai.realtime.RealtimeModel() class. Here’s a quick example:
from livekit.agents import AgentSession
from livekit.plugins import openai
session = AgentSession(
llm=openai.realtime.RealtimeModel()
)
3. Customization: You can tweak settings like the model (the default is gpt-4o-realtime-preview), pick a voice (think alloy or nova), adjust the temperature, and choose modalities such as ["text", "audio"].
4. Advanced Options: There are cool features you can turn on like detecting turns, transcribing input audio, and customizing how long your session lasts.
5. Integration: If you want to use scripted speech, just pair the realtime model with a separate TTS plugin by setting modalities=["text"].
If you’d like, I can share a complete example or help you with any part of this—just let me know!
Sources: OpenAI Realtime API integration guide | LiveKit Docs | Realtime model integrations | LiveKit Docs | examples/voice_agents/realtime_load_chat_history.py | OpenAI and LiveKit partner to turn Advanced Voice into an API