curl --request POST \
--url https://api.openai.com/v1/realtime/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"modalities": [
[
"text",
"audio"
]
],
"model": "gpt-4o-realtime-preview",
"instructions": "<string>",
"voice": "ash",
"input_audio_format": "pcm16",
"output_audio_format": "pcm16",
"input_audio_transcription": {
"model": "<string>",
"language": "<string>",
"prompt": "<string>"
},
"turn_detection": {
"type": "server_vad",
"eagerness": "auto",
"threshold": 123,
"prefix_padding_ms": 123,
"silence_duration_ms": 123,
"create_response": true,
"interrupt_response": true
},
"input_audio_noise_reduction": null,
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {}
}
],
"tool_choice": "auto",
"temperature": 0.8,
"max_response_output_tokens": 123
}'
{
"client_secret": {
"value": "<string>",
"expires_at": 123
},
"modalities": [
"text"
],
"instructions": "<string>",
"voice": "ash",
"input_audio_format": "<string>",
"output_audio_format": "<string>",
"input_audio_transcription": {
"model": "<string>"
},
"turn_detection": {
"type": "<string>",
"threshold": 123,
"prefix_padding_ms": 123,
"silence_duration_ms": 123
},
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {}
}
],
"tool_choice": "<string>",
"temperature": 123,
"max_response_output_tokens": 123
}
Create an ephemeral API token for use in client-side applications with the
Realtime API. Can be configured with the same session parameters as the
session.update
client event.
It responds with a session object, plus a client_secret
key which contains
a usable ephemeral API token that can be used to authenticate browser clients
for the Realtime API.
curl --request POST \
--url https://api.openai.com/v1/realtime/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"modalities": [
[
"text",
"audio"
]
],
"model": "gpt-4o-realtime-preview",
"instructions": "<string>",
"voice": "ash",
"input_audio_format": "pcm16",
"output_audio_format": "pcm16",
"input_audio_transcription": {
"model": "<string>",
"language": "<string>",
"prompt": "<string>"
},
"turn_detection": {
"type": "server_vad",
"eagerness": "auto",
"threshold": 123,
"prefix_padding_ms": 123,
"silence_duration_ms": 123,
"create_response": true,
"interrupt_response": true
},
"input_audio_noise_reduction": null,
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {}
}
],
"tool_choice": "auto",
"temperature": 0.8,
"max_response_output_tokens": 123
}'
{
"client_secret": {
"value": "<string>",
"expires_at": 123
},
"modalities": [
"text"
],
"instructions": "<string>",
"voice": "ash",
"input_audio_format": "<string>",
"output_audio_format": "<string>",
"input_audio_transcription": {
"model": "<string>"
},
"turn_detection": {
"type": "<string>",
"threshold": 123,
"prefix_padding_ms": 123,
"silence_duration_ms": 123
},
"tools": [
{
"type": "function",
"name": "<string>",
"description": "<string>",
"parameters": {}
}
],
"tool_choice": "<string>",
"temperature": 123,
"max_response_output_tokens": 123
}
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Create an ephemeral API key with the given session configuration.
Realtime session object configuration.
Session created successfully.
A new Realtime session configuration, with an ephermeral key. Default TTL for keys is one minute.
Was this page helpful?