@@ -11,7 +11,10 @@ import { Stream } from '../../streaming';
1111
1212export class Completions extends APIResource {
1313 /**
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.
1518 */
1619 create (
1720 body : ChatCompletionCreateParamsNonStreaming ,
@@ -138,6 +141,12 @@ export interface ChatCompletionAssistantMessageParam {
138141 */
139142 role : 'assistant' ;
140143
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+
141150 /**
142151 * The contents of the assistant message. Required unless `tool_calls` or
143152 * `function_call` is specified.
@@ -168,6 +177,17 @@ export interface ChatCompletionAssistantMessageParam {
168177}
169178
170179export 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+
171191 /**
172192 * @deprecated : Deprecated and replaced by `tool_calls`. The name and arguments of
173193 * a function that should be called, as generated by the model.
@@ -188,6 +208,54 @@ export namespace ChatCompletionAssistantMessageParam {
188208 }
189209}
190210
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+
191259/**
192260 * Represents a streamed chunk of a chat completion response returned by model,
193261 * based on the provided input.
@@ -371,8 +439,18 @@ export namespace ChatCompletionChunk {
371439 }
372440}
373441
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 ;
375450
451+ /**
452+ * Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
453+ */
376454export interface ChatCompletionContentPartImage {
377455 image_url : ChatCompletionContentPartImage . ImageURL ;
378456
@@ -397,6 +475,32 @@ export namespace ChatCompletionContentPartImage {
397475 }
398476}
399477
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+
400504export interface ChatCompletionContentPartRefusal {
401505 /**
402506 * The refusal message generated by the model.
@@ -409,6 +513,10 @@ export interface ChatCompletionContentPartRefusal {
409513 type : 'refusal' ;
410514}
411515
516+ /**
517+ * Learn about
518+ * [text inputs](https://platform.openai.com/docs/guides/text-generation).
519+ */
412520export interface ChatCompletionContentPartText {
413521 /**
414522 * The text content.
@@ -471,6 +579,13 @@ export interface ChatCompletionMessage {
471579 */
472580 role : 'assistant' ;
473581
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+
474589 /**
475590 * @deprecated : Deprecated and replaced by `tool_calls`. The name and arguments of
476591 * a function that should be called, as generated by the model.
@@ -548,6 +663,8 @@ export namespace ChatCompletionMessageToolCall {
548663 }
549664}
550665
666+ export type ChatCompletionModality = 'text' | 'audio' ;
667+
551668/**
552669 * Specifies a tool the model should use. Use to force the model to call a specific
553670 * function.
@@ -743,6 +860,13 @@ export interface ChatCompletionCreateParamsBase {
743860 */
744861 model : ( string & { } ) | ChatAPI . ChatModel ;
745862
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+
746870 /**
747871 * Number between -2.0 and 2.0. Positive values penalize new tokens based on their
748872 * existing frequency in the text so far, decreasing the model's likelihood to
@@ -812,10 +936,24 @@ export interface ChatCompletionCreateParamsBase {
812936
813937 /**
814938 * 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).
816940 */
817941 metadata ?: Record < string , string > | null ;
818942
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+
819957 /**
820958 * How many chat completion choices to generate for each input message. Note that
821959 * you will be charged based on the number of generated tokens across all of the
@@ -900,8 +1038,9 @@ export interface ChatCompletionCreateParamsBase {
9001038 stop ?: string | null | Array < string > ;
9011039
9021040 /**
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.
9051044 */
9061045 store ?: boolean | null ;
9071046
@@ -1049,16 +1188,20 @@ export type CompletionCreateParamsStreaming = ChatCompletionCreateParamsStreamin
10491188export namespace Completions {
10501189 export import ChatCompletion = ChatCompletionsAPI . ChatCompletion ;
10511190 export import ChatCompletionAssistantMessageParam = ChatCompletionsAPI . ChatCompletionAssistantMessageParam ;
1191+ export import ChatCompletionAudio = ChatCompletionsAPI . ChatCompletionAudio ;
1192+ export import ChatCompletionAudioParam = ChatCompletionsAPI . ChatCompletionAudioParam ;
10521193 export import ChatCompletionChunk = ChatCompletionsAPI . ChatCompletionChunk ;
10531194 export import ChatCompletionContentPart = ChatCompletionsAPI . ChatCompletionContentPart ;
10541195 export import ChatCompletionContentPartImage = ChatCompletionsAPI . ChatCompletionContentPartImage ;
1196+ export import ChatCompletionContentPartInputAudio = ChatCompletionsAPI . ChatCompletionContentPartInputAudio ;
10551197 export import ChatCompletionContentPartRefusal = ChatCompletionsAPI . ChatCompletionContentPartRefusal ;
10561198 export import ChatCompletionContentPartText = ChatCompletionsAPI . ChatCompletionContentPartText ;
10571199 export import ChatCompletionFunctionCallOption = ChatCompletionsAPI . ChatCompletionFunctionCallOption ;
10581200 export import ChatCompletionFunctionMessageParam = ChatCompletionsAPI . ChatCompletionFunctionMessageParam ;
10591201 export import ChatCompletionMessage = ChatCompletionsAPI . ChatCompletionMessage ;
10601202 export import ChatCompletionMessageParam = ChatCompletionsAPI . ChatCompletionMessageParam ;
10611203 export import ChatCompletionMessageToolCall = ChatCompletionsAPI . ChatCompletionMessageToolCall ;
1204+ export import ChatCompletionModality = ChatCompletionsAPI . ChatCompletionModality ;
10621205 export import ChatCompletionNamedToolChoice = ChatCompletionsAPI . ChatCompletionNamedToolChoice ;
10631206 export import ChatCompletionRole = ChatCompletionsAPI . ChatCompletionRole ;
10641207 export import ChatCompletionStreamOptions = ChatCompletionsAPI . ChatCompletionStreamOptions ;
0 commit comments