Realtime
Create a Realtime session
Creates an ephemeral API token and Realtime session for use in client-side applications.
Aanvraagbody
Create an ephemeral API key with the given session configuration.
client_secret
OpenAI.RealtimeSessionCreateRequestClientSecret
vereist
modalities
enum[]
The set of modalities the model can respond with. To disable audio, set this to ["text"].
instructions
string
The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior. Note that the server sets default instructions which will be used if this field is not set and are visible in the session.created event at the start of the session.
voice
OpenAI.VoiceIdsShared | object
A built-in voice name or a custom voice reference.
enum
input_audio_format
string
The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
output_audio_format
string
The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
input_audio_transcription
OpenAI.RealtimeSessionCreateRequestInputAudioTranscription
tracing
enum | object
Configuration options for tracing. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified. auto will create a trace for the session with default values for the workflow name, group id, and metadata.
enum
turn_detection
OpenAI.RealtimeSessionCreateRequestTurnDetection
tools
OpenAI.RealtimeSessionCreateRequestTools[]
Tools (functions) available to the model.
tool_choice
string
How the model chooses tools. Options are auto, none, required, or specify a function.
max_response_output_tokens
OpenAI.integer | enum
Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or inf for the maximum available tokens for a given model. Defaults to inf.
enum
truncation
enum | object
When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs. Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost. Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate. Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.
enum
type
enum
vereist
token_limits
OpenAI.TokenLimits
prompt
OpenAI.Prompt
Reference to a prompt template and its variables. Learn more.
id
string
vereist
The unique identifier of the prompt template to use.
variables
OpenAI.ResponsePromptVariables | null
Optional map of values to substitute in for variables in your prompt. The substitution values can either be strings, or other Response input types like images or files.
[key: string]
string | OpenAI.InputTextContent | OpenAI.InputImageContent | OpenAI.InputFileContent
type
enum
vereist
The type of the input item. Always input_text.
text
string
vereist
The text input to the model.
prompt_cache_breakpoint
OpenAI.PromptCacheBreakpointConfig
Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's prompt_cache_options.ttl; the boundary is not rounded to a token block.
mode
enum
vereist
The breakpoint mode. Always explicit.
type
enum
vereist
The type of the input item. Always input_image.
detail
enum
vereist
prompt_cache_breakpoint
OpenAI.PromptCacheBreakpointConfig
Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's prompt_cache_options.ttl; the boundary is not rounded to a token block.
mode
enum
vereist
The breakpoint mode. Always explicit.
type
enum
vereist
The type of the input item. Always input_file.
filename
string
The name of the file to be sent to the model.
file_data
string
The content of the file to be sent to the model.
prompt_cache_breakpoint
OpenAI.PromptCacheBreakpointConfig
Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's prompt_cache_options.ttl; the boundary is not rounded to a token block.
mode
enum
vereist
The breakpoint mode. Always explicit.
file_url
string
The URL of the file to be sent to the model.
detail
enum
Antwoorden
The request has succeeded.
Hoofdtekst
id
string
Unique identifier for the session that looks like sess_1234567890abcdef.
object
string
The object type. Always realtime.session.
expires_at
integer
Expiration timestamp for the session, in seconds since epoch.
include
enum[]
Additional fields to include in server outputs. - item.input_audio_transcription.logprobs: Include logprobs for input audio transcription.
model
string
The Realtime model used for this session.
output_modalities
enum[]
The set of modalities the model can respond with. To disable audio, set this to ["text"].
instructions
string
The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior. Note that the server sets default instructions which will be used if this field is not set and are visible in the session.created event at the start of the session.
audio
OpenAI.RealtimeSessionCreateResponseAudio
input
OpenAI.RealtimeSessionCreateResponseAudioInput
format
audio/pcm | audio/pcmu | audio/pcma
audio/pcm
OpenAI.RealtimeAudioFormatsAudioPcm
type
enum
vereist
rate
enum
audio/pcmu
OpenAI.RealtimeAudioFormatsAudioPcmu
type
enum
vereist
audio/pcma
OpenAI.RealtimeAudioFormatsAudioPcma
type
enum
vereist
transcription
OpenAI.AudioTranscriptionResponse
model
string | enum
The model used for transcription. Current options are whisper-1, gpt-transcribe, gpt-live-transcribe, gpt-4o-mini-transcribe, gpt-4o-mini-transcribe-2025-12-15, gpt-4o-transcribe, gpt-4o-transcribe-diarize, and gpt-realtime-whisper.
enum
language
string | null
The language of the input audio.
languages
string[]
The possible input audio languages configured for transcription, in ISO-639-1 format.
prompt
string
The prompt configured for input audio transcription, when present.
noise_reduction
OpenAI.RealtimeSessionCreateResponseAudioInputNoiseReduction | null
type
enum
Type of noise reduction. near_field is for close-talking microphones such as headphones, far_field is for far-field microphones such as laptop or conference room microphones.
turn_detection
OpenAI.RealtimeSessionCreateResponseAudioInputTurnDetection | null
output
OpenAI.RealtimeSessionCreateResponseAudioOutput
format
audio/pcm | audio/pcmu | audio/pcma
audio/pcm
OpenAI.RealtimeAudioFormatsAudioPcm
type
enum
vereist
rate
enum
audio/pcmu
OpenAI.RealtimeAudioFormatsAudioPcmu
type
enum
vereist
audio/pcma
OpenAI.RealtimeAudioFormatsAudioPcma
type
enum
vereist
voice
string | enum
enum
tracing
enum | object
Configuration options for tracing. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified. auto will create a trace for the session with default values for the workflow name, group id, and metadata.
enum
turn_detection
OpenAI.RealtimeSessionCreateResponseTurnDetection | null
Configuration for turn detection. Can be set to null to turn off. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.
tools
OpenAI.RealtimeFunctionTool[]
Tools (functions) available to the model.
tool_choice
string
How the model chooses tools. Options are auto, none, required, or specify a function.
max_output_tokens
OpenAI.integer | enum
Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or inf for the maximum available tokens for a given model. Defaults to inf.
enum
type
enum
vereist
Aanvraag
curl -X POST https://api.openai.com/v1/realtime/sessions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-realtime",
"modalities": ["audio", "text"],
"instructions": "You are a friendly assistant."
}'
Respons
{
"id": "sess_001",
"object": "realtime.session",
"model": "gpt-realtime-2025-08-25",
"modalities": ["audio", "text"],
"instructions": "You are a friendly assistant.",
"voice": "alloy",
"input_audio_format": "pcm16",
"output_audio_format": "pcm16",
"input_audio_transcription": {
"model": "whisper-1"
},
"turn_detection": null,
"tools": [],
"tool_choice": "none",
"temperature": 0.7,
"max_response_output_tokens": 200,
"speed": 1.1,
"tracing": "auto",
"client_secret": {
"value": "ek_abc123",
"expires_at": 1234567890
}
}