1## Create client secret
2
3`client.Realtime.ClientSecrets.New(ctx, body) (*ClientSecretNewResponse, error)`
4
5**post** `/realtime/client_secrets`
6
7Create a Realtime client secret with an associated session configuration.
8
9Client secrets are short-lived tokens that can be passed to a client app,
10such as a web frontend or mobile client, which grants access to the Realtime API without
11leaking your main API key. You can configure a custom TTL for each client secret.
12
13You can also attach session configuration options to the client secret, which will be
14applied to any sessions created using that client secret, but these can also be overridden
15by the client connection.
16
17[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).
18
19Returns the created client secret and the effective session object. The client secret is a string that looks like `ek_1234`.
20
21### Parameters
22
23- `body ClientSecretNewParams`
24
25 - `ExpiresAfter param.Field[ClientSecretNewParamsExpiresAfter]`
26
27 Configuration for the client secret expiration. Expiration refers to the time after which
28 a client secret will no longer be valid for creating sessions. The session itself may
29 continue after that time once started. A secret can be used to create multiple sessions
30 until it expires.
31
32 - `Anchor string`
33
34 The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.
35
36 - `const ClientSecretNewParamsExpiresAfterAnchorCreatedAt ClientSecretNewParamsExpiresAfterAnchor = "created_at"`
37
38 - `Seconds int64`
39
40 The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.
41
42 - `Session param.Field[ClientSecretNewParamsSessionUnion]`
43
44 Session configuration to use for the client secret. Choose either a realtime
45 session or a transcription session.
46
47 - `type RealtimeSessionCreateRequest struct{…}`
48
49 Realtime session object configuration.
50
51 - `Type Realtime`
52
53 The type of session to create. Always `realtime` for the Realtime API.
54
55 - `const RealtimeRealtime Realtime = "realtime"`
56
57 - `Audio RealtimeAudioConfig`
58
59 Configuration for input and output audio.
60
61 - `Input RealtimeAudioConfigInput`
62
63 - `Format RealtimeAudioFormatsUnion`
64
65 The format of the input audio.
66
67 - `type RealtimeAudioFormatsAudioPCM struct{…}`
68
69 The PCM audio format. Only a 24kHz sample rate is supported.
70
71 - `Rate int64`
72
73 The sample rate of the audio. Always `24000`.
74
75 - `const RealtimeAudioFormatsAudioPCMRate24000 RealtimeAudioFormatsAudioPCMRate = 24000`
76
77 - `Type string`
78
79 The audio format. Always `audio/pcm`.
80
81 - `const RealtimeAudioFormatsAudioPCMTypeAudioPCM RealtimeAudioFormatsAudioPCMType = "audio/pcm"`
82
83 - `type RealtimeAudioFormatsAudioPCMU struct{…}`
84
85 The G.711 μ-law format.
86
87 - `Type string`
88
89 The audio format. Always `audio/pcmu`.
90
91 - `const RealtimeAudioFormatsAudioPCMUTypeAudioPCMU RealtimeAudioFormatsAudioPCMUType = "audio/pcmu"`
92
93 - `type RealtimeAudioFormatsAudioPCMA struct{…}`
94
95 The G.711 A-law format.
96
97 - `Type string`
98
99 The audio format. Always `audio/pcma`.
100
101 - `const RealtimeAudioFormatsAudioPCMATypeAudioPCMA RealtimeAudioFormatsAudioPCMAType = "audio/pcma"`
102
103 - `NoiseReduction RealtimeAudioConfigInputNoiseReduction`
104
105 Configuration for input audio noise reduction. This can be set to `null` to turn off.
106 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.
107 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.
108
109 - `Type NoiseReductionType`
110
111 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.
112
113 - `const NoiseReductionTypeNearField NoiseReductionType = "near_field"`
114
115 - `const NoiseReductionTypeFarField NoiseReductionType = "far_field"`
116
117 - `Transcription AudioTranscription`
118
119 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.
120
121 - `Delay AudioTranscriptionDelay`
122
123 Controls how long the model waits before emitting transcription text.
124 Higher values can improve transcription accuracy at the cost of latency.
125 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.
126
127 - `const AudioTranscriptionDelayMinimal AudioTranscriptionDelay = "minimal"`
128
129 - `const AudioTranscriptionDelayLow AudioTranscriptionDelay = "low"`
130
131 - `const AudioTranscriptionDelayMedium AudioTranscriptionDelay = "medium"`
132
133 - `const AudioTranscriptionDelayHigh AudioTranscriptionDelay = "high"`
134
135 - `const AudioTranscriptionDelayXhigh AudioTranscriptionDelay = "xhigh"`
136
137 - `Language string`
138
139 The language of the input audio. Supplying the input language in
140 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format
141 will improve accuracy and latency.
142
143 - `Model AudioTranscriptionModel`
144
145 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
146
147 - `string`
148
149 - `type AudioTranscriptionModel string`
150
151 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
152
153 - `const AudioTranscriptionModelWhisper1 AudioTranscriptionModel = "whisper-1"`
154
155 - `const AudioTranscriptionModelGPT4oMiniTranscribe AudioTranscriptionModel = "gpt-4o-mini-transcribe"`
156
157 - `const AudioTranscriptionModelGPT4oMiniTranscribe2025_12_15 AudioTranscriptionModel = "gpt-4o-mini-transcribe-2025-12-15"`
158
159 - `const AudioTranscriptionModelGPT4oTranscribe AudioTranscriptionModel = "gpt-4o-transcribe"`
160
161 - `const AudioTranscriptionModelGPT4oTranscribeDiarize AudioTranscriptionModel = "gpt-4o-transcribe-diarize"`
162
163 - `const AudioTranscriptionModelGPTRealtimeWhisper AudioTranscriptionModel = "gpt-realtime-whisper"`
164
165 - `Prompt string`
166
167 An optional text to guide the model's style or continue a previous audio
168 segment.
169 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
170 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".
171 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.
172
173 - `TurnDetection RealtimeAudioInputTurnDetectionUnion`
174
175 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.
176
177 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.
178
179 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.
180
181 For `gpt-realtime-whisper` transcription sessions, turn detection must be
182 set to `null`; VAD is not supported.
183
184 - `RealtimeAudioInputTurnDetectionServerVad`
185
186 - `Type ServerVad`
187
188 Type of turn detection, `server_vad` to turn on simple Server VAD.
189
190 - `const ServerVadServerVad ServerVad = "server_vad"`
191
192 - `CreateResponse bool`
193
194 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.
195
196 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.
197
198 - `IdleTimeoutMs int64`
199
200 Optional timeout after which a model response will be triggered automatically. This is
201 useful for situations in which a long pause from the user is unexpected, such as a phone
202 call. The model will effectively prompt the user to continue the conversation based
203 on the current context.
204
205 The timeout value will be applied after the last model response's audio has finished playing,
206 i.e. it's set to the `response.done` time plus audio playback duration.
207
208 An `input_audio_buffer.timeout_triggered` event (plus events
209 associated with the Response) will be emitted when the timeout is reached.
210 Idle timeout is currently only supported for `server_vad` mode.
211
212 - `InterruptResponse bool`
213
214 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default
215 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.
216
217 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.
218
219 - `PrefixPaddingMs int64`
220
221 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in
222 milliseconds). Defaults to 300ms.
223
224 - `SilenceDurationMs int64`
225
226 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults
227 to 500ms. With shorter values the model will respond more quickly,
228 but may jump in on short pauses from the user.
229
230 - `Threshold float64`
231
232 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A
233 higher threshold will require louder audio to activate the model, and
234 thus might perform better in noisy environments.
235
236 - `RealtimeAudioInputTurnDetectionSemanticVad`
237
238 - `Type SemanticVad`
239
240 Type of turn detection, `semantic_vad` to turn on Semantic VAD.
241
242 - `const SemanticVadSemanticVad SemanticVad = "semantic_vad"`
243
244 - `CreateResponse bool`
245
246 Whether or not to automatically generate a response when a VAD stop event occurs.
247
248 - `Eagerness string`
249
250 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.
251
252 - `const RealtimeAudioInputTurnDetectionSemanticVadEagernessLow RealtimeAudioInputTurnDetectionSemanticVadEagerness = "low"`
253
254 - `const RealtimeAudioInputTurnDetectionSemanticVadEagernessMedium RealtimeAudioInputTurnDetectionSemanticVadEagerness = "medium"`
255
256 - `const RealtimeAudioInputTurnDetectionSemanticVadEagernessHigh RealtimeAudioInputTurnDetectionSemanticVadEagerness = "high"`
257
258 - `const RealtimeAudioInputTurnDetectionSemanticVadEagernessAuto RealtimeAudioInputTurnDetectionSemanticVadEagerness = "auto"`
259
260 - `InterruptResponse bool`
261
262 Whether or not to automatically interrupt any ongoing response with output to the default
263 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.
264
265 - `Output RealtimeAudioConfigOutput`
266
267 - `Format RealtimeAudioFormatsUnion`
268
269 The format of the output audio.
270
271 - `Speed float64`
272
273 The speed of the model's spoken response as a multiple of the original speed.
274 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.
275
276 This parameter is a post-processing adjustment to the audio after it is generated, it's
277 also possible to prompt the model to speak faster or slower.
278
279 - `Voice RealtimeAudioConfigOutputVoiceUnion`
280
281 The voice the model uses to respond. Supported built-in voices are
282 `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,
283 `marin`, and `cedar`. You may also provide a custom voice object with
284 an `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed
285 during the session once the model has responded with audio at least once.
286 We recommend `marin` and `cedar` for best quality.
287
288 - `string`
289
290 - `string`
291
292 - `const RealtimeAudioConfigOutputVoiceString2Alloy RealtimeAudioConfigOutputVoiceString2 = "alloy"`
293
294 - `const RealtimeAudioConfigOutputVoiceString2Ash RealtimeAudioConfigOutputVoiceString2 = "ash"`
295
296 - `const RealtimeAudioConfigOutputVoiceString2Ballad RealtimeAudioConfigOutputVoiceString2 = "ballad"`
297
298 - `const RealtimeAudioConfigOutputVoiceString2Coral RealtimeAudioConfigOutputVoiceString2 = "coral"`
299
300 - `const RealtimeAudioConfigOutputVoiceString2Echo RealtimeAudioConfigOutputVoiceString2 = "echo"`
301
302 - `const RealtimeAudioConfigOutputVoiceString2Sage RealtimeAudioConfigOutputVoiceString2 = "sage"`
303
304 - `const RealtimeAudioConfigOutputVoiceString2Shimmer RealtimeAudioConfigOutputVoiceString2 = "shimmer"`
305
306 - `const RealtimeAudioConfigOutputVoiceString2Verse RealtimeAudioConfigOutputVoiceString2 = "verse"`
307
308 - `const RealtimeAudioConfigOutputVoiceString2Marin RealtimeAudioConfigOutputVoiceString2 = "marin"`
309
310 - `const RealtimeAudioConfigOutputVoiceString2Cedar RealtimeAudioConfigOutputVoiceString2 = "cedar"`
311
312 - `RealtimeAudioConfigOutputVoiceID`
313
314 - `ID string`
315
316 The custom voice ID, e.g. `voice_1234`.
317
318 - `Include []string`
319
320 Additional fields to include in server outputs.
321
322 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
323
324 - `const RealtimeSessionCreateRequestIncludeItemInputAudioTranscriptionLogprobs RealtimeSessionCreateRequestInclude = "item.input_audio_transcription.logprobs"`
325
326 - `Instructions string`
327
328 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.
329
330 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.
331
332 - `MaxOutputTokens RealtimeSessionCreateRequestMaxOutputTokensUnion`
333
334 Maximum number of output tokens for a single assistant response,
335 inclusive of tool calls. Provide an integer between 1 and 4096 to
336 limit output tokens, or `inf` for the maximum available tokens for a
337 given model. Defaults to `inf`.
338
339 - `int64`
340
341 - `Inf`
342
343 - `const InfInf Inf = "inf"`
344
345 - `Model RealtimeSessionCreateRequestModel`
346
347 The Realtime model used for this session.
348
349 - `string`
350
351 - `RealtimeSessionCreateRequestModel`
352
353 - `const RealtimeSessionCreateRequestModelGPTRealtime RealtimeSessionCreateRequestModel = "gpt-realtime"`
354
355 - `const RealtimeSessionCreateRequestModelGPTRealtime1_5 RealtimeSessionCreateRequestModel = "gpt-realtime-1.5"`
356
357 - `const RealtimeSessionCreateRequestModelGPTRealtime2 RealtimeSessionCreateRequestModel = "gpt-realtime-2"`
358
359 - `const RealtimeSessionCreateRequestModelGPTRealtime2025_08_28 RealtimeSessionCreateRequestModel = "gpt-realtime-2025-08-28"`
360
361 - `const RealtimeSessionCreateRequestModelGPT4oRealtimePreview RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview"`
362
363 - `const RealtimeSessionCreateRequestModelGPT4oRealtimePreview2024_10_01 RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview-2024-10-01"`
364
365 - `const RealtimeSessionCreateRequestModelGPT4oRealtimePreview2024_12_17 RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview-2024-12-17"`
366
367 - `const RealtimeSessionCreateRequestModelGPT4oRealtimePreview2025_06_03 RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview-2025-06-03"`
368
369 - `const RealtimeSessionCreateRequestModelGPT4oMiniRealtimePreview RealtimeSessionCreateRequestModel = "gpt-4o-mini-realtime-preview"`
370
371 - `const RealtimeSessionCreateRequestModelGPT4oMiniRealtimePreview2024_12_17 RealtimeSessionCreateRequestModel = "gpt-4o-mini-realtime-preview-2024-12-17"`
372
373 - `const RealtimeSessionCreateRequestModelGPTRealtimeMini RealtimeSessionCreateRequestModel = "gpt-realtime-mini"`
374
375 - `const RealtimeSessionCreateRequestModelGPTRealtimeMini2025_10_06 RealtimeSessionCreateRequestModel = "gpt-realtime-mini-2025-10-06"`
376
377 - `const RealtimeSessionCreateRequestModelGPTRealtimeMini2025_12_15 RealtimeSessionCreateRequestModel = "gpt-realtime-mini-2025-12-15"`
378
379 - `const RealtimeSessionCreateRequestModelGPTAudio1_5 RealtimeSessionCreateRequestModel = "gpt-audio-1.5"`
380
381 - `const RealtimeSessionCreateRequestModelGPTAudioMini RealtimeSessionCreateRequestModel = "gpt-audio-mini"`
382
383 - `const RealtimeSessionCreateRequestModelGPTAudioMini2025_10_06 RealtimeSessionCreateRequestModel = "gpt-audio-mini-2025-10-06"`
384
385 - `const RealtimeSessionCreateRequestModelGPTAudioMini2025_12_15 RealtimeSessionCreateRequestModel = "gpt-audio-mini-2025-12-15"`
386
387 - `OutputModalities []string`
388
389 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating
390 that the model will respond with audio plus a transcript. `["text"]` can be used to make
391 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.
392
393 - `const RealtimeSessionCreateRequestOutputModalityText RealtimeSessionCreateRequestOutputModality = "text"`
394
395 - `const RealtimeSessionCreateRequestOutputModalityAudio RealtimeSessionCreateRequestOutputModality = "audio"`
396
397 - `ParallelToolCalls bool`
398
399 Whether the model may call multiple tools in parallel. Only supported by
400 reasoning Realtime models such as `gpt-realtime-2`.
401
402 - `Prompt ResponsePrompt`
403
404 Reference to a prompt template and its variables.
405 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
406
407 - `ID string`
408
409 The unique identifier of the prompt template to use.
410
411 - `Variables map[string, ResponsePromptVariableUnion]`
412
413 Optional map of values to substitute in for variables in your
414 prompt. The substitution values can either be strings, or other
415 Response input types like images or files.
416
417 - `string`
418
419 - `type ResponseInputText struct{…}`
420
421 A text input to the model.
422
423 - `Text string`
424
425 The text input to the model.
426
427 - `Type InputText`
428
429 The type of the input item. Always `input_text`.
430
431 - `const InputTextInputText InputText = "input_text"`
432
433 - `type ResponseInputImage struct{…}`
434
435 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
436
437 - `Detail ResponseInputImageDetail`
438
439 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
440
441 - `const ResponseInputImageDetailLow ResponseInputImageDetail = "low"`
442
443 - `const ResponseInputImageDetailHigh ResponseInputImageDetail = "high"`
444
445 - `const ResponseInputImageDetailAuto ResponseInputImageDetail = "auto"`
446
447 - `const ResponseInputImageDetailOriginal ResponseInputImageDetail = "original"`
448
449 - `Type InputImage`
450
451 The type of the input item. Always `input_image`.
452
453 - `const InputImageInputImage InputImage = "input_image"`
454
455 - `FileID string`
456
457 The ID of the file to be sent to the model.
458
459 - `ImageURL string`
460
461 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.
462
463 - `type ResponseInputFile struct{…}`
464
465 A file input to the model.
466
467 - `Type InputFile`
468
469 The type of the input item. Always `input_file`.
470
471 - `const InputFileInputFile InputFile = "input_file"`
472
473 - `Detail ResponseInputFileDetail`
474
475 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.
476
477 - `const ResponseInputFileDetailLow ResponseInputFileDetail = "low"`
478
479 - `const ResponseInputFileDetailHigh ResponseInputFileDetail = "high"`
480
481 - `FileData string`
482
483 The content of the file to be sent to the model.
484
485 - `FileID string`
486
487 The ID of the file to be sent to the model.
488
489 - `FileURL string`
490
491 The URL of the file to be sent to the model.
492
493 - `Filename string`
494
495 The name of the file to be sent to the model.
496
497 - `Version string`
498
499 Optional version of the prompt template.
500
501 - `Reasoning RealtimeReasoning`
502
503 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
504
505 - `Effort RealtimeReasoningEffort`
506
507 Constrains effort on reasoning for reasoning-capable Realtime models such as
508 `gpt-realtime-2`.
509
510 - `const RealtimeReasoningEffortMinimal RealtimeReasoningEffort = "minimal"`
511
512 - `const RealtimeReasoningEffortLow RealtimeReasoningEffort = "low"`
513
514 - `const RealtimeReasoningEffortMedium RealtimeReasoningEffort = "medium"`
515
516 - `const RealtimeReasoningEffortHigh RealtimeReasoningEffort = "high"`
517
518 - `const RealtimeReasoningEffortXhigh RealtimeReasoningEffort = "xhigh"`
519
520 - `ToolChoice RealtimeToolChoiceConfigUnion`
521
522 How the model chooses tools. Provide one of the string modes or force a specific
523 function/MCP tool.
524
525 - `type ToolChoiceOptions string`
526
527 Controls which (if any) tool is called by the model.
528
529 `none` means the model will not call any tool and instead generates a message.
530
531 `auto` means the model can pick between generating a message or calling one or
532 more tools.
533
534 `required` means the model must call one or more tools.
535
536 - `const ToolChoiceOptionsNone ToolChoiceOptions = "none"`
537
538 - `const ToolChoiceOptionsAuto ToolChoiceOptions = "auto"`
539
540 - `const ToolChoiceOptionsRequired ToolChoiceOptions = "required"`
541
542 - `type ToolChoiceFunction struct{…}`
543
544 Use this option to force the model to call a specific function.
545
546 - `Name string`
547
548 The name of the function to call.
549
550 - `Type Function`
551
552 For function calling, the type is always `function`.
553
554 - `const FunctionFunction Function = "function"`
555
556 - `type ToolChoiceMcp struct{…}`
557
558 Use this option to force the model to call a specific tool on a remote MCP server.
559
560 - `ServerLabel string`
561
562 The label of the MCP server to use.
563
564 - `Type Mcp`
565
566 For MCP tools, the type is always `mcp`.
567
568 - `const McpMcp Mcp = "mcp"`
569
570 - `Name string`
571
572 The name of the tool to call on the server.
573
574 - `Tools RealtimeToolsConfig`
575
576 Tools available to the model.
577
578 - `type RealtimeFunctionTool struct{…}`
579
580 - `Description string`
581
582 The description of the function, including guidance on when and how
583 to call it, and guidance about what to tell the user when calling
584 (if anything).
585
586 - `Name string`
587
588 The name of the function.
589
590 - `Parameters any`
591
592 Parameters of the function in JSON Schema.
593
594 - `Type RealtimeFunctionToolType`
595
596 The type of the tool, i.e. `function`.
597
598 - `const RealtimeFunctionToolTypeFunction RealtimeFunctionToolType = "function"`
599
600 - `RealtimeToolsConfigUnionMcp`
601
602 - `ServerLabel string`
603
604 A label for this MCP server, used to identify it in tool calls.
605
606 - `Type Mcp`
607
608 The type of the MCP tool. Always `mcp`.
609
610 - `const McpMcp Mcp = "mcp"`
611
612 - `AllowedTools RealtimeToolsConfigUnionMcpAllowedTools`
613
614 List of allowed tool names or a filter object.
615
616 - `[]string`
617
618 - `RealtimeToolsConfigUnionMcpAllowedToolsMcpToolFilter`
619
620 - `ReadOnly bool`
621
622 Indicates whether or not a tool modifies data or is read-only. If an
623 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
624 it will match this filter.
625
626 - `ToolNames []string`
627
628 List of allowed tool names.
629
630 - `Authorization string`
631
632 An OAuth access token that can be used with a remote MCP server, either
633 with a custom MCP server URL or a service connector. Your application
634 must handle the OAuth authorization flow and provide the token here.
635
636 - `ConnectorID string`
637
638 Identifier for service connectors, like those available in ChatGPT. One of
639 `server_url` or `connector_id` must be provided. Learn more about service
640 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
641
642 Currently supported `connector_id` values are:
643
644 - Dropbox: `connector_dropbox`
645 - Gmail: `connector_gmail`
646 - Google Calendar: `connector_googlecalendar`
647 - Google Drive: `connector_googledrive`
648 - Microsoft Teams: `connector_microsoftteams`
649 - Outlook Calendar: `connector_outlookcalendar`
650 - Outlook Email: `connector_outlookemail`
651 - SharePoint: `connector_sharepoint`
652
653 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorDropbox RealtimeToolsConfigUnionMcpConnectorID = "connector_dropbox"`
654
655 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorGmail RealtimeToolsConfigUnionMcpConnectorID = "connector_gmail"`
656
657 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorGooglecalendar RealtimeToolsConfigUnionMcpConnectorID = "connector_googlecalendar"`
658
659 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorGoogledrive RealtimeToolsConfigUnionMcpConnectorID = "connector_googledrive"`
660
661 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorMicrosoftteams RealtimeToolsConfigUnionMcpConnectorID = "connector_microsoftteams"`
662
663 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorOutlookcalendar RealtimeToolsConfigUnionMcpConnectorID = "connector_outlookcalendar"`
664
665 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorOutlookemail RealtimeToolsConfigUnionMcpConnectorID = "connector_outlookemail"`
666
667 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorSharepoint RealtimeToolsConfigUnionMcpConnectorID = "connector_sharepoint"`
668
669 - `DeferLoading bool`
670
671 Whether this MCP tool is deferred and discovered via tool search.
672
673 - `Headers map[string, string]`
674
675 Optional HTTP headers to send to the MCP server. Use for authentication
676 or other purposes.
677
678 - `RequireApproval RealtimeToolsConfigUnionMcpRequireApproval`
679
680 Specify which of the MCP server's tools require approval.
681
682 - `RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalFilter`
683
684 - `Always RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalFilterAlways`
685
686 A filter object to specify which tools are allowed.
687
688 - `ReadOnly bool`
689
690 Indicates whether or not a tool modifies data or is read-only. If an
691 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
692 it will match this filter.
693
694 - `ToolNames []string`
695
696 List of allowed tool names.
697
698 - `Never RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalFilterNever`
699
700 A filter object to specify which tools are allowed.
701
702 - `ReadOnly bool`
703
704 Indicates whether or not a tool modifies data or is read-only. If an
705 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
706 it will match this filter.
707
708 - `ToolNames []string`
709
710 List of allowed tool names.
711
712 - `string`
713
714 - `const RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalSettingAlways RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalSetting = "always"`
715
716 - `const RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalSettingNever RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalSetting = "never"`
717
718 - `ServerDescription string`
719
720 Optional description of the MCP server, used to provide more context.
721
722 - `ServerURL string`
723
724 The URL for the MCP server. One of `server_url` or `connector_id` must be
725 provided.
726
727 - `Tracing RealtimeTracingConfigUnion`
728
729 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once
730 tracing is enabled for a session, the configuration cannot be modified.
731
732 `auto` will create a trace for the session with default values for the
733 workflow name, group id, and metadata.
734
735 - `Auto`
736
737 - `const AutoAuto Auto = "auto"`
738
739 - `RealtimeTracingConfigTracingConfiguration`
740
741 - `GroupID string`
742
743 The group id to attach to this trace to enable filtering and
744 grouping in the Traces Dashboard.
745
746 - `Metadata any`
747
748 The arbitrary metadata to attach to this trace to enable
749 filtering in the Traces Dashboard.
750
751 - `WorkflowName string`
752
753 The name of the workflow to attach to this trace. This is used to
754 name the trace in the Traces Dashboard.
755
756 - `Truncation RealtimeTruncationUnion`
757
758 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.
759
760 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.
761
762 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.
763
764 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.
765
766 - `type RealtimeTruncationRealtimeTruncationStrategy string`
767
768 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.
769
770 - `const RealtimeTruncationRealtimeTruncationStrategyAuto RealtimeTruncationRealtimeTruncationStrategy = "auto"`
771
772 - `const RealtimeTruncationRealtimeTruncationStrategyDisabled RealtimeTruncationRealtimeTruncationStrategy = "disabled"`
773
774 - `type RealtimeTruncationRetentionRatio struct{…}`
775
776 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.
777
778 - `RetentionRatio float64`
779
780 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.
781
782 - `Type RetentionRatio`
783
784 Use retention ratio truncation.
785
786 - `const RetentionRatioRetentionRatio RetentionRatio = "retention_ratio"`
787
788 - `TokenLimits RealtimeTruncationRetentionRatioTokenLimits`
789
790 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.
791
792 - `PostInstructions int64`
793
794 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.
795
796 - `type RealtimeTranscriptionSessionCreateRequest struct{…}`
797
798 Realtime transcription session object configuration.
799
800 - `Type Transcription`
801
802 The type of session to create. Always `transcription` for transcription sessions.
803
804 - `const TranscriptionTranscription Transcription = "transcription"`
805
806 - `Audio RealtimeTranscriptionSessionAudio`
807
808 Configuration for input and output audio.
809
810 - `Input RealtimeTranscriptionSessionAudioInput`
811
812 - `Format RealtimeAudioFormatsUnion`
813
814 The PCM audio format. Only a 24kHz sample rate is supported.
815
816 - `NoiseReduction RealtimeTranscriptionSessionAudioInputNoiseReduction`
817
818 Configuration for input audio noise reduction. This can be set to `null` to turn off.
819 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.
820 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.
821
822 - `Type NoiseReductionType`
823
824 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.
825
826 - `Transcription AudioTranscription`
827
828 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.
829
830 - `TurnDetection RealtimeTranscriptionSessionAudioInputTurnDetectionUnion`
831
832 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.
833
834 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.
835
836 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.
837
838 For `gpt-realtime-whisper` transcription sessions, turn detection must be
839 set to `null`; VAD is not supported.
840
841 - `RealtimeTranscriptionSessionAudioInputTurnDetectionServerVad`
842
843 - `Type ServerVad`
844
845 Type of turn detection, `server_vad` to turn on simple Server VAD.
846
847 - `const ServerVadServerVad ServerVad = "server_vad"`
848
849 - `CreateResponse bool`
850
851 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.
852
853 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.
854
855 - `IdleTimeoutMs int64`
856
857 Optional timeout after which a model response will be triggered automatically. This is
858 useful for situations in which a long pause from the user is unexpected, such as a phone
859 call. The model will effectively prompt the user to continue the conversation based
860 on the current context.
861
862 The timeout value will be applied after the last model response's audio has finished playing,
863 i.e. it's set to the `response.done` time plus audio playback duration.
864
865 An `input_audio_buffer.timeout_triggered` event (plus events
866 associated with the Response) will be emitted when the timeout is reached.
867 Idle timeout is currently only supported for `server_vad` mode.
868
869 - `InterruptResponse bool`
870
871 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default
872 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.
873
874 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.
875
876 - `PrefixPaddingMs int64`
877
878 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in
879 milliseconds). Defaults to 300ms.
880
881 - `SilenceDurationMs int64`
882
883 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults
884 to 500ms. With shorter values the model will respond more quickly,
885 but may jump in on short pauses from the user.
886
887 - `Threshold float64`
888
889 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A
890 higher threshold will require louder audio to activate the model, and
891 thus might perform better in noisy environments.
892
893 - `RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVad`
894
895 - `Type SemanticVad`
896
897 Type of turn detection, `semantic_vad` to turn on Semantic VAD.
898
899 - `const SemanticVadSemanticVad SemanticVad = "semantic_vad"`
900
901 - `CreateResponse bool`
902
903 Whether or not to automatically generate a response when a VAD stop event occurs.
904
905 - `Eagerness string`
906
907 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.
908
909 - `const RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagernessLow RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness = "low"`
910
911 - `const RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagernessMedium RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness = "medium"`
912
913 - `const RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagernessHigh RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness = "high"`
914
915 - `const RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagernessAuto RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness = "auto"`
916
917 - `InterruptResponse bool`
918
919 Whether or not to automatically interrupt any ongoing response with output to the default
920 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.
921
922 - `Include []string`
923
924 Additional fields to include in server outputs.
925
926 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
927
928 - `const RealtimeTranscriptionSessionCreateRequestIncludeItemInputAudioTranscriptionLogprobs RealtimeTranscriptionSessionCreateRequestInclude = "item.input_audio_transcription.logprobs"`
929
930### Returns
931
932- `type ClientSecretNewResponse struct{…}`
933
934 Response from creating a session and client secret for the Realtime API.
935
936 - `ExpiresAt int64`
937
938 Expiration timestamp for the client secret, in seconds since epoch.
939
940 - `Session ClientSecretNewResponseSessionUnion`
941
942 The session configuration for either a realtime or transcription session.
943
944 - `type RealtimeSessionCreateResponse struct{…}`
945
946 A Realtime session configuration object.
947
948 - `ID string`
949
950 Unique identifier for the session that looks like `sess_1234567890abcdef`.
951
952 - `Object RealtimeSession`
953
954 The object type. Always `realtime.session`.
955
956 - `const RealtimeSessionRealtimeSession RealtimeSession = "realtime.session"`
957
958 - `Type Realtime`
959
960 The type of session to create. Always `realtime` for the Realtime API.
961
962 - `const RealtimeRealtime Realtime = "realtime"`
963
964 - `Audio RealtimeSessionCreateResponseAudio`
965
966 Configuration for input and output audio.
967
968 - `Input RealtimeSessionCreateResponseAudioInput`
969
970 - `Format RealtimeAudioFormatsUnion`
971
972 The format of the input audio.
973
974 - `type RealtimeAudioFormatsAudioPCM struct{…}`
975
976 The PCM audio format. Only a 24kHz sample rate is supported.
977
978 - `Rate int64`
979
980 The sample rate of the audio. Always `24000`.
981
982 - `const RealtimeAudioFormatsAudioPCMRate24000 RealtimeAudioFormatsAudioPCMRate = 24000`
983
984 - `Type string`
985
986 The audio format. Always `audio/pcm`.
987
988 - `const RealtimeAudioFormatsAudioPCMTypeAudioPCM RealtimeAudioFormatsAudioPCMType = "audio/pcm"`
989
990 - `type RealtimeAudioFormatsAudioPCMU struct{…}`
991
992 The G.711 μ-law format.
993
994 - `Type string`
995
996 The audio format. Always `audio/pcmu`.
997
998 - `const RealtimeAudioFormatsAudioPCMUTypeAudioPCMU RealtimeAudioFormatsAudioPCMUType = "audio/pcmu"`
999
1000 - `type RealtimeAudioFormatsAudioPCMA struct{…}`
1001
1002 The G.711 A-law format.
1003
1004 - `Type string`
1005
1006 The audio format. Always `audio/pcma`.
1007
1008 - `const RealtimeAudioFormatsAudioPCMATypeAudioPCMA RealtimeAudioFormatsAudioPCMAType = "audio/pcma"`
1009
1010 - `NoiseReduction RealtimeSessionCreateResponseAudioInputNoiseReduction`
1011
1012 Configuration for input audio noise reduction. This can be set to `null` to turn off.
1013 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.
1014 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.
1015
1016 - `Type NoiseReductionType`
1017
1018 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.
1019
1020 - `const NoiseReductionTypeNearField NoiseReductionType = "near_field"`
1021
1022 - `const NoiseReductionTypeFarField NoiseReductionType = "far_field"`
1023
1024 - `Transcription AudioTranscription`
1025
1026 - `Delay AudioTranscriptionDelay`
1027
1028 Controls how long the model waits before emitting transcription text.
1029 Higher values can improve transcription accuracy at the cost of latency.
1030 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.
1031
1032 - `const AudioTranscriptionDelayMinimal AudioTranscriptionDelay = "minimal"`
1033
1034 - `const AudioTranscriptionDelayLow AudioTranscriptionDelay = "low"`
1035
1036 - `const AudioTranscriptionDelayMedium AudioTranscriptionDelay = "medium"`
1037
1038 - `const AudioTranscriptionDelayHigh AudioTranscriptionDelay = "high"`
1039
1040 - `const AudioTranscriptionDelayXhigh AudioTranscriptionDelay = "xhigh"`
1041
1042 - `Language string`
1043
1044 The language of the input audio. Supplying the input language in
1045 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format
1046 will improve accuracy and latency.
1047
1048 - `Model AudioTranscriptionModel`
1049
1050 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
1051
1052 - `string`
1053
1054 - `type AudioTranscriptionModel string`
1055
1056 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
1057
1058 - `const AudioTranscriptionModelWhisper1 AudioTranscriptionModel = "whisper-1"`
1059
1060 - `const AudioTranscriptionModelGPT4oMiniTranscribe AudioTranscriptionModel = "gpt-4o-mini-transcribe"`
1061
1062 - `const AudioTranscriptionModelGPT4oMiniTranscribe2025_12_15 AudioTranscriptionModel = "gpt-4o-mini-transcribe-2025-12-15"`
1063
1064 - `const AudioTranscriptionModelGPT4oTranscribe AudioTranscriptionModel = "gpt-4o-transcribe"`
1065
1066 - `const AudioTranscriptionModelGPT4oTranscribeDiarize AudioTranscriptionModel = "gpt-4o-transcribe-diarize"`
1067
1068 - `const AudioTranscriptionModelGPTRealtimeWhisper AudioTranscriptionModel = "gpt-realtime-whisper"`
1069
1070 - `Prompt string`
1071
1072 An optional text to guide the model's style or continue a previous audio
1073 segment.
1074 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
1075 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".
1076 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.
1077
1078 - `TurnDetection RealtimeSessionCreateResponseAudioInputTurnDetectionUnion`
1079
1080 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.
1081
1082 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.
1083
1084 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.
1085
1086 For `gpt-realtime-whisper` transcription sessions, turn detection must be
1087 set to `null`; VAD is not supported.
1088
1089 - `type RealtimeSessionCreateResponseAudioInputTurnDetectionServerVad struct{…}`
1090
1091 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.
1092
1093 - `Type ServerVad`
1094
1095 Type of turn detection, `server_vad` to turn on simple Server VAD.
1096
1097 - `const ServerVadServerVad ServerVad = "server_vad"`
1098
1099 - `CreateResponse bool`
1100
1101 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.
1102
1103 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.
1104
1105 - `IdleTimeoutMs int64`
1106
1107 Optional timeout after which a model response will be triggered automatically. This is
1108 useful for situations in which a long pause from the user is unexpected, such as a phone
1109 call. The model will effectively prompt the user to continue the conversation based
1110 on the current context.
1111
1112 The timeout value will be applied after the last model response's audio has finished playing,
1113 i.e. it's set to the `response.done` time plus audio playback duration.
1114
1115 An `input_audio_buffer.timeout_triggered` event (plus events
1116 associated with the Response) will be emitted when the timeout is reached.
1117 Idle timeout is currently only supported for `server_vad` mode.
1118
1119 - `InterruptResponse bool`
1120
1121 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default
1122 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.
1123
1124 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.
1125
1126 - `PrefixPaddingMs int64`
1127
1128 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in
1129 milliseconds). Defaults to 300ms.
1130
1131 - `SilenceDurationMs int64`
1132
1133 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults
1134 to 500ms. With shorter values the model will respond more quickly,
1135 but may jump in on short pauses from the user.
1136
1137 - `Threshold float64`
1138
1139 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A
1140 higher threshold will require louder audio to activate the model, and
1141 thus might perform better in noisy environments.
1142
1143 - `type RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVad struct{…}`
1144
1145 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.
1146
1147 - `Type SemanticVad`
1148
1149 Type of turn detection, `semantic_vad` to turn on Semantic VAD.
1150
1151 - `const SemanticVadSemanticVad SemanticVad = "semantic_vad"`
1152
1153 - `CreateResponse bool`
1154
1155 Whether or not to automatically generate a response when a VAD stop event occurs.
1156
1157 - `Eagerness string`
1158
1159 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.
1160
1161 - `const RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagernessLow RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness = "low"`
1162
1163 - `const RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagernessMedium RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness = "medium"`
1164
1165 - `const RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagernessHigh RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness = "high"`
1166
1167 - `const RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagernessAuto RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness = "auto"`
1168
1169 - `InterruptResponse bool`
1170
1171 Whether or not to automatically interrupt any ongoing response with output to the default
1172 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.
1173
1174 - `Output RealtimeSessionCreateResponseAudioOutput`
1175
1176 - `Format RealtimeAudioFormatsUnion`
1177
1178 The format of the output audio.
1179
1180 - `Speed float64`
1181
1182 The speed of the model's spoken response as a multiple of the original speed.
1183 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.
1184
1185 This parameter is a post-processing adjustment to the audio after it is generated, it's
1186 also possible to prompt the model to speak faster or slower.
1187
1188 - `Voice string`
1189
1190 The voice the model uses to respond. Voice cannot be changed during the
1191 session once the model has responded with audio at least once. Current
1192 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,
1193 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for
1194 best quality.
1195
1196 - `string`
1197
1198 - `string`
1199
1200 - `const RealtimeSessionCreateResponseAudioOutputVoiceAlloy RealtimeSessionCreateResponseAudioOutputVoice = "alloy"`
1201
1202 - `const RealtimeSessionCreateResponseAudioOutputVoiceAsh RealtimeSessionCreateResponseAudioOutputVoice = "ash"`
1203
1204 - `const RealtimeSessionCreateResponseAudioOutputVoiceBallad RealtimeSessionCreateResponseAudioOutputVoice = "ballad"`
1205
1206 - `const RealtimeSessionCreateResponseAudioOutputVoiceCoral RealtimeSessionCreateResponseAudioOutputVoice = "coral"`
1207
1208 - `const RealtimeSessionCreateResponseAudioOutputVoiceEcho RealtimeSessionCreateResponseAudioOutputVoice = "echo"`
1209
1210 - `const RealtimeSessionCreateResponseAudioOutputVoiceSage RealtimeSessionCreateResponseAudioOutputVoice = "sage"`
1211
1212 - `const RealtimeSessionCreateResponseAudioOutputVoiceShimmer RealtimeSessionCreateResponseAudioOutputVoice = "shimmer"`
1213
1214 - `const RealtimeSessionCreateResponseAudioOutputVoiceVerse RealtimeSessionCreateResponseAudioOutputVoice = "verse"`
1215
1216 - `const RealtimeSessionCreateResponseAudioOutputVoiceMarin RealtimeSessionCreateResponseAudioOutputVoice = "marin"`
1217
1218 - `const RealtimeSessionCreateResponseAudioOutputVoiceCedar RealtimeSessionCreateResponseAudioOutputVoice = "cedar"`
1219
1220 - `ExpiresAt int64`
1221
1222 Expiration timestamp for the session, in seconds since epoch.
1223
1224 - `Include []string`
1225
1226 Additional fields to include in server outputs.
1227
1228 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
1229
1230 - `const RealtimeSessionCreateResponseIncludeItemInputAudioTranscriptionLogprobs RealtimeSessionCreateResponseInclude = "item.input_audio_transcription.logprobs"`
1231
1232 - `Instructions string`
1233
1234 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.
1235
1236 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.
1237
1238 - `MaxOutputTokens RealtimeSessionCreateResponseMaxOutputTokensUnion`
1239
1240 Maximum number of output tokens for a single assistant response,
1241 inclusive of tool calls. Provide an integer between 1 and 4096 to
1242 limit output tokens, or `inf` for the maximum available tokens for a
1243 given model. Defaults to `inf`.
1244
1245 - `int64`
1246
1247 - `type Inf string`
1248
1249 - `const InfInf Inf = "inf"`
1250
1251 - `Model RealtimeSessionCreateResponseModel`
1252
1253 The Realtime model used for this session.
1254
1255 - `string`
1256
1257 - `type RealtimeSessionCreateResponseModel string`
1258
1259 The Realtime model used for this session.
1260
1261 - `const RealtimeSessionCreateResponseModelGPTRealtime RealtimeSessionCreateResponseModel = "gpt-realtime"`
1262
1263 - `const RealtimeSessionCreateResponseModelGPTRealtime1_5 RealtimeSessionCreateResponseModel = "gpt-realtime-1.5"`
1264
1265 - `const RealtimeSessionCreateResponseModelGPTRealtime2 RealtimeSessionCreateResponseModel = "gpt-realtime-2"`
1266
1267 - `const RealtimeSessionCreateResponseModelGPTRealtime2025_08_28 RealtimeSessionCreateResponseModel = "gpt-realtime-2025-08-28"`
1268
1269 - `const RealtimeSessionCreateResponseModelGPT4oRealtimePreview RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview"`
1270
1271 - `const RealtimeSessionCreateResponseModelGPT4oRealtimePreview2024_10_01 RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview-2024-10-01"`
1272
1273 - `const RealtimeSessionCreateResponseModelGPT4oRealtimePreview2024_12_17 RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview-2024-12-17"`
1274
1275 - `const RealtimeSessionCreateResponseModelGPT4oRealtimePreview2025_06_03 RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview-2025-06-03"`
1276
1277 - `const RealtimeSessionCreateResponseModelGPT4oMiniRealtimePreview RealtimeSessionCreateResponseModel = "gpt-4o-mini-realtime-preview"`
1278
1279 - `const RealtimeSessionCreateResponseModelGPT4oMiniRealtimePreview2024_12_17 RealtimeSessionCreateResponseModel = "gpt-4o-mini-realtime-preview-2024-12-17"`
1280
1281 - `const RealtimeSessionCreateResponseModelGPTRealtimeMini RealtimeSessionCreateResponseModel = "gpt-realtime-mini"`
1282
1283 - `const RealtimeSessionCreateResponseModelGPTRealtimeMini2025_10_06 RealtimeSessionCreateResponseModel = "gpt-realtime-mini-2025-10-06"`
1284
1285 - `const RealtimeSessionCreateResponseModelGPTRealtimeMini2025_12_15 RealtimeSessionCreateResponseModel = "gpt-realtime-mini-2025-12-15"`
1286
1287 - `const RealtimeSessionCreateResponseModelGPTAudio1_5 RealtimeSessionCreateResponseModel = "gpt-audio-1.5"`
1288
1289 - `const RealtimeSessionCreateResponseModelGPTAudioMini RealtimeSessionCreateResponseModel = "gpt-audio-mini"`
1290
1291 - `const RealtimeSessionCreateResponseModelGPTAudioMini2025_10_06 RealtimeSessionCreateResponseModel = "gpt-audio-mini-2025-10-06"`
1292
1293 - `const RealtimeSessionCreateResponseModelGPTAudioMini2025_12_15 RealtimeSessionCreateResponseModel = "gpt-audio-mini-2025-12-15"`
1294
1295 - `OutputModalities []string`
1296
1297 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating
1298 that the model will respond with audio plus a transcript. `["text"]` can be used to make
1299 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.
1300
1301 - `const RealtimeSessionCreateResponseOutputModalityText RealtimeSessionCreateResponseOutputModality = "text"`
1302
1303 - `const RealtimeSessionCreateResponseOutputModalityAudio RealtimeSessionCreateResponseOutputModality = "audio"`
1304
1305 - `Prompt ResponsePrompt`
1306
1307 Reference to a prompt template and its variables.
1308 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
1309
1310 - `ID string`
1311
1312 The unique identifier of the prompt template to use.
1313
1314 - `Variables map[string, ResponsePromptVariableUnion]`
1315
1316 Optional map of values to substitute in for variables in your
1317 prompt. The substitution values can either be strings, or other
1318 Response input types like images or files.
1319
1320 - `string`
1321
1322 - `type ResponseInputText struct{…}`
1323
1324 A text input to the model.
1325
1326 - `Text string`
1327
1328 The text input to the model.
1329
1330 - `Type InputText`
1331
1332 The type of the input item. Always `input_text`.
1333
1334 - `const InputTextInputText InputText = "input_text"`
1335
1336 - `type ResponseInputImage struct{…}`
1337
1338 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
1339
1340 - `Detail ResponseInputImageDetail`
1341
1342 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
1343
1344 - `const ResponseInputImageDetailLow ResponseInputImageDetail = "low"`
1345
1346 - `const ResponseInputImageDetailHigh ResponseInputImageDetail = "high"`
1347
1348 - `const ResponseInputImageDetailAuto ResponseInputImageDetail = "auto"`
1349
1350 - `const ResponseInputImageDetailOriginal ResponseInputImageDetail = "original"`
1351
1352 - `Type InputImage`
1353
1354 The type of the input item. Always `input_image`.
1355
1356 - `const InputImageInputImage InputImage = "input_image"`
1357
1358 - `FileID string`
1359
1360 The ID of the file to be sent to the model.
1361
1362 - `ImageURL string`
1363
1364 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.
1365
1366 - `type ResponseInputFile struct{…}`
1367
1368 A file input to the model.
1369
1370 - `Type InputFile`
1371
1372 The type of the input item. Always `input_file`.
1373
1374 - `const InputFileInputFile InputFile = "input_file"`
1375
1376 - `Detail ResponseInputFileDetail`
1377
1378 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.
1379
1380 - `const ResponseInputFileDetailLow ResponseInputFileDetail = "low"`
1381
1382 - `const ResponseInputFileDetailHigh ResponseInputFileDetail = "high"`
1383
1384 - `FileData string`
1385
1386 The content of the file to be sent to the model.
1387
1388 - `FileID string`
1389
1390 The ID of the file to be sent to the model.
1391
1392 - `FileURL string`
1393
1394 The URL of the file to be sent to the model.
1395
1396 - `Filename string`
1397
1398 The name of the file to be sent to the model.
1399
1400 - `Version string`
1401
1402 Optional version of the prompt template.
1403
1404 - `Reasoning RealtimeReasoning`
1405
1406 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
1407
1408 - `Effort RealtimeReasoningEffort`
1409
1410 Constrains effort on reasoning for reasoning-capable Realtime models such as
1411 `gpt-realtime-2`.
1412
1413 - `const RealtimeReasoningEffortMinimal RealtimeReasoningEffort = "minimal"`
1414
1415 - `const RealtimeReasoningEffortLow RealtimeReasoningEffort = "low"`
1416
1417 - `const RealtimeReasoningEffortMedium RealtimeReasoningEffort = "medium"`
1418
1419 - `const RealtimeReasoningEffortHigh RealtimeReasoningEffort = "high"`
1420
1421 - `const RealtimeReasoningEffortXhigh RealtimeReasoningEffort = "xhigh"`
1422
1423 - `ToolChoice RealtimeSessionCreateResponseToolChoiceUnion`
1424
1425 How the model chooses tools. Provide one of the string modes or force a specific
1426 function/MCP tool.
1427
1428 - `type ToolChoiceOptions string`
1429
1430 Controls which (if any) tool is called by the model.
1431
1432 `none` means the model will not call any tool and instead generates a message.
1433
1434 `auto` means the model can pick between generating a message or calling one or
1435 more tools.
1436
1437 `required` means the model must call one or more tools.
1438
1439 - `const ToolChoiceOptionsNone ToolChoiceOptions = "none"`
1440
1441 - `const ToolChoiceOptionsAuto ToolChoiceOptions = "auto"`
1442
1443 - `const ToolChoiceOptionsRequired ToolChoiceOptions = "required"`
1444
1445 - `type ToolChoiceFunction struct{…}`
1446
1447 Use this option to force the model to call a specific function.
1448
1449 - `Name string`
1450
1451 The name of the function to call.
1452
1453 - `Type Function`
1454
1455 For function calling, the type is always `function`.
1456
1457 - `const FunctionFunction Function = "function"`
1458
1459 - `type ToolChoiceMcp struct{…}`
1460
1461 Use this option to force the model to call a specific tool on a remote MCP server.
1462
1463 - `ServerLabel string`
1464
1465 The label of the MCP server to use.
1466
1467 - `Type Mcp`
1468
1469 For MCP tools, the type is always `mcp`.
1470
1471 - `const McpMcp Mcp = "mcp"`
1472
1473 - `Name string`
1474
1475 The name of the tool to call on the server.
1476
1477 - `Tools []RealtimeSessionCreateResponseToolUnion`
1478
1479 Tools available to the model.
1480
1481 - `type RealtimeFunctionTool struct{…}`
1482
1483 - `Description string`
1484
1485 The description of the function, including guidance on when and how
1486 to call it, and guidance about what to tell the user when calling
1487 (if anything).
1488
1489 - `Name string`
1490
1491 The name of the function.
1492
1493 - `Parameters any`
1494
1495 Parameters of the function in JSON Schema.
1496
1497 - `Type RealtimeFunctionToolType`
1498
1499 The type of the tool, i.e. `function`.
1500
1501 - `const RealtimeFunctionToolTypeFunction RealtimeFunctionToolType = "function"`
1502
1503 - `type RealtimeSessionCreateResponseToolMcpTool struct{…}`
1504
1505 Give the model access to additional tools via remote Model Context Protocol
1506 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
1507
1508 - `ServerLabel string`
1509
1510 A label for this MCP server, used to identify it in tool calls.
1511
1512 - `Type Mcp`
1513
1514 The type of the MCP tool. Always `mcp`.
1515
1516 - `const McpMcp Mcp = "mcp"`
1517
1518 - `AllowedTools RealtimeSessionCreateResponseToolMcpToolAllowedToolsUnion`
1519
1520 List of allowed tool names or a filter object.
1521
1522 - `type RealtimeSessionCreateResponseToolMcpToolAllowedToolsMcpAllowedTools []string`
1523
1524 A string array of allowed tool names
1525
1526 - `type RealtimeSessionCreateResponseToolMcpToolAllowedToolsMcpToolFilter struct{…}`
1527
1528 A filter object to specify which tools are allowed.
1529
1530 - `ReadOnly bool`
1531
1532 Indicates whether or not a tool modifies data or is read-only. If an
1533 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
1534 it will match this filter.
1535
1536 - `ToolNames []string`
1537
1538 List of allowed tool names.
1539
1540 - `Authorization string`
1541
1542 An OAuth access token that can be used with a remote MCP server, either
1543 with a custom MCP server URL or a service connector. Your application
1544 must handle the OAuth authorization flow and provide the token here.
1545
1546 - `ConnectorID string`
1547
1548 Identifier for service connectors, like those available in ChatGPT. One of
1549 `server_url` or `connector_id` must be provided. Learn more about service
1550 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
1551
1552 Currently supported `connector_id` values are:
1553
1554 - Dropbox: `connector_dropbox`
1555 - Gmail: `connector_gmail`
1556 - Google Calendar: `connector_googlecalendar`
1557 - Google Drive: `connector_googledrive`
1558 - Microsoft Teams: `connector_microsoftteams`
1559 - Outlook Calendar: `connector_outlookcalendar`
1560 - Outlook Email: `connector_outlookemail`
1561 - SharePoint: `connector_sharepoint`
1562
1563 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorDropbox RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_dropbox"`
1564
1565 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorGmail RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_gmail"`
1566
1567 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorGooglecalendar RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_googlecalendar"`
1568
1569 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorGoogledrive RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_googledrive"`
1570
1571 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorMicrosoftteams RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_microsoftteams"`
1572
1573 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorOutlookcalendar RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_outlookcalendar"`
1574
1575 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorOutlookemail RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_outlookemail"`
1576
1577 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorSharepoint RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_sharepoint"`
1578
1579 - `DeferLoading bool`
1580
1581 Whether this MCP tool is deferred and discovered via tool search.
1582
1583 - `Headers map[string, string]`
1584
1585 Optional HTTP headers to send to the MCP server. Use for authentication
1586 or other purposes.
1587
1588 - `RequireApproval RealtimeSessionCreateResponseToolMcpToolRequireApprovalUnion`
1589
1590 Specify which of the MCP server's tools require approval.
1591
1592 - `type RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalFilter struct{…}`
1593
1594 Specify which of the MCP server's tools require approval. Can be
1595 `always`, `never`, or a filter object associated with tools
1596 that require approval.
1597
1598 - `Always RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalFilterAlways`
1599
1600 A filter object to specify which tools are allowed.
1601
1602 - `ReadOnly bool`
1603
1604 Indicates whether or not a tool modifies data or is read-only. If an
1605 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
1606 it will match this filter.
1607
1608 - `ToolNames []string`
1609
1610 List of allowed tool names.
1611
1612 - `Never RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalFilterNever`
1613
1614 A filter object to specify which tools are allowed.
1615
1616 - `ReadOnly bool`
1617
1618 Indicates whether or not a tool modifies data or is read-only. If an
1619 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
1620 it will match this filter.
1621
1622 - `ToolNames []string`
1623
1624 List of allowed tool names.
1625
1626 - `type RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSetting string`
1627
1628 Specify a single approval policy for all tools. One of `always` or
1629 `never`. When set to `always`, all tools will require approval. When
1630 set to `never`, all tools will not require approval.
1631
1632 - `const RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSettingAlways RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSetting = "always"`
1633
1634 - `const RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSettingNever RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSetting = "never"`
1635
1636 - `ServerDescription string`
1637
1638 Optional description of the MCP server, used to provide more context.
1639
1640 - `ServerURL string`
1641
1642 The URL for the MCP server. One of `server_url` or `connector_id` must be
1643 provided.
1644
1645 - `Tracing RealtimeSessionCreateResponseTracingUnion`
1646
1647 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once
1648 tracing is enabled for a session, the configuration cannot be modified.
1649
1650 `auto` will create a trace for the session with default values for the
1651 workflow name, group id, and metadata.
1652
1653 - `type Auto string`
1654
1655 Enables tracing and sets default values for tracing configuration options. Always `auto`.
1656
1657 - `const AutoAuto Auto = "auto"`
1658
1659 - `type RealtimeSessionCreateResponseTracingTracingConfiguration struct{…}`
1660
1661 Granular configuration for tracing.
1662
1663 - `GroupID string`
1664
1665 The group id to attach to this trace to enable filtering and
1666 grouping in the Traces Dashboard.
1667
1668 - `Metadata any`
1669
1670 The arbitrary metadata to attach to this trace to enable
1671 filtering in the Traces Dashboard.
1672
1673 - `WorkflowName string`
1674
1675 The name of the workflow to attach to this trace. This is used to
1676 name the trace in the Traces Dashboard.
1677
1678 - `Truncation RealtimeTruncationUnion`
1679
1680 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.
1681
1682 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.
1683
1684 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.
1685
1686 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.
1687
1688 - `type RealtimeTruncationRealtimeTruncationStrategy string`
1689
1690 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.
1691
1692 - `const RealtimeTruncationRealtimeTruncationStrategyAuto RealtimeTruncationRealtimeTruncationStrategy = "auto"`
1693
1694 - `const RealtimeTruncationRealtimeTruncationStrategyDisabled RealtimeTruncationRealtimeTruncationStrategy = "disabled"`
1695
1696 - `type RealtimeTruncationRetentionRatio struct{…}`
1697
1698 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.
1699
1700 - `RetentionRatio float64`
1701
1702 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.
1703
1704 - `Type RetentionRatio`
1705
1706 Use retention ratio truncation.
1707
1708 - `const RetentionRatioRetentionRatio RetentionRatio = "retention_ratio"`
1709
1710 - `TokenLimits RealtimeTruncationRetentionRatioTokenLimits`
1711
1712 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.
1713
1714 - `PostInstructions int64`
1715
1716 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.
1717
1718 - `type RealtimeTranscriptionSessionCreateResponse struct{…}`
1719
1720 A Realtime transcription session configuration object.
1721
1722 - `ID string`
1723
1724 Unique identifier for the session that looks like `sess_1234567890abcdef`.
1725
1726 - `Object string`
1727
1728 The object type. Always `realtime.transcription_session`.
1729
1730 - `Type Transcription`
1731
1732 The type of session. Always `transcription` for transcription sessions.
1733
1734 - `const TranscriptionTranscription Transcription = "transcription"`
1735
1736 - `Audio RealtimeTranscriptionSessionCreateResponseAudio`
1737
1738 Configuration for input audio for the session.
1739
1740 - `Input RealtimeTranscriptionSessionCreateResponseAudioInput`
1741
1742 - `Format RealtimeAudioFormatsUnion`
1743
1744 The PCM audio format. Only a 24kHz sample rate is supported.
1745
1746 - `NoiseReduction RealtimeTranscriptionSessionCreateResponseAudioInputNoiseReduction`
1747
1748 Configuration for input audio noise reduction.
1749
1750 - `Type NoiseReductionType`
1751
1752 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.
1753
1754 - `Transcription AudioTranscription`
1755
1756 - `TurnDetection RealtimeTranscriptionSessionTurnDetection`
1757
1758 Configuration for turn detection. Can be set to `null` to turn off. Server
1759 VAD means that the model will detect the start and end of speech based on
1760 audio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.
1761
1762 - `PrefixPaddingMs int64`
1763
1764 Amount of audio to include before the VAD detected speech (in
1765 milliseconds). Defaults to 300ms.
1766
1767 - `SilenceDurationMs int64`
1768
1769 Duration of silence to detect speech stop (in milliseconds). Defaults
1770 to 500ms. With shorter values the model will respond more quickly,
1771 but may jump in on short pauses from the user.
1772
1773 - `Threshold float64`
1774
1775 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A
1776 higher threshold will require louder audio to activate the model, and
1777 thus might perform better in noisy environments.
1778
1779 - `Type string`
1780
1781 Type of turn detection, only `server_vad` is currently supported.
1782
1783 - `ExpiresAt int64`
1784
1785 Expiration timestamp for the session, in seconds since epoch.
1786
1787 - `Include []string`
1788
1789 Additional fields to include in server outputs.
1790
1791 - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
1792
1793 - `const RealtimeTranscriptionSessionCreateResponseIncludeItemInputAudioTranscriptionLogprobs RealtimeTranscriptionSessionCreateResponseInclude = "item.input_audio_transcription.logprobs"`
1794
1795 - `Value string`
1796
1797 The generated client secret value.
1798
1799### Example
1800
1801```go
1802package main
1803
1804import (
1805 "context"
1806 "fmt"
1807
1808 "github.com/openai/openai-go"
1809 "github.com/openai/openai-go/option"
1810 "github.com/openai/openai-go/realtime"
1811)
1812
1813func main() {
1814 client := openai.NewClient(
1815 option.WithAPIKey("My API Key"),
1816 )
1817 clientSecret, err := client.Realtime.ClientSecrets.New(context.TODO(), realtime.ClientSecretNewParams{
1818
1819 })
1820 if err != nil {
1821 panic(err.Error())
1822 }
1823 fmt.Printf("%+v\n", clientSecret.ExpiresAt)
1824}
1825```
1826
1827#### Response
1828
1829```json
1830{
1831 "expires_at": 0,
1832 "session": {
1833 "id": "id",
1834 "object": "realtime.session",
1835 "type": "realtime",
1836 "audio": {
1837 "input": {
1838 "format": {
1839 "rate": 24000,
1840 "type": "audio/pcm"
1841 },
1842 "noise_reduction": {
1843 "type": "near_field"
1844 },
1845 "transcription": {
1846 "delay": "minimal",
1847 "language": "language",
1848 "model": "whisper-1",
1849 "prompt": "prompt"
1850 },
1851 "turn_detection": {
1852 "type": "server_vad",
1853 "create_response": true,
1854 "idle_timeout_ms": 5000,
1855 "interrupt_response": true,
1856 "prefix_padding_ms": 0,
1857 "silence_duration_ms": 0,
1858 "threshold": 0
1859 }
1860 },
1861 "output": {
1862 "format": {
1863 "rate": 24000,
1864 "type": "audio/pcm"
1865 },
1866 "speed": 0.25,
1867 "voice": "ash"
1868 }
1869 },
1870 "expires_at": 0,
1871 "include": [
1872 "item.input_audio_transcription.logprobs"
1873 ],
1874 "instructions": "instructions",
1875 "max_output_tokens": "inf",
1876 "model": "gpt-realtime",
1877 "output_modalities": [
1878 "text"
1879 ],
1880 "prompt": {
1881 "id": "id",
1882 "variables": {
1883 "foo": "string"
1884 },
1885 "version": "version"
1886 },
1887 "reasoning": {
1888 "effort": "minimal"
1889 },
1890 "tool_choice": "none",
1891 "tools": [
1892 {
1893 "description": "description",
1894 "name": "name",
1895 "parameters": {},
1896 "type": "function"
1897 }
1898 ],
1899 "tracing": "auto",
1900 "truncation": "auto"
1901 },
1902 "value": "value"
1903}
1904```