@@ -11,7 +11,10 @@ import { Stream } from '../../streaming';
11
11
12
12
export class Completions extends APIResource {
13
13
/**
14
- * Creates a model response for the given chat conversation.
14
+ * Creates a model response for the given chat conversation. Learn more in the
15
+ * [text generation](https://platform.openai.com/docs/guides/text-generation),
16
+ * [vision](https://platform.openai.com/docs/guides/vision), and
17
+ * [audio](https://platform.openai.com/docs/guides/audio) guides.
15
18
*/
16
19
create (
17
20
body : ChatCompletionCreateParamsNonStreaming ,
@@ -138,6 +141,12 @@ export interface ChatCompletionAssistantMessageParam {
138
141
*/
139
142
role : 'assistant' ;
140
143
144
+ /**
145
+ * Data about a previous audio response from the model.
146
+ * [Learn more](https://platform.openai.com/docs/guides/audio).
147
+ */
148
+ audio ?: ChatCompletionAssistantMessageParam . Audio | null ;
149
+
141
150
/**
142
151
* The contents of the assistant message. Required unless `tool_calls` or
143
152
* `function_call` is specified.
@@ -168,6 +177,17 @@ export interface ChatCompletionAssistantMessageParam {
168
177
}
169
178
170
179
export namespace ChatCompletionAssistantMessageParam {
180
+ /**
181
+ * Data about a previous audio response from the model.
182
+ * [Learn more](https://platform.openai.com/docs/guides/audio).
183
+ */
184
+ export interface Audio {
185
+ /**
186
+ * Unique identifier for a previous audio response from the model.
187
+ */
188
+ id : string ;
189
+ }
190
+
171
191
/**
172
192
* @deprecated : Deprecated and replaced by `tool_calls`. The name and arguments of
173
193
* a function that should be called, as generated by the model.
@@ -188,6 +208,54 @@ export namespace ChatCompletionAssistantMessageParam {
188
208
}
189
209
}
190
210
211
+ /**
212
+ * If the audio output modality is requested, this object contains data about the
213
+ * audio response from the model.
214
+ * [Learn more](https://platform.openai.com/docs/guides/audio).
215
+ */
216
+ export interface ChatCompletionAudio {
217
+ /**
218
+ * Unique identifier for this audio response.
219
+ */
220
+ id : string ;
221
+
222
+ /**
223
+ * Base64 encoded audio bytes generated by the model, in the format specified in
224
+ * the request.
225
+ */
226
+ data : string ;
227
+
228
+ /**
229
+ * The Unix timestamp (in seconds) for when this audio response will no longer be
230
+ * accessible on the server for use in multi-turn conversations.
231
+ */
232
+ expires_at : number ;
233
+
234
+ /**
235
+ * Transcript of the audio generated by the model.
236
+ */
237
+ transcript : string ;
238
+ }
239
+
240
+ /**
241
+ * Parameters for audio output. Required when audio output is requested with
242
+ * `modalities: ["audio"]`.
243
+ * [Learn more](https://platform.openai.com/docs/guides/audio).
244
+ */
245
+ export interface ChatCompletionAudioParam {
246
+ /**
247
+ * Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`,
248
+ * or `pcm16`.
249
+ */
250
+ format : 'wav' | 'mp3' | 'flac' | 'opus' | 'pcm16' ;
251
+
252
+ /**
253
+ * Specifies the voice type. Supported voices are `alloy`, `echo`, `fable`, `onyx`,
254
+ * `nova`, and `shimmer`.
255
+ */
256
+ voice : 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer' ;
257
+ }
258
+
191
259
/**
192
260
* Represents a streamed chunk of a chat completion response returned by model,
193
261
* based on the provided input.
@@ -371,8 +439,18 @@ export namespace ChatCompletionChunk {
371
439
}
372
440
}
373
441
374
- export type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage ;
442
+ /**
443
+ * Learn about
444
+ * [text inputs](https://platform.openai.com/docs/guides/text-generation).
445
+ */
446
+ export type ChatCompletionContentPart =
447
+ | ChatCompletionContentPartText
448
+ | ChatCompletionContentPartImage
449
+ | ChatCompletionContentPartInputAudio ;
375
450
451
+ /**
452
+ * Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
453
+ */
376
454
export interface ChatCompletionContentPartImage {
377
455
image_url : ChatCompletionContentPartImage . ImageURL ;
378
456
@@ -397,6 +475,32 @@ export namespace ChatCompletionContentPartImage {
397
475
}
398
476
}
399
477
478
+ /**
479
+ * Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
480
+ */
481
+ export interface ChatCompletionContentPartInputAudio {
482
+ input_audio : ChatCompletionContentPartInputAudio . InputAudio ;
483
+
484
+ /**
485
+ * The type of the content part. Always `input_audio`.
486
+ */
487
+ type : 'input_audio' ;
488
+ }
489
+
490
+ export namespace ChatCompletionContentPartInputAudio {
491
+ export interface InputAudio {
492
+ /**
493
+ * Base64 encoded audio data.
494
+ */
495
+ data : string ;
496
+
497
+ /**
498
+ * The format of the encoded audio data. Currently supports "wav" and "mp3".
499
+ */
500
+ format : 'wav' | 'mp3' ;
501
+ }
502
+ }
503
+
400
504
export interface ChatCompletionContentPartRefusal {
401
505
/**
402
506
* The refusal message generated by the model.
@@ -409,6 +513,10 @@ export interface ChatCompletionContentPartRefusal {
409
513
type : 'refusal' ;
410
514
}
411
515
516
+ /**
517
+ * Learn about
518
+ * [text inputs](https://platform.openai.com/docs/guides/text-generation).
519
+ */
412
520
export interface ChatCompletionContentPartText {
413
521
/**
414
522
* The text content.
@@ -471,6 +579,13 @@ export interface ChatCompletionMessage {
471
579
*/
472
580
role : 'assistant' ;
473
581
582
+ /**
583
+ * If the audio output modality is requested, this object contains data about the
584
+ * audio response from the model.
585
+ * [Learn more](https://platform.openai.com/docs/guides/audio).
586
+ */
587
+ audio ?: ChatCompletionAudio | null ;
588
+
474
589
/**
475
590
* @deprecated : Deprecated and replaced by `tool_calls`. The name and arguments of
476
591
* a function that should be called, as generated by the model.
@@ -548,6 +663,8 @@ export namespace ChatCompletionMessageToolCall {
548
663
}
549
664
}
550
665
666
+ export type ChatCompletionModality = 'text' | 'audio' ;
667
+
551
668
/**
552
669
* Specifies a tool the model should use. Use to force the model to call a specific
553
670
* function.
@@ -743,6 +860,13 @@ export interface ChatCompletionCreateParamsBase {
743
860
*/
744
861
model : ( string & { } ) | ChatAPI . ChatModel ;
745
862
863
+ /**
864
+ * Parameters for audio output. Required when audio output is requested with
865
+ * `modalities: ["audio"]`.
866
+ * [Learn more](https://platform.openai.com/docs/guides/audio).
867
+ */
868
+ audio ?: ChatCompletionAudioParam | null ;
869
+
746
870
/**
747
871
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their
748
872
* existing frequency in the text so far, decreasing the model's likelihood to
@@ -812,10 +936,24 @@ export interface ChatCompletionCreateParamsBase {
812
936
813
937
/**
814
938
* Developer-defined tags and values used for filtering completions in the
815
- * [dashboard](https://platform.openai.com/completions).
939
+ * [dashboard](https://platform.openai.com/chat- completions).
816
940
*/
817
941
metadata ?: Record < string , string > | null ;
818
942
943
+ /**
944
+ * Output types that you would like the model to generate for this request. Most
945
+ * models are capable of generating text, which is the default:
946
+ *
947
+ * `["text"]`
948
+ *
949
+ * The `gpt-4o-audio-preview` model can also be used to
950
+ * [generate audio](https://platform.openai.com/docs/guides/audio). To request that
951
+ * this model generate both text and audio responses, you can use:
952
+ *
953
+ * `["text", "audio"]`
954
+ */
955
+ modalities ?: Array < ChatCompletionModality > | null ;
956
+
819
957
/**
820
958
* How many chat completion choices to generate for each input message. Note that
821
959
* you will be charged based on the number of generated tokens across all of the
@@ -900,8 +1038,9 @@ export interface ChatCompletionCreateParamsBase {
900
1038
stop ?: string | null | Array < string > ;
901
1039
902
1040
/**
903
- * Whether or not to store the output of this completion request for traffic
904
- * logging in the [dashboard](https://platform.openai.com/completions).
1041
+ * Whether or not to store the output of this chat completion request for use in
1042
+ * our [model distillation](https://platform.openai.com/docs/guides/distillation)
1043
+ * or [evals](https://platform.openai.com/docs/guides/evals) products.
905
1044
*/
906
1045
store ?: boolean | null ;
907
1046
@@ -1049,16 +1188,20 @@ export type CompletionCreateParamsStreaming = ChatCompletionCreateParamsStreamin
1049
1188
export namespace Completions {
1050
1189
export import ChatCompletion = ChatCompletionsAPI . ChatCompletion ;
1051
1190
export import ChatCompletionAssistantMessageParam = ChatCompletionsAPI . ChatCompletionAssistantMessageParam ;
1191
+ export import ChatCompletionAudio = ChatCompletionsAPI . ChatCompletionAudio ;
1192
+ export import ChatCompletionAudioParam = ChatCompletionsAPI . ChatCompletionAudioParam ;
1052
1193
export import ChatCompletionChunk = ChatCompletionsAPI . ChatCompletionChunk ;
1053
1194
export import ChatCompletionContentPart = ChatCompletionsAPI . ChatCompletionContentPart ;
1054
1195
export import ChatCompletionContentPartImage = ChatCompletionsAPI . ChatCompletionContentPartImage ;
1196
+ export import ChatCompletionContentPartInputAudio = ChatCompletionsAPI . ChatCompletionContentPartInputAudio ;
1055
1197
export import ChatCompletionContentPartRefusal = ChatCompletionsAPI . ChatCompletionContentPartRefusal ;
1056
1198
export import ChatCompletionContentPartText = ChatCompletionsAPI . ChatCompletionContentPartText ;
1057
1199
export import ChatCompletionFunctionCallOption = ChatCompletionsAPI . ChatCompletionFunctionCallOption ;
1058
1200
export import ChatCompletionFunctionMessageParam = ChatCompletionsAPI . ChatCompletionFunctionMessageParam ;
1059
1201
export import ChatCompletionMessage = ChatCompletionsAPI . ChatCompletionMessage ;
1060
1202
export import ChatCompletionMessageParam = ChatCompletionsAPI . ChatCompletionMessageParam ;
1061
1203
export import ChatCompletionMessageToolCall = ChatCompletionsAPI . ChatCompletionMessageToolCall ;
1204
+ export import ChatCompletionModality = ChatCompletionsAPI . ChatCompletionModality ;
1062
1205
export import ChatCompletionNamedToolChoice = ChatCompletionsAPI . ChatCompletionNamedToolChoice ;
1063
1206
export import ChatCompletionRole = ChatCompletionsAPI . ChatCompletionRole ;
1064
1207
export import ChatCompletionStreamOptions = ChatCompletionsAPI . ChatCompletionStreamOptions ;
0 commit comments