Naar hoofdinhoud gaan

Deze browser wordt niet meer ondersteund.

Upgrade naar Microsoft Edge om te profiteren van de nieuwste functies, beveiligingsupdates en technische ondersteuning.

Microsoft Edge downloaden Meer informatie over Internet Explorer en Microsoft Edge
microsoft-foundry.rest.security.o-auth2-auth

Realtime

Create a Realtime session

POST /openai/v1/realtime/sessions

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.

Content-Type: application/json
client_secret OpenAI.RealtimeSessionCreateRequestClientSecret vereist
value string vereist
expires_at integer 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.

Een van de volgende:
Een van de volgende:
string
enum
alloyashballadcoralechosageshimmerversemarincedar
id string vereist
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
model string
speed number
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.

Een van de volgende:
enum
auto
workflow_name string
group_id string
metadata object
turn_detection OpenAI.RealtimeSessionCreateRequestTurnDetection
type string
threshold number
prefix_padding_ms integer
silence_duration_ms integer
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.

temperature number
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.

Een van de volgende:
integer
enum
inf
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.

Een van de volgende:
enum
autodisabled
type enum vereist
retention_ratio
retention_ratio number vereist
token_limits OpenAI.TokenLimits
post_instructions integer
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.

version string | null
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
Een van de volgende:
string
type enum vereist

The type of the input item. Always input_text.

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.

explicit
type enum vereist

The type of the input item. Always input_image.

input_image
image_url string | null
file_id string | null
detail enum vereist
lowhighautooriginal
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.

explicit
type enum vereist

The type of the input item. Always input_file.

input_file
file_id string | null
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.

explicit
file_url string

The URL of the file to be sent to the model.

detail enum
autolowhigh

Antwoorden

The request has succeeded.

Hoofdtekst

Content-Type: application/json
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
Een van de volgende:
audio/pcm OpenAI.RealtimeAudioFormatsAudioPcm
type enum vereist
audio/pcm
rate enum
24000
audio/pcmu OpenAI.RealtimeAudioFormatsAudioPcmu
type enum vereist
audio/pcmu
audio/pcma OpenAI.RealtimeAudioFormatsAudioPcma
type enum vereist
audio/pcma
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.

Een van de volgende:
string
enum
whisper-1gpt-transcribegpt-live-transcribegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15gpt-4o-transcribegpt-4o-transcribe-diarizegpt-realtime-whisper
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.

near_fieldfar_field
turn_detection OpenAI.RealtimeSessionCreateResponseAudioInputTurnDetection | null
type string
threshold number
prefix_padding_ms integer
silence_duration_ms integer
output OpenAI.RealtimeSessionCreateResponseAudioOutput
format audio/pcm | audio/pcmu | audio/pcma
Een van de volgende:
audio/pcm OpenAI.RealtimeAudioFormatsAudioPcm
type enum vereist
audio/pcm
rate enum
24000
audio/pcmu OpenAI.RealtimeAudioFormatsAudioPcmu
type enum vereist
audio/pcmu
audio/pcma OpenAI.RealtimeAudioFormatsAudioPcma
type enum vereist
audio/pcma
voice string | enum
Een van de volgende:
string
enum
alloyashballadcoralechosageshimmerversemarincedar
speed number
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.

Een van de volgende:
enum
auto
workflow_name string
group_id string
metadata object
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.

type string
threshold number
prefix_padding_ms integer
silence_duration_ms integer
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.

Een van de volgende:
integer
enum
inf
type enum vereist
realtime

Client error

Hoofdtekst

Content-Type: application/json
error OpenAI.Error vereist
code string | null vereist
message string vereist
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Een van de volgende:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string vereist

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Hoofdtekst

Content-Type: application/json
error OpenAI.Error vereist
code string | null vereist
message string vereist
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Een van de volgende:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string vereist

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

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
  }
}
nl-nl
Uw privacykeuzes
  • AI-disclaimer
  • Vorige versies
  • Blog
  • Bijdragen
  • Privacy
  • Privacy van gezondheidsdata
  • Gebruiksvoorwaarden
  • Handelsmerken
  • © Microsoft 2026