Overview
OpenAIRealtimeLLMService provides real-time, multimodal conversation capabilities using OpenAI’s Realtime API. It supports speech-to-speech interactions with integrated LLM processing, function calling, and advanced conversation management with minimal latency response times.
OpenAI Realtime API Reference
Pipecat’s API methods for OpenAI Realtime integration
Example Implementation
Complete OpenAI Realtime conversation example
OpenAI Documentation
Official OpenAI Realtime API documentation
OpenAI Platform
Access Realtime models and manage API keys
Installation
To use OpenAI Realtime services, install the required dependencies:Prerequisites
OpenAI Account Setup
Before using OpenAI Realtime services, you need:- OpenAI Account: Sign up at OpenAI Platform
- API Key: Generate an OpenAI API key from your account dashboard
- Model Access: Ensure access to OpenAI Realtime models
- Usage Limits: Configure appropriate usage limits and billing
Required Environment Variables
OPENAI_API_KEY: Your OpenAI API key for authentication
Key Features
- Real-time Speech-to-Speech: Direct audio processing with minimal latency
- Advanced Turn Detection: Multiple voice activity detection options including semantic detection
- Function Calling: Seamless support for external functions and APIs
- Voice Options: Multiple voice personalities and speaking styles
- Conversation Management: Intelligent context handling and conversation flow control
Configuration
OpenAIRealtimeLLMService
str
required
OpenAI API key for authentication.
str
default:"gpt-realtime-2.1"
deprecated
Deprecated since 0.0.105, removed in 2.0.0. Use
settings=OpenAIRealtimeLLMService.Settings(model=...) instead.str
default:"wss://api.openai.com/v1/realtime"
WebSocket base URL for the Realtime API. Override for custom or proxied
deployments.
SessionProperties
default:"None"
deprecated
Deprecated since 0.0.105, removed in 2.0.0. Use
settings=OpenAIRealtimeLLMService.Settings(session_properties=...) instead.bool
default:"False"
Whether to start with audio input paused. Useful when you want to control when
audio processing begins.
bool
default:"False"
Whether to start with video input paused.
Literal["auto", "low", "high"]
default:"auto"
Detail level for video processing. Can be
"auto", "low", or "high".
"auto" lets the model decide, "low" is faster and uses fewer tokens,
"high" provides more detail.float | None
default:"None"
In manual turn-detection mode (
turn_detection=False, locally-driven turns),
how much recent audio to replay after an interruption clears the input audio
buffer, so the speech onset isn’t lost. Defaults to None: auto-sized to the
upstream VAD’s start_secs plus 0.3 seconds, falling back to 0.5 seconds
when no VAD is present. Auto-sizing assumes VAD drives turn starts (the
default VADUserTurnStartStrategy); set this explicitly if you use a non-VAD
turn-start strategy. No effect when server-side turn detection is enabled.Any
Additional arguments passed to parent LLMService.
Settings
Runtime-configurable settings passed via thesettings constructor argument using OpenAIRealtimeLLMService.Settings(...). system_instruction and session_properties can be updated mid-conversation with LLMUpdateSettingsFrame; model is fixed for the session. See Service Settings for details.
None values are omitted, letting the service use its own defaults.LLMSettings fields temperature, max_tokens, top_p, top_k, frequency_penalty, presence_penalty, and seed are not sent by this service, so they have no effect. Use session_properties.max_output_tokens to limit response length.
SessionProperties
AudioConfiguration
Theaudio field in SessionProperties accepts an AudioConfiguration with input and output sub-configurations:
AudioInput (audio.input):
AudioOutput (
audio.output):
TurnDetection
Server-side VAD configuration viaTurnDetection:
Alternatively, use
SemanticTurnDetection for semantic-based detection:
Reasoning
Reasoning configuration for reasoning-capable Realtime models (e.g.gpt-realtime-2):
Reasoning configuration is automatically filtered out when used with
non-reasoning models (e.g.
gpt-realtime-1.5) to prevent session errors. A
warning is logged when this filtering occurs.Usage
Basic Setup
With Session Configuration
With Disabled Turn Detection (Manual Control)
With Reasoning Configuration (gpt-realtime-2)
Updating Settings at Runtime
Methods
set_audio_input_paused()
True) or resumes (False) sending input audio to the model.
set_video_input_paused()
True) or resumes (False) sending video frames to the model.
retrieve_conversation_item()
on_conversation_item_created. Raises an Exception with the API’s message when no item has that ID.
Notes
- Model is connection-level: The
modelparameter is set via the WebSocket URL at connection time and cannot be changed during a session. - Output modalities are single-mode: The API supports either
["text"]or["audio"]output, not both simultaneously. - Turn detection options: Use
TurnDetectionfor traditional VAD,SemanticTurnDetectionfor AI-based turn detection, orFalseto disable server-side detection and manage turns manually. - Manual turn detection pre-roll: When server-side turn detection is disabled (
turn_detection=False), the service maintains a rolling audio buffer that is replayed after interruptions to preserve speech onsets. Configure the buffer duration withuser_audio_preroll_secsor let it auto-size from the upstream VAD’sstart_secs. - Audio sample rates: Output audio frames are always labeled 24 kHz mono PCM, so leave
audio.output.formatunset or usePCMAudioFormat(). Input audio is resampled to 24 kHz before it is sent, so anyaudio_in_sample_rateworks. - G.711 formats: The service passes audio through without converting it, and pipeline audio frames are 16-bit PCM, so use
PCMAudioFormatrather thanPCMUAudioFormatorPCMAAudioFormat; for telephony, the transport’s serializer converts to and from G.711. - Video support: Video frames can be sent to the model for multimodal input, at most one per second; frames in between are dropped. Control the detail level with
video_frame_detailand pause/resume withset_video_input_paused(). - Transcription frames: User speech transcription frames are always emitted upstream when input audio transcription is configured.
- System instruction precedence: The
system_instructionfrom service settings takes precedence over an initial system message in the LLM context. A warning is logged when both are set. - Reasoning support: The
reasoningconfiguration is only supported by reasoning-capable models such asgpt-realtime-2. When used with non-supporting models, the reasoning configuration is automatically filtered out to prevent session errors, and a warning is logged.