Principle:Openai Openai python Realtime Session Configuration
| Knowledge Sources | |
|---|---|
| Domains | Realtime_Communication, Configuration |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
A runtime configuration pattern that sets session-level parameters for a Realtime API connection including modalities, voice, instructions, and tool definitions.
Description
Session configuration determines the behavior of a Realtime API connection after it is established. It specifies which modalities are active (text, audio, or both), selects the voice for audio output, provides system-level instructions, configures voice activity detection (VAD) for turn-taking, and registers available tools. Session parameters can be updated at any time during the connection.
Usage
Call session.update() immediately after establishing a connection to configure the desired behavior. Update again mid-session if modalities, voice, or tools need to change dynamically.
Theoretical Basis
Session configuration follows a Mutable State pattern sent as an event:
# Configure session after connection
connection.session.update(session={
"modalities": ["text", "audio"], # Active modalities
"voice": "alloy", # TTS voice
"instructions": "You are helpful.", # System prompt
"turn_detection": {"type": "server_vad"}, # Auto turn detection
"tools": [tool_definitions], # Available tools
"input_audio_format": "pcm16", # Audio input format
"output_audio_format": "pcm16", # Audio output format
})
# Server acknowledges with session.updated event