Please explain the ‘use_realtime’ parameter for Op...
# ask-ai
m
Please explain the ‘use_realtime’ parameter for OpenAI STT.
t
Thanks for reaching out, Alexander. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! The
use_realtime
parameter in OpenAI STT is what lets you decide if you want to use OpenAI's Realtime Transcription API for recognizing speech. When you set it to
True
, it turns on streaming transcription with interim results, so you get the audio processed as it’s being spoken. This is super handy for things like live captioning or interactive voice agents where you want things happening in real-time. Here are some key points to keep in mind: • Turning on
use_realtime=True
means you get streaming and interim results. • It uses WebSocket to send audio chunks continuously for transcription. • There’s server-side voice activity detection (VAD) that helps finalize the transcripts. • Keep in mind, this can add a bit more cost because of the ongoing STT processing. • By default, it’s set to
False
, so you get the regular, non-streaming transcription unless you decide to enable it. Sources: Realtime model integrations | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/__init__.py | LiveKit turn detector plugin | LiveKit Docs
m
What model can I use with this parameter set to true?
t
When you set the
use_realtime
parameter to
true
, you can use these models: •
gpt-4o-mini-transcribe
(this is the default model) •
whisper-1
(used with Azure OpenAI Service) Both of these work great with the Realtime API for streaming transcription. If you want to know more or need a hand with anything, just let me know! Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | examples/src/cartersia_tts.ts
m
What should my parameters be when u’m using OpenAI turn detection e.g. semantic turn detection
t
When you're working with OpenAI turn detection, including semantic turn detection, the parameters you'll use depend on the mode you pick: 1. Server VAD (Default) • `type`: Set this to
"server_vad"
. • `threshold`: A float value that controls noise sensitivity (use a higher value if you're in a noisy environment). • `prefix_padding_ms`: How many milliseconds of audio to include right before the detected speech. • `silence_duration_ms`: The silence duration (in ms) that marks the end of speech. • `create_response`: A boolean that decides if a response should be created after detecting a turn. • `interrupt_response`: A boolean that lets you interrupt the current response if needed. 2. Semantic VAD • `type`: Set this to
"semantic_vad"
. • `eagerness`: Controls how quickly the system responds (
auto
,
low
,
medium
,
high
). • `create_response`: A boolean to decide if a response should be created after turn detection. • `interrupt_response`: A boolean to allow interrupting the current response. Here's an example of how you can use semantic VAD:
Copy code
TurnDetection(
    type="semantic_vad",
    eagerness="auto",
    create_response=True,
    interrupt_response=True,
)
If you have any questions or want me to walk you through it, just let me know—I’m happy to help! Sources: OpenAI Realtime API integration guide | LiveKit Docs | Adjusting Model Parameters | LiveKit Docs | livekit-plugins/livekit-plugins-turn-detector/README.md | Building the all-in-one platform for voice AI agents
m
i meant in the agent session init. I thought the turn_detection needed to be ‘stt’ or something
t
When you're working with OpenAI's Realtime API for turn detection, it's usually best to leave the
turn_detection
parameter in
AgentSession
unset (or set it to
NOT_GIVEN
). Instead, you can set up turn detection right inside the
RealtimeModel
by using its
turn_detection
parameter. This way, you get to use OpenAI's built-in turn detection logic seamlessly. Here's a quick example:
Copy code
from livekit.plugins.openai import realtime

session = AgentSession(
    llm=realtime.RealtimeModel(
        turn_detection={
            "type": "server_vad",
            "silence_duration_ms": 500,
            "threshold": 0.5,
        }
    )
    # turn_detection NOT set here → defaults to OpenAI's turn detection
)
By leaving
turn_detection
unset in
AgentSession
, the system automatically picks the best mode (like
realtime_llm
) and uses OpenAI's server-side VAD or semantic VAD for endpointing. If you'd like to override OpenAI's turn detection and use a custom model (for example, LiveKit's
MultilingualModel
), here’s what you need to do: • Set
turn_detection=MultilingualModel()
in
AgentSession
. • Make sure to provide an STT plugin (like Deepgram) for transcribed text. • Turn off turn detection in
RealtimeModel
by setting
turn_detection=None
. Feel free to reach out if you'd like me to clarify anything or help out further! Sources: examples/voice_agents/realtime_turn_detector.py | OpenAI Realtime API integration guide | LiveKit Docs | Turn detection and interruptions | LiveKit Docs