GPT Realtime 2.1
Model id: openai/gpt-realtime-2.1. API reference for GPT Realtime 2.1: request schema and code examples.
OpenAI's speech-to-speech model for live voice agents: it listens to streamed audio, detects the end of the user's turn, and answers with speech and text in the same session, with function calling. For a cheaper, faster variant see GPT Realtime 2.1 Mini.
Setup your API Key
If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.
API Schema
The model is served over a WebSocket in the OpenAI Realtime protocol. Client events, billing, limits and errors are described in Realtime Sessions.
Connection URL
wss://api.aimlapi.com/v1/realtime?model=openai/gpt-realtime-2.1
Authentication
Server: Authorization: Bearer <YOUR_AIMLAPI_KEY>. Browser: subprotocols realtime and openai-insecure-api-key.<client secret> (client secrets)
SDK base URL
https://api.aimlapi.com/v1
Session options (session.update):
instructions
Up to 16,384 characters
output_modalities
["audio"], ["text"] or both
audio.input.format, audio.output.format
{"type": "audio/pcm", "rate": 24000}, {"type": "audio/pcmu"}, {"type": "audio/pcma"}
audio.input.noise_reduction
{"type": "near_field"}, {"type": "far_field"} or null
audio.input.turn_detection
server_vad (threshold, prefix_padding_ms, silence_duration_ms, create_response, interrupt_response), semantic_vad (eagerness, create_response, interrupt_response), or null for manual turns
audio.output.voice
Built-in voices: alloy, ash, ballad, cedar, coral, echo, marin, sage, shimmer, verse
audio.output.speed
0.25 – 1.5
max_output_tokens
Up to 4,096 (higher values and "inf" are lowered to 4,096)
tools
Up to 32 function tools, each JSON schema up to 64 KiB
tool_choice
auto, none, required, or a named function
Code Example
The official OpenAI SDKs work too: set the base URL to https://api.aimlapi.com/v1 (see the SDK example).
Last updated
Was this helpful?