openai 4.77.4 → 4.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/resources/beta/beta.d.ts +4 -0
  4. package/resources/beta/beta.d.ts.map +1 -1
  5. package/resources/beta/beta.js +4 -0
  6. package/resources/beta/beta.js.map +1 -1
  7. package/resources/beta/beta.mjs +4 -0
  8. package/resources/beta/beta.mjs.map +1 -1
  9. package/resources/beta/index.d.ts +1 -0
  10. package/resources/beta/index.d.ts.map +1 -1
  11. package/resources/beta/index.js +10 -8
  12. package/resources/beta/index.js.map +1 -1
  13. package/resources/beta/index.mjs +1 -0
  14. package/resources/beta/index.mjs.map +1 -1
  15. package/resources/beta/realtime/index.d.ts +3 -0
  16. package/resources/beta/realtime/index.d.ts.map +1 -0
  17. package/resources/beta/realtime/index.js +9 -0
  18. package/resources/beta/realtime/index.js.map +1 -0
  19. package/resources/beta/realtime/index.mjs +4 -0
  20. package/resources/beta/realtime/index.mjs.map +1 -0
  21. package/resources/beta/realtime/realtime.d.ts +1584 -0
  22. package/resources/beta/realtime/realtime.d.ts.map +1 -0
  23. package/resources/beta/realtime/realtime.js +39 -0
  24. package/resources/beta/realtime/realtime.js.map +1 -0
  25. package/resources/beta/realtime/realtime.mjs +12 -0
  26. package/resources/beta/realtime/realtime.mjs.map +1 -0
  27. package/resources/beta/realtime/sessions.d.ts +455 -0
  28. package/resources/beta/realtime/sessions.d.ts.map +1 -0
  29. package/resources/beta/realtime/sessions.js +25 -0
  30. package/resources/beta/realtime/sessions.js.map +1 -0
  31. package/resources/beta/realtime/sessions.mjs +21 -0
  32. package/resources/beta/realtime/sessions.mjs.map +1 -0
  33. package/src/resources/beta/beta.ts +6 -0
  34. package/src/resources/beta/index.ts +1 -0
  35. package/src/resources/beta/realtime/index.ts +4 -0
  36. package/src/resources/beta/realtime/realtime.ts +1904 -0
  37. package/src/resources/beta/realtime/sessions.ts +546 -0
  38. package/src/version.ts +1 -1
  39. package/version.d.ts +1 -1
  40. package/version.js +1 -1
  41. package/version.mjs +1 -1
