@@ -915,12 +915,34 @@ export type RealtimeClientEvent =
915915 | ConversationItemTruncateEvent
916916 | InputAudioBufferAppendEvent
917917 | InputAudioBufferClearEvent
918+ | RealtimeClientEvent . OutputAudioBufferClear
918919 | InputAudioBufferCommitEvent
919920 | ResponseCancelEvent
920921 | ResponseCreateEvent
921922 | SessionUpdateEvent
922923 | TranscriptionSessionUpdate ;
923924
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+
924946/**
925947 * The response resource.
926948 */
@@ -1174,7 +1196,10 @@ export type RealtimeServerEvent =
11741196 | ResponseTextDoneEvent
11751197 | SessionCreatedEvent
11761198 | SessionUpdatedEvent
1177- | TranscriptionSessionUpdatedEvent ;
1199+ | TranscriptionSessionUpdatedEvent
1200+ | RealtimeServerEvent . OutputAudioBufferStarted
1201+ | RealtimeServerEvent . OutputAudioBufferStopped
1202+ | RealtimeServerEvent . OutputAudioBufferCleared ;
11781203
11791204export namespace RealtimeServerEvent {
11801205 /**
@@ -1197,6 +1222,77 @@ export namespace RealtimeServerEvent {
11971222 */
11981223 type : 'conversation.item.retrieved' ;
11991224 }
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+ }
12001296}
12011297
12021298/**
0 commit comments