@@ -915,12 +915,34 @@ export type RealtimeClientEvent =
915
915
| ConversationItemTruncateEvent
916
916
| InputAudioBufferAppendEvent
917
917
| InputAudioBufferClearEvent
918
+ | RealtimeClientEvent . OutputAudioBufferClear
918
919
| InputAudioBufferCommitEvent
919
920
| ResponseCancelEvent
920
921
| ResponseCreateEvent
921
922
| SessionUpdateEvent
922
923
| TranscriptionSessionUpdate ;
923
924
925
+ export namespace RealtimeClientEvent {
926
+ /**
927
+ * **WebRTC Only:** Emit to cut off the current audio response. This will trigger
928
+ * the server to stop generating audio and emit a `output_audio_buffer.cleared`
929
+ * event. This event should be preceded by a `response.cancel` client event to stop
930
+ * the generation of the current response.
931
+ * [Learn more](https://platform.openai.com/docs/guides/realtime-model-capabilities#client-and-server-events-for-audio-in-webrtc).
932
+ */
933
+ export interface OutputAudioBufferClear {
934
+ /**
935
+ * The event type, must be `output_audio_buffer.clear`.
936
+ */
937
+ type : 'output_audio_buffer.clear' ;
938
+
939
+ /**
940
+ * The unique ID of the client event used for error handling.
941
+ */
942
+ event_id ?: string ;
943
+ }
944
+ }
945
+
924
946
/**
925
947
* The response resource.
926
948
*/
@@ -1174,7 +1196,10 @@ export type RealtimeServerEvent =
1174
1196
| ResponseTextDoneEvent
1175
1197
| SessionCreatedEvent
1176
1198
| SessionUpdatedEvent
1177
- | TranscriptionSessionUpdatedEvent ;
1199
+ | TranscriptionSessionUpdatedEvent
1200
+ | RealtimeServerEvent . OutputAudioBufferStarted
1201
+ | RealtimeServerEvent . OutputAudioBufferStopped
1202
+ | RealtimeServerEvent . OutputAudioBufferCleared ;
1178
1203
1179
1204
export namespace RealtimeServerEvent {
1180
1205
/**
@@ -1197,6 +1222,77 @@ export namespace RealtimeServerEvent {
1197
1222
*/
1198
1223
type : 'conversation.item.retrieved' ;
1199
1224
}
1225
+
1226
+ /**
1227
+ * **WebRTC Only:** Emitted when the server begins streaming audio to the client.
1228
+ * This event is emitted after an audio content part has been added
1229
+ * (`response.content_part.added`) to the response.
1230
+ * [Learn more](https://platform.openai.com/docs/guides/realtime-model-capabilities#client-and-server-events-for-audio-in-webrtc).
1231
+ */
1232
+ export interface OutputAudioBufferStarted {
1233
+ /**
1234
+ * The unique ID of the server event.
1235
+ */
1236
+ event_id : string ;
1237
+
1238
+ /**
1239
+ * The unique ID of the response that produced the audio.
1240
+ */
1241
+ response_id : string ;
1242
+
1243
+ /**
1244
+ * The event type, must be `output_audio_buffer.started`.
1245
+ */
1246
+ type : 'output_audio_buffer.started' ;
1247
+ }
1248
+
1249
+ /**
1250
+ * **WebRTC Only:** Emitted when the output audio buffer has been completely
1251
+ * drained on the server, and no more audio is forthcoming. This event is emitted
1252
+ * after the full response data has been sent to the client (`response.done`).
1253
+ * [Learn more](https://platform.openai.com/docs/guides/realtime-model-capabilities#client-and-server-events-for-audio-in-webrtc).
1254
+ */
1255
+ export interface OutputAudioBufferStopped {
1256
+ /**
1257
+ * The unique ID of the server event.
1258
+ */
1259
+ event_id : string ;
1260
+
1261
+ /**
1262
+ * The unique ID of the response that produced the audio.
1263
+ */
1264
+ response_id : string ;
1265
+
1266
+ /**
1267
+ * The event type, must be `output_audio_buffer.stopped`.
1268
+ */
1269
+ type : 'output_audio_buffer.stopped' ;
1270
+ }
1271
+
1272
+ /**
1273
+ * **WebRTC Only:** Emitted when the output audio buffer is cleared. This happens
1274
+ * either in VAD mode when the user has interrupted
1275
+ * (`input_audio_buffer.speech_started`), or when the client has emitted the
1276
+ * `output_audio_buffer.clear` event to manually cut off the current audio
1277
+ * response.
1278
+ * [Learn more](https://platform.openai.com/docs/guides/realtime-model-capabilities#client-and-server-events-for-audio-in-webrtc).
1279
+ */
1280
+ export interface OutputAudioBufferCleared {
1281
+ /**
1282
+ * The unique ID of the server event.
1283
+ */
1284
+ event_id : string ;
1285
+
1286
+ /**
1287
+ * The unique ID of the response that produced the audio.
1288
+ */
1289
+ response_id : string ;
1290
+
1291
+ /**
1292
+ * The event type, must be `output_audio_buffer.cleared`.
1293
+ */
1294
+ type : 'output_audio_buffer.cleared' ;
1295
+ }
1200
1296
}
1201
1297
1202
1298
/**
0 commit comments