Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

GPT Realtime 2.1

Model id: openai/gpt-realtime-2.1. API reference for GPT Realtime 2.1: request schema and code examples.

This documentation is valid for the following list of our models:

  • openai/gpt-realtime-2.1

  • gpt-realtime-2.1

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):

Option
Values

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

Response

The example prints the transcript of the spoken reply (response.output_audio_transcript.delta), then the token usage from response.done, and saves the audio (response.output_audio.delta, base64 PCM16 at 24 kHz) to reply.pcm. Values in angle brackets are placeholders.

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?