@@ -0,0 +1,1584 @@
1
+ import { APIResource } from "../../../resource.js";
2
+ import * as RealtimeAPI from "./realtime.js";
3
+ import * as SessionsAPI from "./sessions.js";
4
+ import { Session as SessionsAPISession, SessionCreateParams, SessionCreateResponse, Sessions } from "./sessions.js";
5
+ export declare class Realtime extends APIResource {
6
+ sessions: SessionsAPI.Sessions;
7
+ }
8
+ /**
9
+ * Returned when a conversation is created. Emitted right after session creation.
10
+ */
11
+ export interface ConversationCreatedEvent {
12
+ /**
13
+ * The conversation resource.
14
+ */
15
+ conversation: ConversationCreatedEvent.Conversation;
16
+ /**
17
+ * The unique ID of the server event.
18
+ */
19
+ event_id: string;
20
+ /**
21
+ * The event type, must be `conversation.created`.
22
+ */
23
+ type: 'conversation.created';
24
+ }
25
+ export declare namespace ConversationCreatedEvent {
26
+ /**
27
+ * The conversation resource.
28
+ */
29
+ interface Conversation {
30
+ /**
31
+ * The unique ID of the conversation.
32
+ */
33
+ id?: string;
34
+ /**
35
+ * The object type, must be `realtime.conversation`.
36
+ */
37
+ object?: 'realtime.conversation';
38
+ }
39
+ }
40
+ /**
41
+ * The item to add to the conversation.
42
+ */
43
+ export interface ConversationItem {
44
+ /**
45
+ * The unique ID of the item, this can be generated by the client to help manage
46
+ * server-side context, but is not required because the server will generate one if
47
+ * not provided.
48
+ */
49
+ id?: string;
50
+ /**
51
+ * The arguments of the function call (for `function_call` items).
52
+ */
53
+ arguments?: string;
54
+ /**
55
+ * The ID of the function call (for `function_call` and `function_call_output`
56
+ * items). If passed on a `function_call_output` item, the server will check that a
57
+ * `function_call` item with the same ID exists in the conversation history.
58
+ */
59
+ call_id?: string;
60
+ /**
61
+ * The content of the message, applicable for `message` items.
62
+ *
63
+ * - Message items of role `system` support only `input_text` content
64
+ * - Message items of role `user` support `input_text` and `input_audio` content
65
+ * - Message items of role `assistant` support `text` content.
66
+ */
67
+ content?: Array<ConversationItemContent>;
68
+ /**
69
+ * The name of the function being called (for `function_call` items).
70
+ */
71
+ name?: string;
72
+ /**
73
+ * Identifier for the API object being returned - always `realtime.item`.
74
+ */
75
+ object?: 'realtime.item';
76
+ /**
77
+ * The output of the function call (for `function_call_output` items).
78
+ */
79
+ output?: string;
80
+ /**
81
+ * The role of the message sender (`user`, `assistant`, `system`), only applicable
82
+ * for `message` items.
83
+ */
84
+ role?: 'user' | 'assistant' | 'system';
85
+ /**
86
+ * The status of the item (`completed`, `incomplete`). These have no effect on the
87
+ * conversation, but are accepted for consistency with the
88
+ * `conversation.item.created` event.
89
+ */
90
+ status?: 'completed' | 'incomplete';
91
+ /**
92
+ * The type of the item (`message`, `function_call`, `function_call_output`).
93
+ */
94
+ type?: 'message' | 'function_call' | 'function_call_output';
95
+ }
96
+ export interface ConversationItemContent {
97
+ /**
98
+ * ID of a previous conversation item to reference (for `item_reference` content
99
+ * types in `response.create` events). These can reference both client and server
100
+ * created items.
101
+ */
102
+ id?: string;
103
+ /**
104
+ * Base64-encoded audio bytes, used for `input_audio` content type.
105
+ */
106
+ audio?: string;
107
+ /**
108
+ * The text content, used for `input_text` and `text` content types.
109
+ */
110
+ text?: string;
111
+ /**
112
+ * The transcript of the audio, used for `input_audio` content type.
113
+ */
114
+ transcript?: string;
115
+ /**
116
+ * The content type (`input_text`, `input_audio`, `item_reference`, `text`).
117
+ */
118
+ type?: 'input_text' | 'input_audio' | 'item_reference' | 'text';
119
+ }
120
+ /**
121
+ * Add a new Item to the Conversation's context, including messages, function
122
+ * calls, and function call responses. This event can be used both to populate a
123
+ * "history" of the conversation and to add new items mid-stream, but has the
124
+ * current limitation that it cannot populate assistant audio messages.
125
+ *
126
+ * If successful, the server will respond with a `conversation.item.created` event,
127
+ * otherwise an `error` event will be sent.
128
+ */
129
+ export interface ConversationItemCreateEvent {
130
+ /**
131
+ * The item to add to the conversation.
132
+ */
133
+ item: ConversationItem;
134
+ /**
135
+ * The event type, must be `conversation.item.create`.
136
+ */
137
+ type: 'conversation.item.create';
138
+ /**
139
+ * Optional client-generated ID used to identify this event.
140
+ */
141
+ event_id?: string;
142
+ /**
143
+ * The ID of the preceding item after which the new item will be inserted. If not
144
+ * set, the new item will be appended to the end of the conversation. If set, it
145
+ * allows an item to be inserted mid-conversation. If the ID cannot be found, an
146
+ * error will be returned and the item will not be added.
147
+ */
148
+ previous_item_id?: string;
149
+ }
150
+ /**
151
+ * Returned when a conversation item is created. There are several scenarios that
152
+ * produce this event:
153
+ *
154
+ * - The server is generating a Response, which if successful will produce either
155
+ * one or two Items, which will be of type `message` (role `assistant`) or type
156
+ * `function_call`.
157
+ * - The input audio buffer has been committed, either by the client or the server
158
+ * (in `server_vad` mode). The server will take the content of the input audio
159
+ * buffer and add it to a new user message Item.
160
+ * - The client has sent a `conversation.item.create` event to add a new Item to
161
+ * the Conversation.
162
+ */
163
+ export interface ConversationItemCreatedEvent {
164
+ /**
165
+ * The unique ID of the server event.
166
+ */
167
+ event_id: string;
168
+ /**
169
+ * The item to add to the conversation.
170
+ */
171
+ item: ConversationItem;
172
+ /**
173
+ * The ID of the preceding item in the Conversation context, allows the client to
174
+ * understand the order of the conversation.
175
+ */
176
+ previous_item_id: string;
177
+ /**
178
+ * The event type, must be `conversation.item.created`.
179
+ */
180
+ type: 'conversation.item.created';
181
+ }
182
+ /**
183
+ * Send this event when you want to remove any item from the conversation history.
184
+ * The server will respond with a `conversation.item.deleted` event, unless the
185
+ * item does not exist in the conversation history, in which case the server will
186
+ * respond with an error.
187
+ */
188
+ export interface ConversationItemDeleteEvent {
189
+ /**
190
+ * The ID of the item to delete.
191
+ */
192
+ item_id: string;
193
+ /**
194
+ * The event type, must be `conversation.item.delete`.
195
+ */
196
+ type: 'conversation.item.delete';
197
+ /**
198
+ * Optional client-generated ID used to identify this event.
199
+ */
200
+ event_id?: string;
201
+ }
202
+ /**
203
+ * Returned when an item in the conversation is deleted by the client with a
204
+ * `conversation.item.delete` event. This event is used to synchronize the server's
205
+ * understanding of the conversation history with the client's view.
206
+ */
207
+ export interface ConversationItemDeletedEvent {
208
+ /**
209
+ * The unique ID of the server event.
210
+ */
211
+ event_id: string;
212
+ /**
213
+ * The ID of the item that was deleted.
214
+ */
215
+ item_id: string;
216
+ /**
217
+ * The event type, must be `conversation.item.deleted`.
218
+ */
219
+ type: 'conversation.item.deleted';
220
+ }
221
+ /**
222
+ * This event is the output of audio transcription for user audio written to the
223
+ * user audio buffer. Transcription begins when the input audio buffer is committed
224
+ * by the client or server (in `server_vad` mode). Transcription runs
225
+ * asynchronously with Response creation, so this event may come before or after
226
+ * the Response events.
227
+ *
228
+ * Realtime API models accept audio natively, and thus input transcription is a
229
+ * separate process run on a separate ASR (Automatic Speech Recognition) model,
230
+ * currently always `whisper-1`. Thus the transcript may diverge somewhat from the
231
+ * model's interpretation, and should be treated as a rough guide.
232
+ */
233
+ export interface ConversationItemInputAudioTranscriptionCompletedEvent {
234
+ /**
235
+ * The index of the content part containing the audio.
236
+ */
237
+ content_index: number;
238
+ /**
239
+ * The unique ID of the server event.
240
+ */
241
+ event_id: string;
242
+ /**
243
+ * The ID of the user message item containing the audio.
244
+ */
245
+ item_id: string;
246
+ /**
247
+ * The transcribed text.
248
+ */
249
+ transcript: string;
250
+ /**
251
+ * The event type, must be `conversation.item.input_audio_transcription.completed`.
252
+ */
253
+ type: 'conversation.item.input_audio_transcription.completed';
254
+ }
255
+ /**
256
+ * Returned when input audio transcription is configured, and a transcription
257
+ * request for a user message failed. These events are separate from other `error`
258
+ * events so that the client can identify the related Item.
259
+ */
260
+ export interface ConversationItemInputAudioTranscriptionFailedEvent {
261
+ /**
262
+ * The index of the content part containing the audio.
263
+ */
264
+ content_index: number;
265
+ /**
266
+ * Details of the transcription error.
267
+ */
268
+ error: ConversationItemInputAudioTranscriptionFailedEvent.Error;
269
+ /**
270
+ * The unique ID of the server event.
271
+ */
272
+ event_id: string;
273
+ /**
274
+ * The ID of the user message item.
275
+ */
276
+ item_id: string;
277
+ /**
278
+ * The event type, must be `conversation.item.input_audio_transcription.failed`.
279
+ */
280
+ type: 'conversation.item.input_audio_transcription.failed';
281
+ }
282
+ export declare namespace ConversationItemInputAudioTranscriptionFailedEvent {
283
+ /**
284
+ * Details of the transcription error.
285
+ */
286
+ interface Error {
287
+ /**
288
+ * Error code, if any.
289
+ */
290
+ code?: string;
291
+ /**
292
+ * A human-readable error message.
293
+ */
294
+ message?: string;
295
+ /**
296
+ * Parameter related to the error, if any.
297
+ */
298
+ param?: string;
299
+ /**
300
+ * The type of error.
301
+ */
302
+ type?: string;
303
+ }
304
+ }
305
+ /**
306
+ * Send this event to truncate a previous assistant message’s audio. The server
307
+ * will produce audio faster than realtime, so this event is useful when the user
308
+ * interrupts to truncate audio that has already been sent to the client but not
309
+ * yet played. This will synchronize the server's understanding of the audio with
310
+ * the client's playback.
311
+ *
312
+ * Truncating audio will delete the server-side text transcript to ensure there is
313
+ * not text in the context that hasn't been heard by the user.
314
+ *
315
+ * If successful, the server will respond with a `conversation.item.truncated`
316
+ * event.
317
+ */
318
+ export interface ConversationItemTruncateEvent {
319
+ /**
320
+ * Inclusive duration up to which audio is truncated, in milliseconds. If the
321
+ * audio_end_ms is greater than the actual audio duration, the server will respond
322
+ * with an error.
323
+ */
324
+ audio_end_ms: number;
325
+ /**
326
+ * The index of the content part to truncate. Set this to 0.
327
+ */
328
+ content_index: number;
329
+ /**
330
+ * The ID of the assistant message item to truncate. Only assistant message items
331
+ * can be truncated.
332
+ */
333
+ item_id: string;
334
+ /**
335
+ * The event type, must be `conversation.item.truncate`.
336
+ */
337
+ type: 'conversation.item.truncate';
338
+ /**
339
+ * Optional client-generated ID used to identify this event.
340
+ */
341
+ event_id?: string;
342
+ }
343
+ /**
344
+ * Returned when an earlier assistant audio message item is truncated by the client
345
+ * with a `conversation.item.truncate` event. This event is used to synchronize the
346
+ * server's understanding of the audio with the client's playback.
347
+ *
348
+ * This action will truncate the audio and remove the server-side text transcript
349
+ * to ensure there is no text in the context that hasn't been heard by the user.
350
+ */
351
+ export interface ConversationItemTruncatedEvent {
352
+ /**
353
+ * The duration up to which the audio was truncated, in milliseconds.
354
+ */
355
+ audio_end_ms: number;
356
+ /**
357
+ * The index of the content part that was truncated.
358
+ */
359
+ content_index: number;
360
+ /**
361
+ * The unique ID of the server event.
362
+ */
363
+ event_id: string;
364
+ /**
365
+ * The ID of the assistant message item that was truncated.
366
+ */
367
+ item_id: string;
368
+ /**
369
+ * The event type, must be `conversation.item.truncated`.
370
+ */
371
+ type: 'conversation.item.truncated';
372
+ }
373
+ /**
374
+ * Returned when an error occurs, which could be a client problem or a server
375
+ * problem. Most errors are recoverable and the session will stay open, we
376
+ * recommend to implementors to monitor and log error messages by default.
377
+ */
378
+ export interface ErrorEvent {
379
+ /**
380
+ * Details of the error.
381
+ */
382
+ error: ErrorEvent.Error;
383
+ /**
384
+ * The unique ID of the server event.
385
+ */
386
+ event_id: string;
387
+ /**
388
+ * The event type, must be `error`.
389
+ */
390
+ type: 'error';
391
+ }
392
+ export declare namespace ErrorEvent {
393
+ /**
394
+ * Details of the error.
395
+ */
396
+ interface Error {
397
+ /**
398
+ * A human-readable error message.
399
+ */
400
+ message: string;
401
+ /**
402
+ * The type of error (e.g., "invalid_request_error", "server_error").
403
+ */
404
+ type: string;
405
+ /**
406
+ * Error code, if any.
407
+ */
408
+ code?: string | null;
409
+ /**
410
+ * The event_id of the client event that caused the error, if applicable.
411
+ */
412
+ event_id?: string | null;
413
+ /**
414
+ * Parameter related to the error, if any.
415
+ */
416
+ param?: string | null;
417
+ }
418
+ }
419
+ /**
420
+ * Send this event to append audio bytes to the input audio buffer. The audio
421
+ * buffer is temporary storage you can write to and later commit. In Server VAD
422
+ * mode, the audio buffer is used to detect speech and the server will decide when
423
+ * to commit. When Server VAD is disabled, you must commit the audio buffer
424
+ * manually.
425
+ *
426
+ * The client may choose how much audio to place in each event up to a maximum of
427
+ * 15 MiB, for example streaming smaller chunks from the client may allow the VAD
428
+ * to be more responsive. Unlike made other client events, the server will not send
429
+ * a confirmation response to this event.
430
+ */
431
+ export interface InputAudioBufferAppendEvent {
432
+ /**
433
+ * Base64-encoded audio bytes. This must be in the format specified by the
434
+ * `input_audio_format` field in the session configuration.
435
+ */
436
+ audio: string;
437
+ /**
438
+ * The event type, must be `input_audio_buffer.append`.
439
+ */
440
+ type: 'input_audio_buffer.append';
441
+ /**
442
+ * Optional client-generated ID used to identify this event.
443
+ */
444
+ event_id?: string;
445
+ }
446
+ /**
447
+ * Send this event to clear the audio bytes in the buffer. The server will respond
448
+ * with an `input_audio_buffer.cleared` event.
449
+ */
450
+ export interface InputAudioBufferClearEvent {
451
+ /**
452
+ * The event type, must be `input_audio_buffer.clear`.
453
+ */
454
+ type: 'input_audio_buffer.clear';
455
+ /**
456
+ * Optional client-generated ID used to identify this event.
457
+ */
458
+ event_id?: string;
459
+ }
460
+ /**
461
+ * Returned when the input audio buffer is cleared by the client with a
462
+ * `input_audio_buffer.clear` event.
463
+ */
464
+ export interface InputAudioBufferClearedEvent {
465
+ /**
466
+ * The unique ID of the server event.
467
+ */
468
+ event_id: string;
469
+ /**
470
+ * The event type, must be `input_audio_buffer.cleared`.
471
+ */
472
+ type: 'input_audio_buffer.cleared';
473
+ }
474
+ /**
475
+ * Send this event to commit the user input audio buffer, which will create a new
476
+ * user message item in the conversation. This event will produce an error if the
477
+ * input audio buffer is empty. When in Server VAD mode, the client does not need
478
+ * to send this event, the server will commit the audio buffer automatically.
479
+ *
480
+ * Committing the input audio buffer will trigger input audio transcription (if
481
+ * enabled in session configuration), but it will not create a response from the
482
+ * model. The server will respond with an `input_audio_buffer.committed` event.
483
+ */
484
+ export interface InputAudioBufferCommitEvent {
485
+ /**
486
+ * The event type, must be `input_audio_buffer.commit`.
487
+ */
488
+ type: 'input_audio_buffer.commit';
489
+ /**
490
+ * Optional client-generated ID used to identify this event.
491
+ */
492
+ event_id?: string;
493
+ }
494
+ /**
495
+ * Returned when an input audio buffer is committed, either by the client or
496
+ * automatically in server VAD mode. The `item_id` property is the ID of the user
497
+ * message item that will be created, thus a `conversation.item.created` event will
498
+ * also be sent to the client.
499
+ */
500
+ export interface InputAudioBufferCommittedEvent {
501
+ /**
502
+ * The unique ID of the server event.
503
+ */
504
+ event_id: string;
505
+ /**
506
+ * The ID of the user message item that will be created.
507
+ */
508
+ item_id: string;
509
+ /**
510
+ * The ID of the preceding item after which the new item will be inserted.
511
+ */
512
+ previous_item_id: string;
513
+ /**
514
+ * The event type, must be `input_audio_buffer.committed`.
515
+ */
516
+ type: 'input_audio_buffer.committed';
517
+ }
518
+ /**
519
+ * Sent by the server when in `server_vad` mode to indicate that speech has been
520
+ * detected in the audio buffer. This can happen any time audio is added to the
521
+ * buffer (unless speech is already detected). The client may want to use this
522
+ * event to interrupt audio playback or provide visual feedback to the user.
523
+ *
524
+ * The client should expect to receive a `input_audio_buffer.speech_stopped` event
525
+ * when speech stops. The `item_id` property is the ID of the user message item
526
+ * that will be created when speech stops and will also be included in the
527
+ * `input_audio_buffer.speech_stopped` event (unless the client manually commits
528
+ * the audio buffer during VAD activation).
529
+ */
530
+ export interface InputAudioBufferSpeechStartedEvent {
531
+ /**
532
+ * Milliseconds from the start of all audio written to the buffer during the
533
+ * session when speech was first detected. This will correspond to the beginning of
534
+ * audio sent to the model, and thus includes the `prefix_padding_ms` configured in
535
+ * the Session.
536
+ */
537
+ audio_start_ms: number;
538
+ /**
539
+ * The unique ID of the server event.
540
+ */
541
+ event_id: string;
542
+ /**
543
+ * The ID of the user message item that will be created when speech stops.
544
+ */
545
+ item_id: string;
546
+ /**
547
+ * The event type, must be `input_audio_buffer.speech_started`.
548
+ */
549
+ type: 'input_audio_buffer.speech_started';
550
+ }
551
+ /**
552
+ * Returned in `server_vad` mode when the server detects the end of speech in the
553
+ * audio buffer. The server will also send an `conversation.item.created` event
554
+ * with the user message item that is created from the audio buffer.
555
+ */
556
+ export interface InputAudioBufferSpeechStoppedEvent {
557
+ /**
558
+ * Milliseconds since the session started when speech stopped. This will correspond
559
+ * to the end of audio sent to the model, and thus includes the
560
+ * `min_silence_duration_ms` configured in the Session.
561
+ */
562
+ audio_end_ms: number;
563
+ /**
564
+ * The unique ID of the server event.
565
+ */
566
+ event_id: string;
567
+ /**
568
+ * The ID of the user message item that will be created.
569
+ */
570
+ item_id: string;
571
+ /**
572
+ * The event type, must be `input_audio_buffer.speech_stopped`.
573
+ */
574
+ type: 'input_audio_buffer.speech_stopped';
575
+ }
576
+ /**
577
+ * Emitted at the beginning of a Response to indicate the updated rate limits. When
578
+ * a Response is created some tokens will be "reserved" for the output tokens, the
579
+ * rate limits shown here reflect that reservation, which is then adjusted
580
+ * accordingly once the Response is completed.
581
+ */
582
+ export interface RateLimitsUpdatedEvent {
583
+ /**
584
+ * The unique ID of the server event.
585
+ */
586
+ event_id: string;
587
+ /**
588
+ * List of rate limit information.
589
+ */
590
+ rate_limits: Array<RateLimitsUpdatedEvent.RateLimit>;
591
+ /**
592
+ * The event type, must be `rate_limits.updated`.
593
+ */
594
+ type: 'rate_limits.updated';
595
+ }
596
+ export declare namespace RateLimitsUpdatedEvent {
597
+ interface RateLimit {
598
+ /**
599
+ * The maximum allowed value for the rate limit.
600
+ */
601
+ limit?: number;
602
+ /**
603
+ * The name of the rate limit (`requests`, `tokens`).
604
+ */
605
+ name?: 'requests' | 'tokens';
606
+ /**
607
+ * The remaining value before the limit is reached.
608
+ */
609
+ remaining?: number;
610
+ /**
611
+ * Seconds until the rate limit resets.
612
+ */
613
+ reset_seconds?: number;
614
+ }
615
+ }
616
+ /**
617
+ * All events that the client can send to the Realtime API
618
+ */
619
+ export type RealtimeClientEvent = SessionUpdateEvent | InputAudioBufferAppendEvent | InputAudioBufferCommitEvent | InputAudioBufferClearEvent | ConversationItemCreateEvent | ConversationItemTruncateEvent | ConversationItemDeleteEvent | ResponseCreateEvent | ResponseCancelEvent;
620
+ /**
621
+ * The response resource.
622
+ */
623
+ export interface RealtimeResponse {
624
+ /**
625
+ * The unique ID of the response.
626
+ */
627
+ id?: string;
628
+ /**
629
+ * Developer-provided string key-value pairs associated with this response.
630
+ */
631
+ metadata?: unknown | null;
632
+ /**
633
+ * The object type, must be `realtime.response`.
634
+ */
635
+ object?: 'realtime.response';
636
+ /**
637
+ * The list of output items generated by the response.
638
+ */
639
+ output?: Array<ConversationItem>;
640
+ /**
641
+ * The final status of the response (`completed`, `cancelled`, `failed`, or
642
+ * `incomplete`).
643
+ */
644
+ status?: 'completed' | 'cancelled' | 'failed' | 'incomplete';
645
+ /**
646
+ * Additional details about the status.
647
+ */
648
+ status_details?: RealtimeResponseStatus;
649
+ /**
650
+ * Usage statistics for the Response, this will correspond to billing. A Realtime
651
+ * API session will maintain a conversation context and append new Items to the
652
+ * Conversation, thus output from previous turns (text and audio tokens) will
653
+ * become the input for later turns.
654
+ */
655
+ usage?: RealtimeResponseUsage;
656
+ }
657
+ /**
658
+ * Additional details about the status.
659
+ */
660
+ export interface RealtimeResponseStatus {
661
+ /**
662
+ * A description of the error that caused the response to fail, populated when the
663
+ * `status` is `failed`.
664
+ */
665
+ error?: RealtimeResponseStatus.Error;
666
+ /**
667
+ * The reason the Response did not complete. For a `cancelled` Response, one of
668
+ * `turn_detected` (the server VAD detected a new start of speech) or
669
+ * `client_cancelled` (the client sent a cancel event). For an `incomplete`
670
+ * Response, one of `max_output_tokens` or `content_filter` (the server-side safety
671
+ * filter activated and cut off the response).
672
+ */
673
+ reason?: 'turn_detected' | 'client_cancelled' | 'max_output_tokens' | 'content_filter';
674
+ /**
675
+ * The type of error that caused the response to fail, corresponding with the
676
+ * `status` field (`completed`, `cancelled`, `incomplete`, `failed`).
677
+ */
678
+ type?: 'completed' | 'cancelled' | 'incomplete' | 'failed';
679
+ }
680
+ export declare namespace RealtimeResponseStatus {
681
+ /**
682
+ * A description of the error that caused the response to fail, populated when the
683
+ * `status` is `failed`.
684
+ */
685
+ interface Error {
686
+ /**
687
+ * Error code, if any.
688
+ */
689
+ code?: string;
690
+ /**
691
+ * The type of error.
692
+ */
693
+ type?: string;
694
+ }
695
+ }
696
+ /**
697
+ * Usage statistics for the Response, this will correspond to billing. A Realtime
698
+ * API session will maintain a conversation context and append new Items to the
699
+ * Conversation, thus output from previous turns (text and audio tokens) will
700
+ * become the input for later turns.
701
+ */
702
+ export interface RealtimeResponseUsage {
703
+ /**
704
+ * Details about the input tokens used in the Response.
705
+ */
706
+ input_token_details?: RealtimeResponseUsage.InputTokenDetails;
707
+ /**
708
+ * The number of input tokens used in the Response, including text and audio
709
+ * tokens.
710
+ */
711
+ input_tokens?: number;
712
+ /**
713
+ * Details about the output tokens used in the Response.
714
+ */
715
+ output_token_details?: RealtimeResponseUsage.OutputTokenDetails;
716
+ /**
717
+ * The number of output tokens sent in the Response, including text and audio
718
+ * tokens.
719
+ */
720
+ output_tokens?: number;
721
+ /**
722
+ * The total number of tokens in the Response including input and output text and
723
+ * audio tokens.
724
+ */
725
+ total_tokens?: number;
726
+ }
727
+ export declare namespace RealtimeResponseUsage {
728
+ /**
729
+ * Details about the input tokens used in the Response.
730
+ */
731
+ interface InputTokenDetails {
732
+ /**
733
+ * The number of audio tokens used in the Response.
734
+ */
735
+ audio_tokens?: number;
736
+ /**
737
+ * The number of cached tokens used in the Response.
738
+ */
739
+ cached_tokens?: number;
740
+ /**
741
+ * The number of text tokens used in the Response.
742
+ */
743
+ text_tokens?: number;
744
+ }
745
+ /**
746
+ * Details about the output tokens used in the Response.
747
+ */
748
+ interface OutputTokenDetails {
749
+ /**
750
+ * The number of audio tokens used in the Response.
751
+ */
752
+ audio_tokens?: number;
753
+ /**
754
+ * The number of text tokens used in the Response.
755
+ */
756
+ text_tokens?: number;
757
+ }
758
+ }
759
+ /**
760
+ * All events that the Realtime API can send back
761
+ */
762
+ export type RealtimeServerEvent = ErrorEvent | SessionCreatedEvent | SessionUpdatedEvent | ConversationCreatedEvent | InputAudioBufferCommittedEvent | InputAudioBufferClearedEvent | InputAudioBufferSpeechStartedEvent | InputAudioBufferSpeechStoppedEvent | ConversationItemCreatedEvent | ConversationItemInputAudioTranscriptionCompletedEvent | ConversationItemInputAudioTranscriptionFailedEvent | ConversationItemTruncatedEvent | ConversationItemDeletedEvent | ResponseCreatedEvent | ResponseDoneEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseContentPartAddedEvent | ResponseContentPartDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent | ResponseAudioTranscriptDeltaEvent | ResponseAudioTranscriptDoneEvent | ResponseAudioDeltaEvent | ResponseAudioDoneEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | RateLimitsUpdatedEvent;
763
+ /**
764
+ * Returned when the model-generated audio is updated.
765
+ */
766
+ export interface ResponseAudioDeltaEvent {
767
+ /**
768
+ * The index of the content part in the item's content array.
769
+ */
770
+ content_index: number;
771
+ /**
772
+ * Base64-encoded audio data delta.
773
+ */
774
+ delta: string;
775
+ /**
776
+ * The unique ID of the server event.
777
+ */
778
+ event_id: string;
779
+ /**
780
+ * The ID of the item.
781
+ */
782
+ item_id: string;
783
+ /**
784
+ * The index of the output item in the response.
785
+ */
786
+ output_index: number;
787
+ /**
788
+ * The ID of the response.
789
+ */
790
+ response_id: string;
791
+ /**
792
+ * The event type, must be `response.audio.delta`.
793
+ */
794
+ type: 'response.audio.delta';
795
+ }
796
+ /**
797
+ * Returned when the model-generated audio is done. Also emitted when a Response is
798
+ * interrupted, incomplete, or cancelled.
799
+ */
800
+ export interface ResponseAudioDoneEvent {
801
+ /**
802
+ * The index of the content part in the item's content array.
803
+ */
804
+ content_index: number;
805
+ /**
806
+ * The unique ID of the server event.
807
+ */
808
+ event_id: string;
809
+ /**
810
+ * The ID of the item.
811
+ */
812
+ item_id: string;
813
+ /**
814
+ * The index of the output item in the response.
815
+ */
816
+ output_index: number;
817
+ /**
818
+ * The ID of the response.
819
+ */
820
+ response_id: string;
821
+ /**
822
+ * The event type, must be `response.audio.done`.
823
+ */
824
+ type: 'response.audio.done';
825
+ }
826
+ /**
827
+ * Returned when the model-generated transcription of audio output is updated.
828
+ */
829
+ export interface ResponseAudioTranscriptDeltaEvent {
830
+ /**
831
+ * The index of the content part in the item's content array.
832
+ */
833
+ content_index: number;
834
+ /**
835
+ * The transcript delta.
836
+ */
837
+ delta: string;
838
+ /**
839
+ * The unique ID of the server event.
840
+ */
841
+ event_id: string;
842
+ /**
843
+ * The ID of the item.
844
+ */
845
+ item_id: string;
846
+ /**
847
+ * The index of the output item in the response.
848
+ */
849
+ output_index: number;
850
+ /**
851
+ * The ID of the response.
852
+ */
853
+ response_id: string;
854
+ /**
855
+ * The event type, must be `response.audio_transcript.delta`.
856
+ */
857
+ type: 'response.audio_transcript.delta';
858
+ }
859
+ /**
860
+ * Returned when the model-generated transcription of audio output is done
861
+ * streaming. Also emitted when a Response is interrupted, incomplete, or
862
+ * cancelled.
863
+ */
864
+ export interface ResponseAudioTranscriptDoneEvent {
865
+ /**
866
+ * The index of the content part in the item's content array.
867
+ */
868
+ content_index: number;
869
+ /**
870
+ * The unique ID of the server event.
871
+ */
872
+ event_id: string;
873
+ /**
874
+ * The ID of the item.
875
+ */
876
+ item_id: string;
877
+ /**
878
+ * The index of the output item in the response.
879
+ */
880
+ output_index: number;
881
+ /**
882
+ * The ID of the response.
883
+ */
884
+ response_id: string;
885
+ /**
886
+ * The final transcript of the audio.
887
+ */
888
+ transcript: string;
889
+ /**
890
+ * The event type, must be `response.audio_transcript.done`.
891
+ */
892
+ type: 'response.audio_transcript.done';
893
+ }
894
+ /**
895
+ * Send this event to cancel an in-progress response. The server will respond with
896
+ * a `response.cancelled` event or an error if there is no response to cancel.
897
+ */
898
+ export interface ResponseCancelEvent {
899
+ /**
900
+ * The event type, must be `response.cancel`.
901
+ */
902
+ type: 'response.cancel';
903
+ /**
904
+ * Optional client-generated ID used to identify this event.
905
+ */
906
+ event_id?: string;
907
+ /**
908
+ * A specific response ID to cancel - if not provided, will cancel an in-progress
909
+ * response in the default conversation.
910
+ */
911
+ response_id?: string;
912
+ }
913
+ /**
914
+ * Returned when a new content part is added to an assistant message item during
915
+ * response generation.
916
+ */
917
+ export interface ResponseContentPartAddedEvent {
918
+ /**
919
+ * The index of the content part in the item's content array.
920
+ */
921
+ content_index: number;
922
+ /**
923
+ * The unique ID of the server event.
924
+ */
925
+ event_id: string;
926
+ /**
927
+ * The ID of the item to which the content part was added.
928
+ */
929
+ item_id: string;
930
+ /**
931
+ * The index of the output item in the response.
932
+ */
933
+ output_index: number;
934
+ /**
935
+ * The content part that was added.
936
+ */
937
+ part: ResponseContentPartAddedEvent.Part;
938
+ /**
939
+ * The ID of the response.
940
+ */
941
+ response_id: string;
942
+ /**
943
+ * The event type, must be `response.content_part.added`.
944
+ */
945
+ type: 'response.content_part.added';
946
+ }
947
+ export declare namespace ResponseContentPartAddedEvent {
948
+ /**
949
+ * The content part that was added.
950
+ */
951
+ interface Part {
952
+ /**
953
+ * Base64-encoded audio data (if type is "audio").
954
+ */
955
+ audio?: string;
956
+ /**
957
+ * The text content (if type is "text").
958
+ */
959
+ text?: string;
960
+ /**
961
+ * The transcript of the audio (if type is "audio").
962
+ */
963
+ transcript?: string;
964
+ /**
965
+ * The content type ("text", "audio").
966
+ */
967
+ type?: 'text' | 'audio';
968
+ }
969
+ }
970
+ /**
971
+ * Returned when a content part is done streaming in an assistant message item.
972
+ * Also emitted when a Response is interrupted, incomplete, or cancelled.
973
+ */
974
+ export interface ResponseContentPartDoneEvent {
975
+ /**
976
+ * The index of the content part in the item's content array.
977
+ */
978
+ content_index: number;
979
+ /**
980
+ * The unique ID of the server event.
981
+ */
982
+ event_id: string;
983
+ /**
984
+ * The ID of the item.
985
+ */
986
+ item_id: string;
987
+ /**
988
+ * The index of the output item in the response.
989
+ */
990
+ output_index: number;
991
+ /**
992
+ * The content part that is done.
993
+ */
994
+ part: ResponseContentPartDoneEvent.Part;
995
+ /**
996
+ * The ID of the response.
997
+ */
998
+ response_id: string;
999
+ /**
1000
+ * The event type, must be `response.content_part.done`.
1001
+ */
1002
+ type: 'response.content_part.done';
1003
+ }
1004
+ export declare namespace ResponseContentPartDoneEvent {
1005
+ /**
1006
+ * The content part that is done.
1007
+ */
1008
+ interface Part {
1009
+ /**
1010
+ * Base64-encoded audio data (if type is "audio").
1011
+ */
1012
+ audio?: string;
1013
+ /**
1014
+ * The text content (if type is "text").
1015
+ */
1016
+ text?: string;
1017
+ /**
1018
+ * The transcript of the audio (if type is "audio").
1019
+ */
1020
+ transcript?: string;
1021
+ /**
1022
+ * The content type ("text", "audio").
1023
+ */
1024
+ type?: 'text' | 'audio';
1025
+ }
1026
+ }
1027
+ /**
1028
+ * This event instructs the server to create a Response, which means triggering
1029
+ * model inference. When in Server VAD mode, the server will create Responses
1030
+ * automatically.
1031
+ *
1032
+ * A Response will include at least one Item, and may have two, in which case the
1033
+ * second will be a function call. These Items will be appended to the conversation
1034
+ * history.
1035
+ *
1036
+ * The server will respond with a `response.created` event, events for Items and
1037
+ * content created, and finally a `response.done` event to indicate the Response is
1038
+ * complete.
1039
+ *
1040
+ * The `response.create` event includes inference configuration like
1041
+ * `instructions`, and `temperature`. These fields will override the Session's
1042
+ * configuration for this Response only.
1043
+ */
1044
+ export interface ResponseCreateEvent {
1045
+ /**
1046
+ * The event type, must be `response.create`.
1047
+ */
1048
+ type: 'response.create';
1049
+ /**
1050
+ * Optional client-generated ID used to identify this event.
1051
+ */
1052
+ event_id?: string;
1053
+ /**
1054
+ * Create a new Realtime response with these parameters
1055
+ */
1056
+ response?: ResponseCreateEvent.Response;
1057
+ }
1058
+ export declare namespace ResponseCreateEvent {
1059
+ /**
1060
+ * Create a new Realtime response with these parameters
1061
+ */
1062
+ interface Response {
1063
+ /**
1064
+ * Controls which conversation the response is added to. Currently supports `auto`
1065
+ * and `none`, with `auto` as the default value. The `auto` value means that the
1066
+ * contents of the response will be added to the default conversation. Set this to
1067
+ * `none` to create an out-of-band response which will not add items to default
1068
+ * conversation.
1069
+ */
1070
+ conversation?: (string & {}) | 'auto' | 'none';
1071
+ /**
1072
+ * Input items to include in the prompt for the model. Creates a new context for
1073
+ * this response, without including the default conversation. Can include
1074
+ * references to items from the default conversation.
1075
+ */
1076
+ input?: Array<RealtimeAPI.ConversationItem>;
1077
+ /**
1078
+ * The default system instructions (i.e. system message) prepended to model calls.
1079
+ * This field allows the client to guide the model on desired responses. The model
1080
+ * can be instructed on response content and format, (e.g. "be extremely succinct",
1081
+ * "act friendly", "here are examples of good responses") and on audio behavior
1082
+ * (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
1083
+ * instructions are not guaranteed to be followed by the model, but they provide
1084
+ * guidance to the model on the desired behavior.
1085
+ *
1086
+ * Note that the server sets default instructions which will be used if this field
1087
+ * is not set and are visible in the `session.created` event at the start of the
1088
+ * session.
1089
+ */
1090
+ instructions?: string;
1091
+ /**
1092
+ * Maximum number of output tokens for a single assistant response, inclusive of
1093
+ * tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
1094
+ * `inf` for the maximum available tokens for a given model. Defaults to `inf`.
1095
+ */
1096
+ max_response_output_tokens?: number | 'inf';
1097
+ /**
1098
+ * Set of 16 key-value pairs that can be attached to an object. This can be useful
1099
+ * for storing additional information about the object in a structured format. Keys
1100
+ * can be a maximum of 64 characters long and values can be a maximum of 512
1101
+ * characters long.
1102
+ */
1103
+ metadata?: unknown | null;
1104
+ /**
1105
+ * The set of modalities the model can respond with. To disable audio, set this to
1106
+ * ["text"].
1107
+ */
1108
+ modalities?: Array<'text' | 'audio'>;
1109
+ /**
1110
+ * The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
1111
+ */
1112
+ output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
1113
+ /**
1114
+ * Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
1115
+ */
1116
+ temperature?: number;
1117
+ /**
1118
+ * How the model chooses tools. Options are `auto`, `none`, `required`, or specify
1119
+ * a function, like `{"type": "function", "function": {"name": "my_function"}}`.
1120
+ */
1121
+ tool_choice?: string;
1122
+ /**
1123
+ * Tools (functions) available to the model.
1124
+ */
1125
+ tools?: Array<Response.Tool>;
1126
+ /**
1127
+ * The voice the model uses to respond. Voice cannot be changed during the session
1128
+ * once the model has responded with audio at least once. Current voice options are
1129
+ * `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, `shimmer` and `verse`.
1130
+ */
1131
+ voice?: 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
1132
+ }
1133
+ namespace Response {
1134
+ interface Tool {
1135
+ /**
1136
+ * The description of the function, including guidance on when and how to call it,
1137
+ * and guidance about what to tell the user when calling (if anything).
1138
+ */
1139
+ description?: string;
1140
+ /**
1141
+ * The name of the function.
1142
+ */
1143
+ name?: string;
1144
+ /**
1145
+ * Parameters of the function in JSON Schema.
1146
+ */
1147
+ parameters?: unknown;
1148
+ /**
1149
+ * The type of the tool, i.e. `function`.
1150
+ */
1151
+ type?: 'function';
1152
+ }
1153
+ }
1154
+ }
1155
+ /**
1156
+ * Returned when a new Response is created. The first event of response creation,
1157
+ * where the response is in an initial state of `in_progress`.
1158
+ */
1159
+ export interface ResponseCreatedEvent {
1160
+ /**
1161
+ * The unique ID of the server event.
1162
+ */
1163
+ event_id: string;
1164
+ /**
1165
+ * The response resource.
1166
+ */
1167
+ response: RealtimeResponse;
1168
+ /**
1169
+ * The event type, must be `response.created`.
1170
+ */
1171
+ type: 'response.created';
1172
+ }
1173
+ /**
1174
+ * Returned when a Response is done streaming. Always emitted, no matter the final
1175
+ * state. The Response object included in the `response.done` event will include
1176
+ * all output Items in the Response but will omit the raw audio data.
1177
+ */
1178
+ export interface ResponseDoneEvent {
1179
+ /**
1180
+ * The unique ID of the server event.
1181
+ */
1182
+ event_id: string;
1183
+ /**
1184
+ * The response resource.
1185
+ */
1186
+ response: RealtimeResponse;
1187
+ /**
1188
+ * The event type, must be `response.done`.
1189
+ */
1190
+ type: 'response.done';
1191
+ }
1192
+ /**
1193
+ * Returned when the model-generated function call arguments are updated.
1194
+ */
1195
+ export interface ResponseFunctionCallArgumentsDeltaEvent {
1196
+ /**
1197
+ * The ID of the function call.
1198
+ */
1199
+ call_id: string;
1200
+ /**
1201
+ * The arguments delta as a JSON string.
1202
+ */
1203
+ delta: string;
1204
+ /**
1205
+ * The unique ID of the server event.
1206
+ */
1207
+ event_id: string;
1208
+ /**
1209
+ * The ID of the function call item.
1210
+ */
1211
+ item_id: string;
1212
+ /**
1213
+ * The index of the output item in the response.
1214
+ */
1215
+ output_index: number;
1216
+ /**
1217
+ * The ID of the response.
1218
+ */
1219
+ response_id: string;
1220
+ /**
1221
+ * The event type, must be `response.function_call_arguments.delta`.
1222
+ */
1223
+ type: 'response.function_call_arguments.delta';
1224
+ }
1225
+ /**
1226
+ * Returned when the model-generated function call arguments are done streaming.
1227
+ * Also emitted when a Response is interrupted, incomplete, or cancelled.
1228
+ */
1229
+ export interface ResponseFunctionCallArgumentsDoneEvent {
1230
+ /**
1231
+ * The final arguments as a JSON string.
1232
+ */
1233
+ arguments: string;
1234
+ /**
1235
+ * The ID of the function call.
1236
+ */
1237
+ call_id: string;
1238
+ /**
1239
+ * The unique ID of the server event.
1240
+ */
1241
+ event_id: string;
1242
+ /**
1243
+ * The ID of the function call item.
1244
+ */
1245
+ item_id: string;
1246
+ /**
1247
+ * The index of the output item in the response.
1248
+ */
1249
+ output_index: number;
1250
+ /**
1251
+ * The ID of the response.
1252
+ */
1253
+ response_id: string;
1254
+ /**
1255
+ * The event type, must be `response.function_call_arguments.done`.
1256
+ */
1257
+ type: 'response.function_call_arguments.done';
1258
+ }
1259
+ /**
1260
+ * Returned when a new Item is created during Response generation.
1261
+ */
1262
+ export interface ResponseOutputItemAddedEvent {
1263
+ /**
1264
+ * The unique ID of the server event.
1265
+ */
1266
+ event_id: string;
1267
+ /**
1268
+ * The item to add to the conversation.
1269
+ */
1270
+ item: ConversationItem;
1271
+ /**
1272
+ * The index of the output item in the Response.
1273
+ */
1274
+ output_index: number;
1275
+ /**
1276
+ * The ID of the Response to which the item belongs.
1277
+ */
1278
+ response_id: string;
1279
+ /**
1280
+ * The event type, must be `response.output_item.added`.
1281
+ */
1282
+ type: 'response.output_item.added';
1283
+ }
1284
+ /**
1285
+ * Returned when an Item is done streaming. Also emitted when a Response is
1286
+ * interrupted, incomplete, or cancelled.
1287
+ */
1288
+ export interface ResponseOutputItemDoneEvent {
1289
+ /**
1290
+ * The unique ID of the server event.
1291
+ */
1292
+ event_id: string;
1293
+ /**
1294
+ * The item to add to the conversation.
1295
+ */
1296
+ item: ConversationItem;
1297
+ /**
1298
+ * The index of the output item in the Response.
1299
+ */
1300
+ output_index: number;
1301
+ /**
1302
+ * The ID of the Response to which the item belongs.
1303
+ */
1304
+ response_id: string;
1305
+ /**
1306
+ * The event type, must be `response.output_item.done`.
1307
+ */
1308
+ type: 'response.output_item.done';
1309
+ }
1310
+ /**
1311
+ * Returned when the text value of a "text" content part is updated.
1312
+ */
1313
+ export interface ResponseTextDeltaEvent {
1314
+ /**
1315
+ * The index of the content part in the item's content array.
1316
+ */
1317
+ content_index: number;
1318
+ /**
1319
+ * The text delta.
1320
+ */
1321
+ delta: string;
1322
+ /**
1323
+ * The unique ID of the server event.
1324
+ */
1325
+ event_id: string;
1326
+ /**
1327
+ * The ID of the item.
1328
+ */
1329
+ item_id: string;
1330
+ /**
1331
+ * The index of the output item in the response.
1332
+ */
1333
+ output_index: number;
1334
+ /**
1335
+ * The ID of the response.
1336
+ */
1337
+ response_id: string;
1338
+ /**
1339
+ * The event type, must be `response.text.delta`.
1340
+ */
1341
+ type: 'response.text.delta';
1342
+ }
1343
+ /**
1344
+ * Returned when the text value of a "text" content part is done streaming. Also
1345
+ * emitted when a Response is interrupted, incomplete, or cancelled.
1346
+ */
1347
+ export interface ResponseTextDoneEvent {
1348
+ /**
1349
+ * The index of the content part in the item's content array.
1350
+ */
1351
+ content_index: number;
1352
+ /**
1353
+ * The unique ID of the server event.
1354
+ */
1355
+ event_id: string;
1356
+ /**
1357
+ * The ID of the item.
1358
+ */
1359
+ item_id: string;
1360
+ /**
1361
+ * The index of the output item in the response.
1362
+ */
1363
+ output_index: number;
1364
+ /**
1365
+ * The ID of the response.
1366
+ */
1367
+ response_id: string;
1368
+ /**
1369
+ * The final text content.
1370
+ */
1371
+ text: string;
1372
+ /**
1373
+ * The event type, must be `response.text.done`.
1374
+ */
1375
+ type: 'response.text.done';
1376
+ }
1377
+ /**
1378
+ * Returned when a Session is created. Emitted automatically when a new connection
1379
+ * is established as the first server event. This event will contain the default
1380
+ * Session configuration.
1381
+ */
1382
+ export interface SessionCreatedEvent {
1383
+ /**
1384
+ * The unique ID of the server event.
1385
+ */
1386
+ event_id: string;
1387
+ /**
1388
+ * Realtime session object configuration.
1389
+ */
1390
+ session: SessionsAPI.Session;
1391
+ /**
1392
+ * The event type, must be `session.created`.
1393
+ */
1394
+ type: 'session.created';
1395
+ }
1396
+ /**
1397
+ * Send this event to update the session’s default configuration. The client may
1398
+ * send this event at any time to update the session configuration, and any field
1399
+ * may be updated at any time, except for "voice". The server will respond with a
1400
+ * `session.updated` event that shows the full effective configuration. Only fields
1401
+ * that are present are updated, thus the correct way to clear a field like
1402
+ * "instructions" is to pass an empty string.
1403
+ */
1404
+ export interface SessionUpdateEvent {
1405
+ /**
1406
+ * Realtime session object configuration.
1407
+ */
1408
+ session: SessionUpdateEvent.Session;
1409
+ /**
1410
+ * The event type, must be `session.update`.
1411
+ */
1412
+ type: 'session.update';
1413
+ /**
1414
+ * Optional client-generated ID used to identify this event.
1415
+ */
1416
+ event_id?: string;
1417
+ }
1418
+ export declare namespace SessionUpdateEvent {
1419
+ /**
1420
+ * Realtime session object configuration.
1421
+ */
1422
+ interface Session {
1423
+ /**
1424
+ * The Realtime model used for this session.
1425
+ */
1426
+ model: 'gpt-4o-realtime-preview' | 'gpt-4o-realtime-preview-2024-10-01' | 'gpt-4o-realtime-preview-2024-12-17' | 'gpt-4o-mini-realtime-preview' | 'gpt-4o-mini-realtime-preview-2024-12-17';
1427
+ /**
1428
+ * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
1429
+ */
1430
+ input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
1431
+ /**
1432
+ * Configuration for input audio transcription, defaults to off and can be set to
1433
+ * `null` to turn off once on. Input audio transcription is not native to the
1434
+ * model, since the model consumes audio directly. Transcription runs
1435
+ * asynchronously through Whisper and should be treated as rough guidance rather
1436
+ * than the representation understood by the model.
1437
+ */
1438
+ input_audio_transcription?: Session.InputAudioTranscription;
1439
+ /**
1440
+ * The default system instructions (i.e. system message) prepended to model calls.
1441
+ * This field allows the client to guide the model on desired responses. The model
1442
+ * can be instructed on response content and format, (e.g. "be extremely succinct",
1443
+ * "act friendly", "here are examples of good responses") and on audio behavior
1444
+ * (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
1445
+ * instructions are not guaranteed to be followed by the model, but they provide
1446
+ * guidance to the model on the desired behavior.
1447
+ *
1448
+ * Note that the server sets default instructions which will be used if this field
1449
+ * is not set and are visible in the `session.created` event at the start of the
1450
+ * session.
1451
+ */
1452
+ instructions?: string;
1453
+ /**
1454
+ * Maximum number of output tokens for a single assistant response, inclusive of
1455
+ * tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
1456
+ * `inf` for the maximum available tokens for a given model. Defaults to `inf`.
1457
+ */
1458
+ max_response_output_tokens?: number | 'inf';
1459
+ /**
1460
+ * The set of modalities the model can respond with. To disable audio, set this to
1461
+ * ["text"].
1462
+ */
1463
+ modalities?: Array<'text' | 'audio'>;
1464
+ /**
1465
+ * The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
1466
+ */
1467
+ output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
1468
+ /**
1469
+ * Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
1470
+ */
1471
+ temperature?: number;
1472
+ /**
1473
+ * How the model chooses tools. Options are `auto`, `none`, `required`, or specify
1474
+ * a function.
1475
+ */
1476
+ tool_choice?: string;
1477
+ /**
1478
+ * Tools (functions) available to the model.
1479
+ */
1480
+ tools?: Array<Session.Tool>;
1481
+ /**
1482
+ * Configuration for turn detection. Can be set to `null` to turn off. Server VAD
1483
+ * means that the model will detect the start and end of speech based on audio
1484
+ * volume and respond at the end of user speech.
1485
+ */
1486
+ turn_detection?: Session.TurnDetection;
1487
+ /**
1488
+ * The voice the model uses to respond. Voice cannot be changed during the session
1489
+ * once the model has responded with audio at least once. Current voice options are
1490
+ * `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, `shimmer` and `verse`.
1491
+ */
1492
+ voice?: 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
1493
+ }
1494
+ namespace Session {
1495
+ /**
1496
+ * Configuration for input audio transcription, defaults to off and can be set to
1497
+ * `null` to turn off once on. Input audio transcription is not native to the
1498
+ * model, since the model consumes audio directly. Transcription runs
1499
+ * asynchronously through Whisper and should be treated as rough guidance rather
1500
+ * than the representation understood by the model.
1501
+ */
1502
+ interface InputAudioTranscription {
1503
+ /**
1504
+ * The model to use for transcription, `whisper-1` is the only currently supported
1505
+ * model.
1506
+ */
1507
+ model?: string;
1508
+ }
1509
+ interface Tool {
1510
+ /**
1511
+ * The description of the function, including guidance on when and how to call it,
1512
+ * and guidance about what to tell the user when calling (if anything).
1513
+ */
1514
+ description?: string;
1515
+ /**
1516
+ * The name of the function.
1517
+ */
1518
+ name?: string;
1519
+ /**
1520
+ * Parameters of the function in JSON Schema.
1521
+ */
1522
+ parameters?: unknown;
1523
+ /**
1524
+ * The type of the tool, i.e. `function`.
1525
+ */
1526
+ type?: 'function';
1527
+ }
1528
+ /**
1529
+ * Configuration for turn detection. Can be set to `null` to turn off. Server VAD
1530
+ * means that the model will detect the start and end of speech based on audio
1531
+ * volume and respond at the end of user speech.
1532
+ */
1533
+ interface TurnDetection {
1534
+ /**
1535
+ * Whether or not to automatically generate a response when VAD is enabled. `true`
1536
+ * by default.
1537
+ */
1538
+ create_response?: boolean;
1539
+ /**
1540
+ * Amount of audio to include before the VAD detected speech (in milliseconds).
1541
+ * Defaults to 300ms.
1542
+ */
1543
+ prefix_padding_ms?: number;
1544
+ /**
1545
+ * Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms.
1546
+ * With shorter values the model will respond more quickly, but may jump in on
1547
+ * short pauses from the user.
1548
+ */
1549
+ silence_duration_ms?: number;
1550
+ /**
1551
+ * Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher
1552
+ * threshold will require louder audio to activate the model, and thus might
1553
+ * perform better in noisy environments.
1554
+ */
1555
+ threshold?: number;
1556
+ /**
1557
+ * Type of turn detection, only `server_vad` is currently supported.
1558
+ */
1559
+ type?: string;
1560
+ }
1561
+ }
1562
+ }
1563
+ /**
1564
+ * Returned when a session is updated with a `session.update` event, unless there
1565
+ * is an error.
1566
+ */
1567
+ export interface SessionUpdatedEvent {
1568
+ /**
1569
+ * The unique ID of the server event.
1570
+ */
1571
+ event_id: string;
1572
+ /**
1573
+ * Realtime session object configuration.
1574
+ */
1575
+ session: SessionsAPI.Session;
1576
+ /**
1577
+ * The event type, must be `session.updated`.
1578
+ */
1579
+ type: 'session.updated';
1580
+ }
1581
+ export declare namespace Realtime {
1582
+ export { Sessions as Sessions, type SessionsAPISession as Session, type SessionCreateResponse as SessionCreateResponse, type SessionCreateParams as SessionCreateParams, };
1583
+ }
1584
+ //# sourceMappingURL=realtime.d.ts.map