-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocument.json
More file actions
2507 lines (2507 loc) · 146 KB
/
document.json
File metadata and controls
2507 lines (2507 loc) · 146 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[
{
"id": "realtime",
"type": "generated",
"title": "Realtime",
"content": "Communicate with a GPT-4o class model live, in real time, over WebSocket.\nProduces both audio and text transcriptions.\n[Learn more about the Realtime API](/docs/guides/realtime).\n",
"navigationGroup": "realtime",
"url": "/docs/api-reference/realtime",
"beta": true,
"sections": []
}, {
"id": "realtime-client-events",
"type": "generated",
"title": "Client events",
"content": "These are events that the OpenAI Realtime WebSocket server will accept from the client.\n",
"navigationGroup": "realtime",
"url": "/docs/api-reference/realtime-client-events",
"sections": [{
"type": "objectgroup",
"title": "session",
"url": "/docs/api-reference/realtime-client-events/session",
"relativeUrl": "realtime-client-events/session",
"indent": 0
}, {
"type": "object",
"navTitle": ".update",
"title": "session.update",
"content": "Send this event to update the session’s default configuration. The client may send this event at any time to update the session configuration, and any field may be updated at any time, except for 'voice'. The server will respond with a `session.updated` event that shows the full effective configuration. Only fields that are present are updated, thus the correct way to clear a field like 'instructions' is to pass an empty string.",
"url": "/docs/api-reference/realtime-client-events/session/update",
"relativeUrl": "realtime-client-events/session/update",
"definition": {
"type": "object",
"description": "Send this event to update the session’s default configuration. The client may send this event at any time to update the session configuration, and any field may be updated at any time, except for 'voice'. The server will respond with a `session.updated` event that shows the full effective configuration. Only fields that are present are updated, thus the correct way to clear a field like 'instructions' is to pass an empty string.",
"properties": {
"event_id": {
"type": "string",
"description": "Optional client-generated ID used to identify this event."
},
"type": {
"type": "string",
"description": "The event type, must be 'session.update'"
},
"session": {
"type": "object",
"description": "Realtime session object configuration.",
"properties": {
"modalities": {
"type": "array",
"items": {
"type": "string"
},
"description": "The set of modalities the model can respond with. To disable audio,\nset this to ['text']."
},
"instructions": {
"type": "string",
"description": "The default system instructions (i.e. system message) prepended to model \ncalls. This field allows the client to guide the model on desired \nresponses. The model can be instructed on response content and format, \n(e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good \nresponses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion \ninto your voice\", \"laugh frequently\"). The instructions are not guaranteed \nto be followed by the model, but they provide guidance to the model on the \ndesired behavior.\n\nNote that the server sets default instructions which will be used if this \nfield is not set and are visible in the `session.created` event at the \nstart of the session.\n"
},
"voice": {
"type": "string",
"enum": ["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse"],
"description": "The voice the model uses to respond. Supported voices are `alloy`, `ash`,\n`ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. Cannot be \nchanged once the model has responded with audio at least once.\n"
},
"input_audio_format": {
"type": "string",
"description": "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n"
},
"output_audio_format": {
"type": "string",
"description": "The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n"
},
"input_audio_transcription": {
"type": "object",
"description": "Configuration for input audio transcription, defaults to off and can be \nset to `null` to turn off once on. Input audio transcription is not native \nto the model, since the model consumes audio directly. Transcription runs \nasynchronously through Whisper and should be treated as rough guidance \nrather than the representation understood by the model.\n",
"properties": {
"model": {
"type": "string",
"description": "The model to use for transcription, `whisper-1` is the only currently \nsupported model.\n"
}
}
},
"turn_detection": {
"type": "object",
"description": "Configuration for turn detection. Can be set to `null` to turn off. Server \nVAD means that the model will detect the start and end of speech based on \naudio volume and respond at the end of user speech.\n",
"properties": {
"type": {
"type": "string",
"description": "Type of turn detection, only `server_vad` is currently supported.\n"
},
"threshold": {
"type": "number",
"description": "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A \nhigher threshold will require louder audio to activate the model, and \nthus might perform better in noisy environments.\n"
},
"prefix_padding_ms": {
"type": "integer",
"description": "Amount of audio to include before the VAD detected speech (in \nmilliseconds). Defaults to 300ms.\n"
},
"silence_duration_ms": {
"type": "integer",
"description": "Duration of silence to detect speech stop (in milliseconds). Defaults \nto 500ms. With shorter values the model will respond more quickly, \nbut may jump in on short pauses from the user.\n"
}
}
},
"tools": {
"type": "array",
"description": "Tools (functions) available to the model.",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The type of the tool, i.e. `function`."
},
"name": {
"type": "string",
"description": "The name of the function."
},
"description": {
"type": "string",
"description": "The description of the function, including guidance on when and how \nto call it, and guidance about what to tell the user when calling \n(if anything).\n"
},
"parameters": {
"type": "object",
"description": "Parameters of the function in JSON Schema."
}
}
}
},
"tool_choice": {
"type": "string",
"description": "How the model chooses tools. Options are `auto`, `none`, `required`, or \nspecify a function.\n"
},
"temperature": {
"type": "number",
"description": "Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.\n"
},
"max_response_output_tokens": {
"oneOf": [{
"type": "integer"
}, {
"type": "string",
"enum": ["inf"]
}],
"description": "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n"
}
}
}
},
"required": ["type", "session"],
"x-oaiMeta": {
"name": "session.update",
"group": "realtime",
"example": {
"event_id": "event_123",
"type": "session.update",
"session": {
"modalities": ["text", "audio"],
"instructions": "Your knowledge cutoff is 2023-10. You are a helpful assistant.",
"voice": "alloy",
"input_audio_format": "pcm16",
"output_audio_format": "pcm16",
"input_audio_transcription": {
"model": "whisper-1"
},
"turn_detection": {
"type": "server_vad",
"threshold": 0.5,
"prefix_padding_ms": 300,
"silence_duration_ms": 500
},
"tools": [
{
"type": "function",
"name": "get_weather",
"description": "Get the current weather for a location, tell the user you are fetching the weather.",
"parameters": {
"type": "object",
"properties": {
"location": { "type": "string" }
},
"required": ["location"]
}
}
],
"tool_choice": "auto",
"temperature": 0.8,
"max_response_output_tokens": "inf"
}
}
}
},
"indent": 1
}, {
"type": "objectgroup",
"title": "input_audio_buffer",
"url": "/docs/api-reference/realtime-client-events/input_audio_buffer",
"relativeUrl": "realtime-client-events/input_audio_buffer",
"indent": 0
}, {
"type": "object",
"navTitle": ".append",
"title": "input_audio_buffer.append",
"content": "Send this event to append audio bytes to the input audio buffer. The audio buffer is temporary storage you can write to and later commit. In Server VAD mode, the audio buffer is used to detect speech and the server will decide when to commit. When Server VAD is disabled, you must commit the audio buffer manually.\nThe client may choose how much audio to place in each event up to a maximum of 15 MiB, for example streaming smaller chunks from the client may allow the VAD to be more responsive. Unlike made other client events, the server will not send a confirmation response to this event.",
"url": "/docs/api-reference/realtime-client-events/input_audio_buffer/append",
"relativeUrl": "realtime-client-events/input_audio_buffer/append",
"definition": {
"type": "object",
"description": "Send this event to append audio bytes to the input audio buffer. The audio buffer is temporary storage you can write to and later commit. In Server VAD mode, the audio buffer is used to detect speech and the server will decide when to commit. When Server VAD is disabled, you must commit the audio buffer manually.\nThe client may choose how much audio to place in each event up to a maximum of 15 MiB, for example streaming smaller chunks from the client may allow the VAD to be more responsive. Unlike made other client events, the server will not send a confirmation response to this event.",
"properties": {
"event_id": {
"type": "string",
"description": "Optional client-generated ID used to identify this event."
},
"type": {
"type": "string",
"description": 'The event type, must be "input_audio_buffer.append".'
},
"audio": {
"type": "string",
"description": "Base64-encoded audio bytes. This must be in the format specified by the `input_audio_format` field in the session configuration."
}
},
"required": ["type", "audio"],
"x-oaiMeta": {
name: "input_audio_buffer.append",
group: "realtime",
example: '{\n "event_id": "event_456",\n "type": "input_audio_buffer.append",\n "audio": "Base64EncodedAudioData"\n}\n'
}
},
indent: 1
}, {
type: "object",
navTitle: ".commit",
title: "input_audio_buffer.commit",
content: "Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. This event will produce an error if the input audio buffer is empty. When in Server VAD mode, the client does not need to send this event, the server will commit the audio buffer automatically.\nCommitting the input audio buffer will trigger input audio transcription (if enabled in session configuration), but it will not create a response from the model. The server will respond with an `input_audio_buffer.committed` event.",
url: "/docs/api-reference/realtime-client-events/input_audio_buffer/commit",
relativeUrl: "realtime-client-events/input_audio_buffer/commit",
definition: {
type: "object",
description: "Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. This event will produce an error if the input audio buffer is empty. When in Server VAD mode, the client does not need to send this event, the server will commit the audio buffer automatically.\nCommitting the input audio buffer will trigger input audio transcription (if enabled in session configuration), but it will not create a response from the model. The server will respond with an `input_audio_buffer.committed` event.",
properties: {
event_id: {
type: "string",
description: "Optional client-generated ID used to identify this event."
},
type: {
type: "string",
description: 'The event type, must be "input_audio_buffer.commit".'
}
},
required: ["type"],
"x-oaiMeta": {
name: "input_audio_buffer.commit",
group: "realtime",
example: '{\n "event_id": "event_789",\n "type": "input_audio_buffer.commit"\n}\n'
}
},
indent: 1
}, {
type: "object",
navTitle: ".clear",
title: "input_audio_buffer.clear",
content: "Send this event to clear the audio bytes in the buffer. The server will respond with an `input_audio_buffer.cleared` event.",
url: "/docs/api-reference/realtime-client-events/input_audio_buffer/clear",
relativeUrl: "realtime-client-events/input_audio_buffer/clear",
definition: {
type: "object",
description: "Send this event to clear the audio bytes in the buffer. The server will respond with an `input_audio_buffer.cleared` event.",
properties: {
event_id: {
type: "string",
description: "Optional client-generated ID used to identify this event."
},
type: {
type: "string",
description: 'The event type, must be "input_audio_buffer.clear".'
}
},
required: ["type"],
"x-oaiMeta": {
name: "input_audio_buffer.clear",
group: "realtime",
example: '{\n "event_id": "event_012",\n "type": "input_audio_buffer.clear"\n}\n'
}
},
indent: 1
}, {
type: "objectgroup",
title: "conversation",
url: "/docs/api-reference/realtime-client-events/conversation",
relativeUrl: "realtime-client-events/conversation",
indent: 0
}, {
type: "objectgroup",
title: ".item",
url: "/docs/api-reference/realtime-client-events/conversation/item",
relativeUrl: "realtime-client-events/conversation/item",
indent: 1
}, {
type: "object",
navTitle: ".create",
title: "conversation.item.create",
content: 'Add a new Item to the Conversation\'s context, including messages, function calls, and function call responses. This event can be used both to populate a "history" of the conversation and to add new items mid-stream, but has the current limitation that it cannot populate assistant audio messages.\nIf successful, the server will respond with a `conversation.item.created` event, otherwise an `error` event will be sent.',
url: "/docs/api-reference/realtime-client-events/conversation/item/create",
relativeUrl: "realtime-client-events/conversation/item/create",
definition: {
type: "object",
description: 'Add a new Item to the Conversation\'s context, including messages, function calls, and function call responses. This event can be used both to populate a "history" of the conversation and to add new items mid-stream, but has the current limitation that it cannot populate assistant audio messages.\nIf successful, the server will respond with a `conversation.item.created` event, otherwise an `error` event will be sent.',
properties: {
event_id: {
type: "string",
description: "Optional client-generated ID used to identify this event."
},
type: {
type: "string",
description: "The event type, must be `conversation.item.create`."
},
previous_item_id: {
type: "string",
description: "The ID of the preceding item after which the new item will be inserted. If not set, the new item will be appended to the end of the conversation. If set, it allows an item to be inserted mid-conversation. If the ID cannot be found, an error will be returned and the item will not be added."
},
item: {
type: "object",
description: "The item to add to the conversation.",
properties: {
id: {
type: "string",
description: "The unique ID of the item, this can be generated by the client to help manage server-side context, but is not required because the server will generate one if not provided."
},
type: {
type: "string",
description: "The type of the item (`message`, `function_call`, `function_call_output`)."
},
status: {
type: "string",
description: "The status of the item (`completed`, `incomplete`). These have no effect on the conversation, but are accepted for consistency with the `conversation.item.created` event."
},
role: {
type: "string",
description: "The role of the message sender (`user`, `assistant`, `system`), only applicable for `message` items."
},
content: {
type: "array",
description: "The content of the message, applicable for `message` items. Message items with a role of `system` support only `input_text` content, message items of role `user` support `input_text` and `input_audio` content, and message items of role `assistant` support `text` content.",
items: {
type: "object",
properties: {
type: {
type: "string",
description: "The content type (`input_text`, `input_audio`, `text`)."
},
text: {
type: "string",
description: "The text content, used for `input_text` and `text` content types."
},
audio: {
type: "string",
description: "Base64-encoded audio bytes, used for `input_audio` content type."
},
transcript: {
type: "string",
description: "The transcript of the audio, used for `input_audio` content type."
}
}
}
},
call_id: {
type: "string",
description: "The ID of the function call (for `function_call` and `function_call_output` items). If passed on a `function_call_output` item, the server will check that a `function_call` item with the same ID exists in the conversation history."
},
name: {
type: "string",
description: "The name of the function being called (for `function_call` items)."
},
arguments: {
type: "string",
description: "The arguments of the function call (for `function_call` items)."
},
output: {
type: "string",
description: "The output of the function call (for `function_call_output` items)."
}
}
}
},
required: ["type", "item"],
"x-oaiMeta": {
name: "conversation.item.create",
group: "realtime",
example: '{\n "event_id": "event_345",\n "type": "conversation.item.create",\n "previous_item_id": null,\n "item": {\n "id": "msg_001",\n "type": "message",\n "role": "user",\n "content": [\n {\n "type": "input_text",\n "text": "Hello, how are you?"\n }\n ]\n }\n}\n'
}
},
indent: 2
}, {
type: "object",
navTitle: ".truncate",
title: "conversation.item.truncate",
content: "Send this event to truncate a previous assistant message’s audio. The server will produce audio faster than realtime, so this event is useful when the user interrupts to truncate audio that has already been sent to the client but not yet played. This will synchronize the server's understanding of the audio with the client's playback.\nTruncating audio will delete the server-side text transcript to ensure there is not text in the context that hasn't been heard by the user.\nIf successful, the server will respond with a `conversation.item.truncated` event. ",
url: "/docs/api-reference/realtime-client-events/conversation/item/truncate",
relativeUrl: "realtime-client-events/conversation/item/truncate",
definition: {
type: "object",
description: "Send this event to truncate a previous assistant message’s audio. The server will produce audio faster than realtime, so this event is useful when the user interrupts to truncate audio that has already been sent to the client but not yet played. This will synchronize the server's understanding of the audio with the client's playback.\nTruncating audio will delete the server-side text transcript to ensure there is not text in the context that hasn't been heard by the user.\nIf successful, the server will respond with a `conversation.item.truncated` event. ",
properties: {
event_id: {
type: "string",
description: "Optional client-generated ID used to identify this event."
},
type: {
type: "string",
description: 'The event type, must be "conversation.item.truncate".'
},
item_id: {
type: "string",
description: "The ID of the assistant message item to truncate. Only assistant message items can be truncated."
},
content_index: {
type: "integer",
description: "The index of the content part to truncate. Set this to 0."
},
audio_end_ms: {
type: "integer",
description: "Inclusive duration up to which audio is truncated, in milliseconds. If the audio_end_ms is greater than the actual audio duration, the server will respond with an error."
}
},
required: ["type", "item_id", "content_index", "audio_end_ms"],
"x-oaiMeta": {
name: "conversation.item.truncate",
group: "realtime",
example: '{\n "event_id": "event_678",\n "type": "conversation.item.truncate",\n "item_id": "msg_002",\n "content_index": 0,\n "audio_end_ms": 1500\n}\n'
}
},
indent: 2
}, {
type: "object",
navTitle: ".delete",
title: "conversation.item.delete",
content: "Send this event when you want to remove any item from the conversation history. The server will respond with a `conversation.item.deleted` event, unless the item does not exist in the conversation history, in which case the server will respond with an error.",
url: "/docs/api-reference/realtime-client-events/conversation/item/delete",
relativeUrl: "realtime-client-events/conversation/item/delete",
definition: {
type: "object",
description: "Send this event when you want to remove any item from the conversation history. The server will respond with a `conversation.item.deleted` event, unless the item does not exist in the conversation history, in which case the server will respond with an error.",
properties: {
event_id: {
type: "string",
description: "Optional client-generated ID used to identify this event."
},
type: {
type: "string",
description: 'The event type, must be "conversation.item.delete".'
},
item_id: {
type: "string",
description: "The ID of the item to delete."
}
},
required: ["type", "item_id"],
"x-oaiMeta": {
name: "conversation.item.delete",
group: "realtime",
example: '{\n "event_id": "event_901",\n "type": "conversation.item.delete",\n "item_id": "msg_003"\n}\n'
}
},
indent: 2
}, {
type: "objectgroup",
title: "response",
url: "/docs/api-reference/realtime-client-events/response",
relativeUrl: "realtime-client-events/response",
indent: 0
}, {
type: "object",
navTitle: ".create",
title: "response.create",
content: "This event instructs the server to create a Response, which means triggering model inference. When in Server VAD mode, the server will create Responses automatically.\nA Response will include at least one Item, and may have two, in which case the second will be a function call. These Items will be appended to the conversation history.\nThe server will respond with a `response.created` event, events for Items and content created, and finally a `response.done` event to indicate the Response is complete.\nThe `response.create` event includes inference configuration like `instructions`, and `temperature`. These fields will override the Session's configuration for this Response only.",
url: "/docs/api-reference/realtime-client-events/response/create",
relativeUrl: "realtime-client-events/response/create",
definition: {
type: "object",
description: "This event instructs the server to create a Response, which means triggering model inference. When in Server VAD mode, the server will create Responses automatically.\nA Response will include at least one Item, and may have two, in which case the second will be a function call. These Items will be appended to the conversation history.\nThe server will respond with a `response.created` event, events for Items and content created, and finally a `response.done` event to indicate the Response is complete.\nThe `response.create` event includes inference configuration like `instructions`, and `temperature`. These fields will override the Session's configuration for this Response only.",
properties: {
event_id: {
type: "string",
description: "Optional client-generated ID used to identify this event."
},
type: {
type: "string",
description: "The event type, must be `response.create`."
},
response: {
type: "object",
description: "The response resource.",
properties: {
id: {
type: "string",
description: "The unique ID of the response."
},
object: {
type: "string",
description: "The object type, must be `realtime.response`."
},
status: {
type: "string",
description: "The final status of the response (`completed`, `cancelled`, `failed`, `incomplete`)."
},
status_details: {
type: "object",
description: "Additional details about the status.",
properties: {
type: {
type: "string",
description: "The type of error that caused the response to fail, corresponding with the `status` field (`cancelled`, `incomplete`, `failed`)."
},
reason: {
type: "string",
description: "The reason the Response did not complete. For a `cancelled` Response, one of `turn_detected` (the server VAD detected a new start of speech) or `client_cancelled` (the client sent a cancel event). For an `incomplete` Response, one of `max_output_tokens` or `content_filter` (the server-side safety filter activated and cut off the response)."
},
error: {
type: "object",
description: "A description of the error that caused the response to fail, populated when the `status` is `failed`.",
properties: {
type: {
type: "string",
description: "The type of error."
},
code: {
type: "string",
description: "Error code, if any."
}
}
}
}
},
output: {
type: "array",
description: "The list of output items generated by the response.",
items: {
type: "object",
description: "An item in the response output."
}
},
usage: {
type: "object",
description: "Usage statistics for the Response, this will correspond to billing. A Realtime API session will maintain a conversation context and append new Items to the Conversation, thus output from previous turns (text and audio tokens) will become the input for later turns.",
properties: {
total_tokens: {
type: "integer",
description: "The total number of tokens in the Response including input and output text and audio tokens."
},
input_tokens: {
type: "integer",
description: "The number of input tokens used in the Response, including text and audio tokens."
},
output_tokens: {
type: "integer",
description: "The number of output tokens sent in the Response, including text and audio tokens."
},
input_token_details: {
type: "object",
description: "Details about the input tokens used in the Response.",
properties: {
cached_tokens: {
type: "integer",
description: "The number of cached tokens used in the Response."
},
text_tokens: {
type: "integer",
description: "The number of text tokens used in the Response."
},
audio_tokens: {
type: "integer",
description: "The number of audio tokens used in the Response."
}
}
},
output_token_details: {
type: "object",
description: "Details about the output tokens used in the Response.",
properties: {
text_tokens: {
type: "integer",
description: "The number of text tokens used in the Response."
},
audio_tokens: {
type: "integer",
description: "The number of audio tokens used in the Response."
}
}
}
}
}
}
}
},
required: ["type", "response"],
"x-oaiMeta": {
name: "response.create",
group: "realtime",
example: '{\n "event_id": "event_234",\n "type": "response.create",\n "response": {\n "modalities": ["text", "audio"],\n "instructions": "Please assist the user.",\n "voice": "alloy",\n "output_audio_format": "pcm16",\n "tools": [\n {\n "type": "function",\n "name": "calculate_sum",\n "description": "Calculates the sum of two numbers.",\n "parameters": {\n "type": "object",\n "properties": {\n "a": { "type": "number" },\n "b": { "type": "number" }\n },\n "required": ["a", "b"]\n }\n }\n ],\n "tool_choice": "auto",\n "temperature": 0.7,\n "max_output_tokens": 150\n }\n}\n'
}
},
indent: 1
}, {
type: "object",
navTitle: ".cancel",
title: "response.cancel",
content: "Send this event to cancel an in-progress response. The server will respond with a `response.cancelled` event or an error if there is no response to cancel.",
url: "/docs/api-reference/realtime-client-events/response/cancel",
relativeUrl: "realtime-client-events/response/cancel",
definition: {
type: "object",
description: "Send this event to cancel an in-progress response. The server will respond with a `response.cancelled` event or an error if there is no response to cancel.",
properties: {
event_id: {
type: "string",
description: "Optional client-generated ID used to identify this event."
},
type: {
type: "string",
description: "The event type, must be `response.cancel`."
}
},
required: ["type"],
"x-oaiMeta": {
name: "response.cancel",
group: "realtime",
example: '{\n "event_id": "event_567",\n "type": "response.cancel"\n}\n'
}
},
indent: 1
}]
}, {
id: "realtime-server-events",
type: "generated",
title: "Server events",
content: "These are events emitted from the OpenAI Realtime WebSocket server to the client.\n",
navigationGroup: "realtime",
url: "/docs/api-reference/realtime-server-events",
sections: [{
type: "object",
navTitle: "error",
title: "error",
content: "Returned when an error occurs, which could be a client problem or a server problem. Most errors are recoverable and the session will stay open, we recommend to implementors to monitor and log error messages by default.",
url: "/docs/api-reference/realtime-server-events/error",
relativeUrl: "realtime-server-events/error",
definition: {
type: "object",
description: "Returned when an error occurs, which could be a client problem or a server problem. Most errors are recoverable and the session will stay open, we recommend to implementors to monitor and log error messages by default.",
properties: {
event_id: {
type: "string",
description: "The unique ID of the server event."
},
type: {
type: "string",
description: 'The event type, must be "error".'
},
error: {
type: "object",
description: "Details of the error.",
properties: {
type: {
type: "string",
description: 'The type of error (e.g., "invalid_request_error", "server_error").'
},
code: {
type: "string",
description: "Error code, if any."
},
message: {
type: "string",
description: "A human-readable error message."
},
param: {
type: "string",
description: "Parameter related to the error, if any."
},
event_id: {
type: "string",
description: "The event_id of the client event that caused the error, if applicable."
}
}
}
},
required: ["event_id", "type", "error"],
"x-oaiMeta": {
name: "error",
group: "realtime",
example: '{\n "event_id": "event_890",\n "type": "error",\n "error": {\n "type": "invalid_request_error",\n "code": "invalid_event",\n "message": "The \'type\' field is missing.",\n "param": null,\n "event_id": "event_567"\n }\n}\n'
}
},
indent: 0
}, {
type: "objectgroup",
title: "session",
url: "/docs/api-reference/realtime-server-events/session",
relativeUrl: "realtime-server-events/session",
indent: 0
}, {
type: "object",
navTitle: ".created",
title: "session.created",
content: "Returned when a Session is created. Emitted automatically when a new connection is established as the first server event. This event will contain the default Session configuration.",
url: "/docs/api-reference/realtime-server-events/session/created",
relativeUrl: "realtime-server-events/session/created",
definition: {
type: "object",
description: "Returned when a Session is created. Emitted automatically when a new connection is established as the first server event. This event will contain the default Session configuration.",
properties: {
event_id: {
type: "string",
description: "The unique ID of the server event."
},
type: {
type: "string",
description: "The event type, must be `session.created`."
},
session: {
type: "object",
description: "Realtime session object configuration.",
properties: {
modalities: {
type: "array",
items: {
type: "string"
},
description: 'The set of modalities the model can respond with. To disable audio,\nset this to ["text"].\n'
},
instructions: {
type: "string",
description: 'The default system instructions (i.e. system message) prepended to model \ncalls. This field allows the client to guide the model on desired \nresponses. The model can be instructed on response content and format, \n(e.g. "be extremely succinct", "act friendly", "here are examples of good \nresponses") and on audio behavior (e.g. "talk quickly", "inject emotion \ninto your voice", "laugh frequently"). The instructions are not guaranteed \nto be followed by the model, but they provide guidance to the model on the \ndesired behavior.\n\nNote that the server sets default instructions which will be used if this \nfield is not set and are visible in the `session.created` event at the \nstart of the session.\n'
},
voice: {
type: "string",
enum: ["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse"],
description: "The voice the model uses to respond. Supported voices are `alloy`, `ash`,\n`ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. Cannot be \nchanged once the model has responded with audio at least once.\n"
},
input_audio_format: {
type: "string",
description: "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n"
},
output_audio_format: {
type: "string",
description: "The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n"
},
input_audio_transcription: {
type: "object",
description: "Configuration for input audio transcription, defaults to off and can be \nset to `null` to turn off once on. Input audio transcription is not native \nto the model, since the model consumes audio directly. Transcription runs \nasynchronously through Whisper and should be treated as rough guidance \nrather than the representation understood by the model.\n",
properties: {
model: {
type: "string",
description: "The model to use for transcription, `whisper-1` is the only currently \nsupported model.\n"
}
}
},
turn_detection: {
type: "object",
description: "Configuration for turn detection. Can be set to `null` to turn off. Server \nVAD means that the model will detect the start and end of speech based on \naudio volume and respond at the end of user speech.\n",
properties: {
type: {
type: "string",
description: "Type of turn detection, only `server_vad` is currently supported.\n"
},
threshold: {
type: "number",
description: "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A \nhigher threshold will require louder audio to activate the model, and \nthus might perform better in noisy environments.\n"
},
prefix_padding_ms: {
type: "integer",
description: "Amount of audio to include before the VAD detected speech (in \nmilliseconds). Defaults to 300ms.\n"
},
silence_duration_ms: {
type: "integer",
description: "Duration of silence to detect speech stop (in milliseconds). Defaults \nto 500ms. With shorter values the model will respond more quickly, \nbut may jump in on short pauses from the user.\n"
}
}
},
tools: {
type: "array",
description: "Tools (functions) available to the model.",
items: {
type: "object",
properties: {
type: {
type: "string",
description: "The type of the tool, i.e. `function`."
},
name: {
type: "string",
description: "The name of the function."
},
description: {
type: "string",
description: "The description of the function, including guidance on when and how \nto call it, and guidance about what to tell the user when calling \n(if anything).\n"
},
parameters: {
type: "object",
description: "Parameters of the function in JSON Schema."
}
}
}
},
tool_choice: {
type: "string",
description: "How the model chooses tools. Options are `auto`, `none`, `required`, or \nspecify a function.\n"
},
temperature: {
type: "number",
description: "Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.\n"
},
max_response_output_tokens: {
oneOf: [{
type: "integer"
}, {
type: "string",
enum: ["inf"]
}],
description: "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n"
}
}
}
},
required: ["event_id", "type", "session"],
"x-oaiMeta": {
name: "session.created",
group: "realtime",
example: '{\n "event_id": "event_1234",\n "type": "session.created",\n "session": {\n "id": "sess_001",\n "object": "realtime.session",\n "model": "gpt-4o-realtime-preview-2024-10-01",\n "modalities": ["text", "audio"],\n "instructions": "",\n "voice": "alloy",\n "input_audio_format": "pcm16",\n "output_audio_format": "pcm16",\n "input_audio_transcription": null,\n "turn_detection": {\n "type": "server_vad",\n "threshold": 0.5,\n "prefix_padding_ms": 300,\n "silence_duration_ms": 200\n },\n "tools": [],\n "tool_choice": "auto",\n "temperature": 0.8,\n "max_response_output_tokens": null\n }\n}\n'
}
},
indent: 1
}, {
type: "object",
navTitle: ".updated",
title: "session.updated",
content: "Returned when a session is updated with a `session.update` event, unless there is an error.",
url: "/docs/api-reference/realtime-server-events/session/updated",
relativeUrl: "realtime-server-events/session/updated",
definition: {
type: "object",
description: "Returned when a session is updated with a `session.update` event, unless there is an error.",
properties: {
event_id: {
type: "string",
description: "The unique ID of the server event."
},
type: {
type: "string",
description: 'The event type, must be "session.updated".'
},
session: {
type: "object",
description: "Realtime session object configuration.",
properties: {
modalities: {
type: "array",
items: {
type: "string"
},
description: 'The set of modalities the model can respond with. To disable audio,\nset this to ["text"].\n'
},
instructions: {
type: "string",
description: 'The default system instructions (i.e. system message) prepended to model \ncalls. This field allows the client to guide the model on desired \nresponses. The model can be instructed on response content and format, \n(e.g. "be extremely succinct", "act friendly", "here are examples of good \nresponses") and on audio behavior (e.g. "talk quickly", "inject emotion \ninto your voice", "laugh frequently"). The instructions are not guaranteed \nto be followed by the model, but they provide guidance to the model on the \ndesired behavior.\n\nNote that the server sets default instructions which will be used if this \nfield is not set and are visible in the `session.created` event at the \nstart of the session.\n'
},
voice: {
type: "string",
enum: ["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse"],
description: "The voice the model uses to respond. Supported voices are `alloy`, `ash`,\n`ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`. Cannot be \nchanged once the model has responded with audio at least once.\n"
},
input_audio_format: {
type: "string",
description: "The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n"
},
output_audio_format: {
type: "string",
description: "The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.\n"
},
input_audio_transcription: {
type: "object",
description: "Configuration for input audio transcription, defaults to off and can be \nset to `null` to turn off once on. Input audio transcription is not native \nto the model, since the model consumes audio directly. Transcription runs \nasynchronously through Whisper and should be treated as rough guidance \nrather than the representation understood by the model.\n",
properties: {
model: {
type: "string",
description: "The model to use for transcription, `whisper-1` is the only currently \nsupported model.\n"
}
}
},
turn_detection: {
type: "object",
description: "Configuration for turn detection. Can be set to `null` to turn off. Server \nVAD means that the model will detect the start and end of speech based on \naudio volume and respond at the end of user speech.\n",
properties: {
type: {
type: "string",
description: "Type of turn detection, only `server_vad` is currently supported.\n"
},
threshold: {
type: "number",
description: "Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A \nhigher threshold will require louder audio to activate the model, and \nthus might perform better in noisy environments.\n"
},
prefix_padding_ms: {
type: "integer",
description: "Amount of audio to include before the VAD detected speech (in \nmilliseconds). Defaults to 300ms.\n"
},
silence_duration_ms: {
type: "integer",
description: "Duration of silence to detect speech stop (in milliseconds). Defaults \nto 500ms. With shorter values the model will respond more quickly, \nbut may jump in on short pauses from the user.\n"
}
}
},
tools: {
type: "array",
description: "Tools (functions) available to the model.",
items: {
type: "object",
properties: {
type: {
type: "string",
description: "The type of the tool, i.e. `function`."
},
name: {
type: "string",
description: "The name of the function."
},
description: {
type: "string",
description: "The description of the function, including guidance on when and how \nto call it, and guidance about what to tell the user when calling \n(if anything).\n"
},
parameters: {
type: "object",
description: "Parameters of the function in JSON Schema."
}
}
}
},
tool_choice: {
type: "string",
description: "How the model chooses tools. Options are `auto`, `none`, `required`, or \nspecify a function.\n"
},
temperature: {
type: "number",
description: "Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.\n"
},
max_response_output_tokens: {
oneOf: [{
type: "integer"
}, {
type: "string",
enum: ["inf"]
}],
description: "Maximum number of output tokens for a single assistant response,\ninclusive of tool calls. Provide an integer between 1 and 4096 to\nlimit output tokens, or `inf` for the maximum available tokens for a\ngiven model. Defaults to `inf`.\n"
}
}
}
},
required: ["event_id", "type", "session"],
"x-oaiMeta": {
name: "session.updated",
group: "realtime",
example: '{\n "event_id": "event_5678",\n "type": "session.updated",\n "session": {\n "id": "sess_001",\n "object": "realtime.session",\n "model": "gpt-4o-realtime-preview-2024-10-01",\n "modalities": ["text"],\n "instructions": "New instructions",\n "voice": "alloy",\n "input_audio_format": "pcm16",\n "output_audio_format": "pcm16",\n "input_audio_transcription": {\n "model": "whisper-1"\n },\n "turn_detection": null,\n "tools": [],\n "tool_choice": "none",\n "temperature": 0.7,\n "max_response_output_tokens": 200\n }\n}\n'
}
},
indent: 1
}, {
type: "objectgroup",
title: "conversation",
url: "/docs/api-reference/realtime-server-events/conversation",
relativeUrl: "realtime-server-events/conversation",
indent: 0
}, {
type: "object",
navTitle: ".created",
title: "conversation.created",
content: "Returned when a conversation is created. Emitted right after session creation.",
url: "/docs/api-reference/realtime-server-events/conversation/created",
relativeUrl: "realtime-server-events/conversation/created",
definition: {
type: "object",
description: "Returned when a conversation is created. Emitted right after session creation.",
properties: {
event_id: {
type: "string",
description: "The unique ID of the server event."
},
type: {
type: "string",
description: 'The event type, must be "conversation.created".'
},
conversation: {
type: "object",
description: "The conversation resource.",
properties: {
id: {
type: "string",
description: "The unique ID of the conversation."
},
object: {
type: "string",
description: 'The object type, must be "realtime.conversation".'
}
}