openai 4.87.4 → 4.89.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 (80) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/helpers/audio.d.ts +12 -0
  3. package/helpers/audio.d.ts.map +1 -0
  4. package/helpers/audio.js +121 -0
  5. package/helpers/audio.js.map +1 -0
  6. package/helpers/audio.mjs +116 -0
  7. package/helpers/audio.mjs.map +1 -0
  8. package/index.d.mts +2 -0
  9. package/index.d.ts +2 -0
  10. package/index.d.ts.map +1 -1
  11. package/index.js.map +1 -1
  12. package/index.mjs.map +1 -1
  13. package/package.json +8 -29
  14. package/resources/audio/audio.d.ts +5 -4
  15. package/resources/audio/audio.d.ts.map +1 -1
  16. package/resources/audio/audio.js.map +1 -1
  17. package/resources/audio/audio.mjs.map +1 -1
  18. package/resources/audio/index.d.ts +1 -1
  19. package/resources/audio/index.d.ts.map +1 -1
  20. package/resources/audio/index.js.map +1 -1
  21. package/resources/audio/index.mjs.map +1 -1
  22. package/resources/audio/speech.d.ts +7 -2
  23. package/resources/audio/speech.d.ts.map +1 -1
  24. package/resources/audio/transcriptions.d.ts +172 -9
  25. package/resources/audio/transcriptions.d.ts.map +1 -1
  26. package/resources/audio/transcriptions.js.map +1 -1
  27. package/resources/audio/transcriptions.mjs.map +1 -1
  28. package/resources/audio/translations.d.ts +1 -1
  29. package/resources/audio/translations.d.ts.map +1 -1
  30. package/resources/beta/realtime/index.d.ts +1 -0
  31. package/resources/beta/realtime/index.d.ts.map +1 -1
  32. package/resources/beta/realtime/index.js +3 -1
  33. package/resources/beta/realtime/index.js.map +1 -1
  34. package/resources/beta/realtime/index.mjs +1 -0
  35. package/resources/beta/realtime/index.mjs.map +1 -1
  36. package/resources/beta/realtime/realtime.d.ts +383 -36
  37. package/resources/beta/realtime/realtime.d.ts.map +1 -1
  38. package/resources/beta/realtime/realtime.js +4 -0
  39. package/resources/beta/realtime/realtime.js.map +1 -1
  40. package/resources/beta/realtime/realtime.mjs +4 -0
  41. package/resources/beta/realtime/realtime.mjs.map +1 -1
  42. package/resources/beta/realtime/sessions.d.ts +169 -60
  43. package/resources/beta/realtime/sessions.d.ts.map +1 -1
  44. package/resources/beta/realtime/transcription-sessions.d.ts +262 -0
  45. package/resources/beta/realtime/transcription-sessions.d.ts.map +1 -0
  46. package/resources/beta/realtime/transcription-sessions.js +25 -0
  47. package/resources/beta/realtime/transcription-sessions.js.map +1 -0
  48. package/resources/beta/realtime/transcription-sessions.mjs +21 -0
  49. package/resources/beta/realtime/transcription-sessions.mjs.map +1 -0
  50. package/resources/chat/completions/completions.d.ts +1 -1
  51. package/resources/chat/completions/completions.d.ts.map +1 -1
  52. package/resources/responses/responses.d.ts +3 -3
  53. package/resources/responses/responses.d.ts.map +1 -1
  54. package/resources/shared.d.ts +3 -1
  55. package/resources/shared.d.ts.map +1 -1
  56. package/resources.d.ts +2 -0
  57. package/resources.d.ts.map +1 -0
  58. package/resources.js +18 -0
  59. package/resources.js.map +1 -0
  60. package/resources.mjs +2 -0
  61. package/resources.mjs.map +1 -0
  62. package/src/helpers/audio.ts +145 -0
  63. package/src/index.ts +2 -0
  64. package/src/resources/audio/audio.ts +15 -2
  65. package/src/resources/audio/index.ts +6 -0
  66. package/src/resources/audio/speech.ts +8 -2
  67. package/src/resources/audio/transcriptions.ts +215 -9
  68. package/src/resources/audio/translations.ts +1 -1
  69. package/src/resources/beta/realtime/index.ts +5 -0
  70. package/src/resources/beta/realtime/realtime.ts +465 -57
  71. package/src/resources/beta/realtime/sessions.ts +176 -60
  72. package/src/resources/beta/realtime/transcription-sessions.ts +308 -0
  73. package/src/resources/chat/completions/completions.ts +1 -1
  74. package/src/resources/responses/responses.ts +3 -3
  75. package/src/resources/shared.ts +22 -5
  76. package/src/resources.ts +1 -0
  77. package/src/version.ts +1 -1
  78. package/version.d.ts +1 -1
  79. package/version.js +1 -1
  80. package/version.mjs +1 -1
@@ -0,0 +1,145 @@
1
+ import { File } from 'formdata-node';
2
+ import { spawn } from 'node:child_process';
3
+ import { Readable } from 'node:stream';
4
+ import { platform, versions } from 'node:process';
5
+ import { Response } from "../_shims";
6
+
7
+ const DEFAULT_SAMPLE_RATE = 24000;
8
+ const DEFAULT_CHANNELS = 1;
9
+
10
+ const isNode = Boolean(versions?.node);
11
+
12
+ const recordingProviders: Record<NodeJS.Platform, string> = {
13
+ win32: 'dshow',
14
+ darwin: 'avfoundation',
15
+ linux: 'alsa',
16
+ aix: 'alsa',
17
+ android: 'alsa',
18
+ freebsd: 'alsa',
19
+ haiku: 'alsa',
20
+ sunos: 'alsa',
21
+ netbsd: 'alsa',
22
+ openbsd: 'alsa',
23
+ cygwin: 'dshow',
24
+ };
25
+
26
+ function isResponse(stream: NodeJS.ReadableStream | Response | File): stream is Response {
27
+ return typeof (stream as any).body !== 'undefined';
28
+ }
29
+
30
+ function isFile(stream: NodeJS.ReadableStream | Response | File): stream is File {
31
+ return stream instanceof File;
32
+ }
33
+
34
+ async function nodejsPlayAudio(stream: NodeJS.ReadableStream | Response | File): Promise<void> {
35
+ return new Promise((resolve, reject) => {
36
+ try {
37
+ const ffplay = spawn('ffplay', ['-autoexit', '-nodisp', '-i', 'pipe:0']);
38
+
39
+ if (isResponse(stream)) {
40
+ stream.body.pipe(ffplay.stdin);
41
+ } else if (isFile(stream)) {
42
+ Readable.from(stream.stream()).pipe(ffplay.stdin);
43
+ } else {
44
+ stream.pipe(ffplay.stdin);
45
+ }
46
+
47
+ ffplay.on('close', (code: number) => {
48
+ if (code !== 0) {
49
+ reject(new Error(`ffplay process exited with code ${code}`));
50
+ }
51
+ resolve();
52
+ });
53
+ } catch (error) {
54
+ reject(error);
55
+ }
56
+ });
57
+ }
58
+
59
+ export async function playAudio(input: NodeJS.ReadableStream | Response | File): Promise<void> {
60
+ if (isNode) {
61
+ return nodejsPlayAudio(input);
62
+ }
63
+
64
+ throw new Error(
65
+ 'Play audio is not supported in the browser yet. Check out https://npm.im/wavtools as an alternative.',
66
+ );
67
+ }
68
+
69
+ type RecordAudioOptions = {
70
+ signal?: AbortSignal;
71
+ device?: number;
72
+ timeout?: number;
73
+ };
74
+
75
+ function nodejsRecordAudio({ signal, device, timeout }: RecordAudioOptions = {}): Promise<File> {
76
+ return new Promise((resolve, reject) => {
77
+ const data: any[] = [];
78
+ const provider = recordingProviders[platform];
79
+ try {
80
+ const ffmpeg = spawn(
81
+ 'ffmpeg',
82
+ [
83
+ '-f',
84
+ provider,
85
+ '-i',
86
+ `:${device ?? 0}`, // default audio input device; adjust as needed
87
+ '-ar',
88
+ DEFAULT_SAMPLE_RATE.toString(),
89
+ '-ac',
90
+ DEFAULT_CHANNELS.toString(),
91
+ '-f',
92
+ 'wav',
93
+ 'pipe:1',
94
+ ],
95
+ {
96
+ stdio: ['ignore', 'pipe', 'pipe'],
97
+ },
98
+ );
99
+
100
+ ffmpeg.stdout.on('data', (chunk) => {
101
+ data.push(chunk);
102
+ });
103
+
104
+ ffmpeg.on('error', (error) => {
105
+ console.error(error);
106
+ reject(error);
107
+ });
108
+
109
+ ffmpeg.on('close', (code) => {
110
+ returnData();
111
+ });
112
+
113
+ function returnData() {
114
+ const audioBuffer = Buffer.concat(data);
115
+ const audioFile = new File([audioBuffer], 'audio.wav', { type: 'audio/wav' });
116
+ resolve(audioFile);
117
+ }
118
+
119
+ if (typeof timeout === 'number' && timeout > 0) {
120
+ const internalSignal = AbortSignal.timeout(timeout);
121
+ internalSignal.addEventListener('abort', () => {
122
+ ffmpeg.kill('SIGTERM');
123
+ });
124
+ }
125
+
126
+ if (signal) {
127
+ signal.addEventListener('abort', () => {
128
+ ffmpeg.kill('SIGTERM');
129
+ });
130
+ }
131
+ } catch (error) {
132
+ reject(error);
133
+ }
134
+ });
135
+ }
136
+
137
+ export async function recordAudio(options: RecordAudioOptions = {}) {
138
+ if (isNode) {
139
+ return nodejsRecordAudio(options);
140
+ }
141
+
142
+ throw new Error(
143
+ 'Record audio is not supported in the browser. Check out https://npm.im/wavtools as an alternative.',
144
+ );
145
+ }
package/src/index.ts CHANGED
@@ -508,6 +508,7 @@ export declare namespace OpenAI {
508
508
 
509
509
  export { Responses as Responses };
510
510
 
511
+ export type AllModels = API.AllModels;
511
512
  export type ChatModel = API.ChatModel;
512
513
  export type ComparisonFilter = API.ComparisonFilter;
513
514
  export type CompoundFilter = API.CompoundFilter;
@@ -520,6 +521,7 @@ export declare namespace OpenAI {
520
521
  export type ResponseFormatJSONObject = API.ResponseFormatJSONObject;
521
522
  export type ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
522
523
  export type ResponseFormatText = API.ResponseFormatText;
524
+ export type ResponsesModel = API.ResponsesModel;
523
525
  }
524
526
 
525
527
  // ---------------------- Azure ----------------------
@@ -7,8 +7,14 @@ import * as TranscriptionsAPI from './transcriptions';
7
7
  import {
8
8
  Transcription,
9
9
  TranscriptionCreateParams,
10
+ TranscriptionCreateParamsNonStreaming,
11
+ TranscriptionCreateParamsStreaming,
10
12
  TranscriptionCreateResponse,
13
+ TranscriptionInclude,
11
14
  TranscriptionSegment,
15
+ TranscriptionStreamEvent,
16
+ TranscriptionTextDeltaEvent,
17
+ TranscriptionTextDoneEvent,
12
18
  TranscriptionVerbose,
13
19
  TranscriptionWord,
14
20
  Transcriptions,
@@ -28,11 +34,12 @@ export class Audio extends APIResource {
28
34
  speech: SpeechAPI.Speech = new SpeechAPI.Speech(this._client);
29
35
  }
30
36
 
31
- export type AudioModel = 'whisper-1';
37
+ export type AudioModel = 'whisper-1' | 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe';
32
38
 
33
39
  /**
34
40
  * The format of the output, in one of these options: `json`, `text`, `srt`,
35
- * `verbose_json`, or `vtt`.
41
+ * `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
42
+ * the only supported format is `json`.
36
43
  */
37
44
  export type AudioResponseFormat = 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
38
45
 
@@ -46,11 +53,17 @@ export declare namespace Audio {
46
53
  export {
47
54
  Transcriptions as Transcriptions,
48
55
  type Transcription as Transcription,
56
+ type TranscriptionInclude as TranscriptionInclude,
49
57
  type TranscriptionSegment as TranscriptionSegment,
58
+ type TranscriptionStreamEvent as TranscriptionStreamEvent,
59
+ type TranscriptionTextDeltaEvent as TranscriptionTextDeltaEvent,
60
+ type TranscriptionTextDoneEvent as TranscriptionTextDoneEvent,
50
61
  type TranscriptionVerbose as TranscriptionVerbose,
51
62
  type TranscriptionWord as TranscriptionWord,
52
63
  type TranscriptionCreateResponse as TranscriptionCreateResponse,
53
64
  type TranscriptionCreateParams as TranscriptionCreateParams,
65
+ type TranscriptionCreateParamsNonStreaming as TranscriptionCreateParamsNonStreaming,
66
+ type TranscriptionCreateParamsStreaming as TranscriptionCreateParamsStreaming,
54
67
  };
55
68
 
56
69
  export {
@@ -5,11 +5,17 @@ export { Speech, type SpeechModel, type SpeechCreateParams } from './speech';
5
5
  export {
6
6
  Transcriptions,
7
7
  type Transcription,
8
+ type TranscriptionInclude,
8
9
  type TranscriptionSegment,
10
+ type TranscriptionStreamEvent,
11
+ type TranscriptionTextDeltaEvent,
12
+ type TranscriptionTextDoneEvent,
9
13
  type TranscriptionVerbose,
10
14
  type TranscriptionWord,
11
15
  type TranscriptionCreateResponse,
12
16
  type TranscriptionCreateParams,
17
+ type TranscriptionCreateParamsNonStreaming,
18
+ type TranscriptionCreateParamsStreaming,
13
19
  } from './transcriptions';
14
20
  export {
15
21
  Translations,
@@ -18,7 +18,7 @@ export class Speech extends APIResource {
18
18
  }
19
19
  }
20
20
 
21
- export type SpeechModel = 'tts-1' | 'tts-1-hd';
21
+ export type SpeechModel = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts';
22
22
 
23
23
  export interface SpeechCreateParams {
24
24
  /**
@@ -28,7 +28,7 @@ export interface SpeechCreateParams {
28
28
 
29
29
  /**
30
30
  * One of the available [TTS models](https://platform.openai.com/docs/models#tts):
31
- * `tts-1` or `tts-1-hd`
31
+ * `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
32
32
  */
33
33
  model: (string & {}) | SpeechModel;
34
34
 
@@ -40,6 +40,12 @@ export interface SpeechCreateParams {
40
40
  */
41
41
  voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';
42
42
 
43
+ /**
44
+ * Control the voice of your generated audio with additional instructions. Does not
45
+ * work with `tts-1` or `tts-1-hd`.
46
+ */
47
+ instructions?: string;
48
+
43
49
  /**
44
50
  * The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
45
51
  * `wav`, and `pcm`.
@@ -2,29 +2,42 @@
2
2
 
3
3
  import { APIResource } from '../../resource';
4
4
  import * as Core from '../../core';
5
+ import * as TranscriptionsAPI from './transcriptions';
5
6
  import * as AudioAPI from './audio';
7
+ import { Stream } from '../../streaming';
6
8
 
7
9
  export class Transcriptions extends APIResource {
8
10
  /**
9
11
  * Transcribes audio into the input language.
10
12
  */
11
13
  create(
12
- body: TranscriptionCreateParams<'json' | undefined>,
14
+ body: TranscriptionCreateParamsNonStreaming<'json' | undefined>,
13
15
  options?: Core.RequestOptions,
14
16
  ): Core.APIPromise<Transcription>;
15
17
  create(
16
- body: TranscriptionCreateParams<'verbose_json'>,
18
+ body: TranscriptionCreateParamsNonStreaming<'verbose_json'>,
17
19
  options?: Core.RequestOptions,
18
20
  ): Core.APIPromise<TranscriptionVerbose>;
19
21
  create(
20
- body: TranscriptionCreateParams<'srt' | 'vtt' | 'text'>,
22
+ body: TranscriptionCreateParamsNonStreaming<'srt' | 'vtt' | 'text'>,
21
23
  options?: Core.RequestOptions,
22
24
  ): Core.APIPromise<string>;
23
- create(body: TranscriptionCreateParams, options?: Core.RequestOptions): Core.APIPromise<Transcription>;
25
+ create(
26
+ body: TranscriptionCreateParamsNonStreaming,
27
+ options?: Core.RequestOptions,
28
+ ): Core.APIPromise<Transcription>;
29
+ create(
30
+ body: TranscriptionCreateParamsStreaming,
31
+ options?: Core.RequestOptions,
32
+ ): Core.APIPromise<Stream<TranscriptionStreamEvent>>;
33
+ create(
34
+ body: TranscriptionCreateParamsStreaming,
35
+ options?: Core.RequestOptions,
36
+ ): Core.APIPromise<TranscriptionCreateResponse | string | Stream<TranscriptionStreamEvent>>;
24
37
  create(
25
38
  body: TranscriptionCreateParams,
26
39
  options?: Core.RequestOptions,
27
- ): Core.APIPromise<TranscriptionCreateResponse | string> {
40
+ ): Core.APIPromise<TranscriptionCreateResponse | string | Stream<TranscriptionStreamEvent>> {
28
41
  return this._client.post(
29
42
  '/audio/transcriptions',
30
43
  Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
@@ -41,8 +54,36 @@ export interface Transcription {
41
54
  * The transcribed text.
42
55
  */
43
56
  text: string;
57
+
58
+ /**
59
+ * The log probabilities of the tokens in the transcription. Only returned with the
60
+ * models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added
61
+ * to the `include` array.
62
+ */
63
+ logprobs?: Array<Transcription.Logprob>;
44
64
  }
45
65
 
66
+ export namespace Transcription {
67
+ export interface Logprob {
68
+ /**
69
+ * The token in the transcription.
70
+ */
71
+ token?: string;
72
+
73
+ /**
74
+ * The bytes of the token.
75
+ */
76
+ bytes?: Array<number>;
77
+
78
+ /**
79
+ * The log probability of the token.
80
+ */
81
+ logprob?: number;
82
+ }
83
+ }
84
+
85
+ export type TranscriptionInclude = 'logprobs';
86
+
46
87
  export interface TranscriptionSegment {
47
88
  /**
48
89
  * Unique identifier of the segment.
@@ -98,6 +139,103 @@ export interface TranscriptionSegment {
98
139
  tokens: Array<number>;
99
140
  }
100
141
 
142
+ /**
143
+ * Emitted when there is an additional text delta. This is also the first event
144
+ * emitted when the transcription starts. Only emitted when you
145
+ * [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
146
+ * with the `Stream` parameter set to `true`.
147
+ */
148
+ export type TranscriptionStreamEvent = TranscriptionTextDeltaEvent | TranscriptionTextDoneEvent;
149
+
150
+ /**
151
+ * Emitted when there is an additional text delta. This is also the first event
152
+ * emitted when the transcription starts. Only emitted when you
153
+ * [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
154
+ * with the `Stream` parameter set to `true`.
155
+ */
156
+ export interface TranscriptionTextDeltaEvent {
157
+ /**
158
+ * The text delta that was additionally transcribed.
159
+ */
160
+ delta: string;
161
+
162
+ /**
163
+ * The type of the event. Always `transcript.text.delta`.
164
+ */
165
+ type: 'transcript.text.delta';
166
+
167
+ /**
168
+ * The log probabilities of the delta. Only included if you
169
+ * [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
170
+ * with the `include[]` parameter set to `logprobs`.
171
+ */
172
+ logprobs?: Array<TranscriptionTextDeltaEvent.Logprob>;
173
+ }
174
+
175
+ export namespace TranscriptionTextDeltaEvent {
176
+ export interface Logprob {
177
+ /**
178
+ * The token that was used to generate the log probability.
179
+ */
180
+ token?: string;
181
+
182
+ /**
183
+ * The bytes that were used to generate the log probability.
184
+ */
185
+ bytes?: Array<unknown>;
186
+
187
+ /**
188
+ * The log probability of the token.
189
+ */
190
+ logprob?: number;
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Emitted when the transcription is complete. Contains the complete transcription
196
+ * text. Only emitted when you
197
+ * [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
198
+ * with the `Stream` parameter set to `true`.
199
+ */
200
+ export interface TranscriptionTextDoneEvent {
201
+ /**
202
+ * The text that was transcribed.
203
+ */
204
+ text: string;
205
+
206
+ /**
207
+ * The type of the event. Always `transcript.text.done`.
208
+ */
209
+ type: 'transcript.text.done';
210
+
211
+ /**
212
+ * The log probabilities of the individual tokens in the transcription. Only
213
+ * included if you
214
+ * [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
215
+ * with the `include[]` parameter set to `logprobs`.
216
+ */
217
+ logprobs?: Array<TranscriptionTextDoneEvent.Logprob>;
218
+ }
219
+
220
+ export namespace TranscriptionTextDoneEvent {
221
+ export interface Logprob {
222
+ /**
223
+ * The token that was used to generate the log probability.
224
+ */
225
+ token?: string;
226
+
227
+ /**
228
+ * The bytes that were used to generate the log probability.
229
+ */
230
+ bytes?: Array<unknown>;
231
+
232
+ /**
233
+ * The log probability of the token.
234
+ */
235
+ logprob?: number;
236
+ }
237
+ }
238
+
101
239
  /**
102
240
  * Represents a verbose json transcription response returned by model, based on the
103
241
  * provided input.
@@ -152,7 +290,11 @@ export interface TranscriptionWord {
152
290
  */
153
291
  export type TranscriptionCreateResponse = Transcription | TranscriptionVerbose;
154
292
 
155
- export interface TranscriptionCreateParams<
293
+ export type TranscriptionCreateParams<
294
+ ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
295
+ > = TranscriptionCreateParamsNonStreaming<ResponseFormat> | TranscriptionCreateParamsStreaming;
296
+
297
+ export interface TranscriptionCreateParamsBase<
156
298
  ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
157
299
  > {
158
300
  /**
@@ -162,11 +304,21 @@ export interface TranscriptionCreateParams<
162
304
  file: Core.Uploadable;
163
305
 
164
306
  /**
165
- * ID of the model to use. Only `whisper-1` (which is powered by our open source
166
- * Whisper V2 model) is currently available.
307
+ * ID of the model to use. The options are `gpt-4o-transcribe`,
308
+ * `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
309
+ * Whisper V2 model).
167
310
  */
168
311
  model: (string & {}) | AudioAPI.AudioModel;
169
312
 
313
+ /**
314
+ * Additional information to include in the transcription response. `logprobs` will
315
+ * return the log probabilities of the tokens in the response to understand the
316
+ * model's confidence in the transcription. `logprobs` only works with
317
+ * response_format set to `json` and only with the models `gpt-4o-transcribe` and
318
+ * `gpt-4o-mini-transcribe`.
319
+ */
320
+ include?: Array<TranscriptionInclude>;
321
+
170
322
  /**
171
323
  * The language of the input audio. Supplying the input language in
172
324
  * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
@@ -184,10 +336,23 @@ export interface TranscriptionCreateParams<
184
336
 
185
337
  /**
186
338
  * The format of the output, in one of these options: `json`, `text`, `srt`,
187
- * `verbose_json`, or `vtt`.
339
+ * `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
340
+ * the only supported format is `json`.
188
341
  */
189
342
  response_format?: ResponseFormat;
190
343
 
344
+ /**
345
+ * If set to true, the model response data will be streamed to the client as it is
346
+ * generated using
347
+ * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
348
+ * See the
349
+ * [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)
350
+ * for more information.
351
+ *
352
+ * Note: Streaming is not supported for the `whisper-1` model and will be ignored.
353
+ */
354
+ stream?: boolean | null;
355
+
191
356
  /**
192
357
  * The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
193
358
  * output more random, while lower values like 0.2 will make it more focused and
@@ -207,13 +372,54 @@ export interface TranscriptionCreateParams<
207
372
  timestamp_granularities?: Array<'word' | 'segment'>;
208
373
  }
209
374
 
375
+ export namespace TranscriptionCreateParams {
376
+ export type TranscriptionCreateParamsNonStreaming = TranscriptionsAPI.TranscriptionCreateParamsNonStreaming;
377
+ export type TranscriptionCreateParamsStreaming = TranscriptionsAPI.TranscriptionCreateParamsStreaming;
378
+ }
379
+
380
+ export interface TranscriptionCreateParamsNonStreaming<
381
+ ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
382
+ > extends TranscriptionCreateParamsBase<ResponseFormat> {
383
+ /**
384
+ * If set to true, the model response data will be streamed to the client as it is
385
+ * generated using
386
+ * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
387
+ * See the
388
+ * [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)
389
+ * for more information.
390
+ *
391
+ * Note: Streaming is not supported for the `whisper-1` model and will be ignored.
392
+ */
393
+ stream?: false | null;
394
+ }
395
+
396
+ export interface TranscriptionCreateParamsStreaming extends TranscriptionCreateParamsBase {
397
+ /**
398
+ * If set to true, the model response data will be streamed to the client as it is
399
+ * generated using
400
+ * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
401
+ * See the
402
+ * [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)
403
+ * for more information.
404
+ *
405
+ * Note: Streaming is not supported for the `whisper-1` model and will be ignored.
406
+ */
407
+ stream: true;
408
+ }
409
+
210
410
  export declare namespace Transcriptions {
211
411
  export {
212
412
  type Transcription as Transcription,
413
+ type TranscriptionInclude as TranscriptionInclude,
213
414
  type TranscriptionSegment as TranscriptionSegment,
415
+ type TranscriptionStreamEvent as TranscriptionStreamEvent,
416
+ type TranscriptionTextDeltaEvent as TranscriptionTextDeltaEvent,
417
+ type TranscriptionTextDoneEvent as TranscriptionTextDoneEvent,
214
418
  type TranscriptionVerbose as TranscriptionVerbose,
215
419
  type TranscriptionWord as TranscriptionWord,
216
420
  type TranscriptionCreateResponse as TranscriptionCreateResponse,
217
421
  type TranscriptionCreateParams as TranscriptionCreateParams,
422
+ type TranscriptionCreateParamsNonStreaming as TranscriptionCreateParamsNonStreaming,
423
+ type TranscriptionCreateParamsStreaming as TranscriptionCreateParamsStreaming,
218
424
  };
219
425
  }
@@ -88,7 +88,7 @@ export interface TranslationCreateParams<
88
88
  * The format of the output, in one of these options: `json`, `text`, `srt`,
89
89
  * `verbose_json`, or `vtt`.
90
90
  */
91
- response_format?: ResponseFormat;
91
+ response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
92
92
 
93
93
  /**
94
94
  * The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
@@ -2,3 +2,8 @@
2
2
 
3
3
  export { Realtime } from './realtime';
4
4
  export { Sessions, type Session, type SessionCreateResponse, type SessionCreateParams } from './sessions';
5
+ export {
6
+ TranscriptionSessions,
7
+ type TranscriptionSession,
8
+ type TranscriptionSessionCreateParams,
9
+ } from './transcription-sessions';