Skip to content

Commit 7f9704e

Browse files
feat: extract out ImageModel, AudioModel, SpeechModel (#964)
1 parent 9920e1d commit 7f9704e

File tree

13 files changed

+53
-85
lines changed

13 files changed

+53
-85
lines changed

api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Methods:
8888
Types:
8989

9090
- <code><a href="./src/resources/images.ts">Image</a></code>
91+
- <code><a href="./src/resources/images.ts">ImageModel</a></code>
9192
- <code><a href="./src/resources/images.ts">ImagesResponse</a></code>
9293

9394
Methods:
@@ -98,6 +99,10 @@ Methods:
9899

99100
# Audio
100101

102+
Types:
103+
104+
- <code><a href="./src/resources/audio/audio.ts">AudioModel</a></code>
105+
101106
## Transcriptions
102107

103108
Types:
@@ -120,6 +125,10 @@ Methods:
120125

121126
## Speech
122127

128+
Types:
129+
130+
- <code><a href="./src/resources/audio/speech.ts">SpeechModel</a></code>
131+
123132
Methods:
124133

125134
- <code title="post /audio/speech">client.audio.speech.<a href="./src/resources/audio/speech.ts">create</a>({ ...params }) -> Response</code>
@@ -129,6 +138,7 @@ Methods:
129138
Types:
130139

131140
- <code><a href="./src/resources/moderations.ts">Moderation</a></code>
141+
- <code><a href="./src/resources/moderations.ts">ModerationModel</a></code>
132142
- <code><a href="./src/resources/moderations.ts">ModerationCreateResponse</a></code>
133143

134144
Methods:

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,18 @@ export namespace OpenAI {
282282

283283
export import Images = API.Images;
284284
export import Image = API.Image;
285+
export import ImageModel = API.ImageModel;
285286
export import ImagesResponse = API.ImagesResponse;
286287
export import ImageCreateVariationParams = API.ImageCreateVariationParams;
287288
export import ImageEditParams = API.ImageEditParams;
288289
export import ImageGenerateParams = API.ImageGenerateParams;
289290

290291
export import Audio = API.Audio;
292+
export import AudioModel = API.AudioModel;
291293

292294
export import Moderations = API.Moderations;
293295
export import Moderation = API.Moderation;
296+
export import ModerationModel = API.ModerationModel;
294297
export import ModerationCreateResponse = API.ModerationCreateResponse;
295298
export import ModerationCreateParams = API.ModerationCreateParams;
296299

src/resources/audio/audio.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import { APIResource } from '../../resource';
4+
import * as AudioAPI from './audio';
45
import * as SpeechAPI from './speech';
56
import * as TranscriptionsAPI from './transcriptions';
67
import * as TranslationsAPI from './translations';
@@ -11,13 +12,17 @@ export class Audio extends APIResource {
1112
speech: SpeechAPI.Speech = new SpeechAPI.Speech(this._client);
1213
}
1314

15+
export type AudioModel = 'whisper-1';
16+
1417
export namespace Audio {
18+
export import AudioModel = AudioAPI.AudioModel;
1519
export import Transcriptions = TranscriptionsAPI.Transcriptions;
1620
export import Transcription = TranscriptionsAPI.Transcription;
1721
export import TranscriptionCreateParams = TranscriptionsAPI.TranscriptionCreateParams;
1822
export import Translations = TranslationsAPI.Translations;
1923
export import Translation = TranslationsAPI.Translation;
2024
export import TranslationCreateParams = TranslationsAPI.TranslationCreateParams;
2125
export import Speech = SpeechAPI.Speech;
26+
export import SpeechModel = SpeechAPI.SpeechModel;
2227
export import SpeechCreateParams = SpeechAPI.SpeechCreateParams;
2328
}

src/resources/audio/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
export { Audio } from './audio';
4-
export { SpeechCreateParams, Speech } from './speech';
3+
export { AudioModel, Audio } from './audio';
4+
export { SpeechModel, SpeechCreateParams, Speech } from './speech';
55
export { Transcription, TranscriptionCreateParams, Transcriptions } from './transcriptions';
66
export { Translation, TranslationCreateParams, Translations } from './translations';

src/resources/audio/speech.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export class Speech extends APIResource {
1414
}
1515
}
1616

17+
export type SpeechModel = 'tts-1' | 'tts-1-hd';
18+
1719
export interface SpeechCreateParams {
1820
/**
1921
* The text to generate audio for. The maximum length is 4096 characters.
@@ -24,7 +26,7 @@ export interface SpeechCreateParams {
2426
* One of the available [TTS models](https://platform.openai.com/docs/models/tts):
2527
* `tts-1` or `tts-1-hd`
2628
*/
27-
model: (string & {}) | 'tts-1' | 'tts-1-hd';
29+
model: (string & {}) | SpeechModel;
2830

2931
/**
3032
* The voice to use when generating the audio. Supported voices are `alloy`,
@@ -48,5 +50,6 @@ export interface SpeechCreateParams {
4850
}
4951

5052
export namespace Speech {
53+
export import SpeechModel = SpeechAPI.SpeechModel;
5154
export import SpeechCreateParams = SpeechAPI.SpeechCreateParams;
5255
}

src/resources/audio/transcriptions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { APIResource } from '../../resource';
44
import * as Core from '../../core';
55
import * as TranscriptionsAPI from './transcriptions';
6+
import * as AudioAPI from './audio';
67

78
export class Transcriptions extends APIResource {
89
/**
@@ -35,7 +36,7 @@ export interface TranscriptionCreateParams {
3536
* ID of the model to use. Only `whisper-1` (which is powered by our open source
3637
* Whisper V2 model) is currently available.
3738
*/
38-
model: (string & {}) | 'whisper-1';
39+
model: (string & {}) | AudioAPI.AudioModel;
3940

4041
/**
4142
* The language of the input audio. Supplying the input language in

src/resources/audio/translations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { APIResource } from '../../resource';
44
import * as Core from '../../core';
55
import * as TranslationsAPI from './translations';
6+
import * as AudioAPI from './audio';
67

78
export class Translations extends APIResource {
89
/**
@@ -28,7 +29,7 @@ export interface TranslationCreateParams {
2829
* ID of the model to use. Only `whisper-1` (which is powered by our open source
2930
* Whisper V2 model) is currently available.
3031
*/
31-
model: (string & {}) | 'whisper-1';
32+
model: (string & {}) | AudioAPI.AudioModel;
3233

3334
/**
3435
* An optional text to guide the model's style or continue a previous audio

src/resources/beta/assistants.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isRequestOptions } from '../../core';
55
import * as Core from '../../core';
66
import * as AssistantsAPI from './assistants';
77
import * as Shared from '../shared';
8+
import * as ChatAPI from '../chat/chat';
89
import * as MessagesAPI from './threads/messages';
910
import * as ThreadsAPI from './threads/threads';
1011
import * as RunsAPI from './threads/runs/runs';
@@ -1053,30 +1054,7 @@ export interface AssistantCreateParams {
10531054
* [Model overview](https://platform.openai.com/docs/models/overview) for
10541055
* descriptions of them.
10551056
*/
1056-
model:
1057-
| (string & {})
1058-
| 'gpt-4o'
1059-
| 'gpt-4o-2024-05-13'
1060-
| 'gpt-4o-mini'
1061-
| 'gpt-4o-mini-2024-07-18'
1062-
| 'gpt-4-turbo'
1063-
| 'gpt-4-turbo-2024-04-09'
1064-
| 'gpt-4-0125-preview'
1065-
| 'gpt-4-turbo-preview'
1066-
| 'gpt-4-1106-preview'
1067-
| 'gpt-4-vision-preview'
1068-
| 'gpt-4'
1069-
| 'gpt-4-0314'
1070-
| 'gpt-4-0613'
1071-
| 'gpt-4-32k'
1072-
| 'gpt-4-32k-0314'
1073-
| 'gpt-4-32k-0613'
1074-
| 'gpt-3.5-turbo'
1075-
| 'gpt-3.5-turbo-16k'
1076-
| 'gpt-3.5-turbo-0613'
1077-
| 'gpt-3.5-turbo-1106'
1078-
| 'gpt-3.5-turbo-0125'
1079-
| 'gpt-3.5-turbo-16k-0613';
1057+
model: (string & {}) | ChatAPI.ChatModel;
10801058

10811059
/**
10821060
* The description of the assistant. The maximum length is 512 characters.

src/resources/beta/threads/runs/runs.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { sleep } from '../../../../core';
99
import { RunSubmitToolOutputsParamsStream } from '../../../../lib/AssistantStream';
1010
import * as RunsAPI from './runs';
1111
import * as AssistantsAPI from '../../assistants';
12+
import * as ChatAPI from '../../../chat/chat';
1213
import * as MessagesAPI from '../messages';
1314
import * as ThreadsAPI from '../threads';
1415
import * as StepsAPI from './steps';
@@ -668,31 +669,7 @@ export interface RunCreateParamsBase {
668669
* model associated with the assistant. If not, the model associated with the
669670
* assistant will be used.
670671
*/
671-
model?:
672-
| (string & {})
673-
| 'gpt-4o'
674-
| 'gpt-4o-2024-05-13'
675-
| 'gpt-4o-mini'
676-
| 'gpt-4o-mini-2024-07-18'
677-
| 'gpt-4-turbo'
678-
| 'gpt-4-turbo-2024-04-09'
679-
| 'gpt-4-0125-preview'
680-
| 'gpt-4-turbo-preview'
681-
| 'gpt-4-1106-preview'
682-
| 'gpt-4-vision-preview'
683-
| 'gpt-4'
684-
| 'gpt-4-0314'
685-
| 'gpt-4-0613'
686-
| 'gpt-4-32k'
687-
| 'gpt-4-32k-0314'
688-
| 'gpt-4-32k-0613'
689-
| 'gpt-3.5-turbo'
690-
| 'gpt-3.5-turbo-16k'
691-
| 'gpt-3.5-turbo-0613'
692-
| 'gpt-3.5-turbo-1106'
693-
| 'gpt-3.5-turbo-0125'
694-
| 'gpt-3.5-turbo-16k-0613'
695-
| null;
672+
model?: (string & {}) | ChatAPI.ChatModel | null;
696673

697674
/**
698675
* Whether to enable

src/resources/beta/threads/threads.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { APIPromise } from '../../../core';
77
import * as Core from '../../../core';
88
import * as ThreadsAPI from './threads';
99
import * as AssistantsAPI from '../assistants';
10+
import * as ChatAPI from '../../chat/chat';
1011
import * as MessagesAPI from './messages';
1112
import * as RunsAPI from './runs/runs';
1213
import { Stream } from '../../../streaming';
@@ -545,31 +546,7 @@ export interface ThreadCreateAndRunParamsBase {
545546
* model associated with the assistant. If not, the model associated with the
546547
* assistant will be used.
547548
*/
548-
model?:
549-
| (string & {})
550-
| 'gpt-4o'
551-
| 'gpt-4o-2024-05-13'
552-
| 'gpt-4o-mini'
553-
| 'gpt-4o-mini-2024-07-18'
554-
| 'gpt-4-turbo'
555-
| 'gpt-4-turbo-2024-04-09'
556-
| 'gpt-4-0125-preview'
557-
| 'gpt-4-turbo-preview'
558-
| 'gpt-4-1106-preview'
559-
| 'gpt-4-vision-preview'
560-
| 'gpt-4'
561-
| 'gpt-4-0314'
562-
| 'gpt-4-0613'
563-
| 'gpt-4-32k'
564-
| 'gpt-4-32k-0314'
565-
| 'gpt-4-32k-0613'
566-
| 'gpt-3.5-turbo'
567-
| 'gpt-3.5-turbo-16k'
568-
| 'gpt-3.5-turbo-0613'
569-
| 'gpt-3.5-turbo-1106'
570-
| 'gpt-3.5-turbo-0125'
571-
| 'gpt-3.5-turbo-16k-0613'
572-
| null;
549+
model?: (string & {}) | ChatAPI.ChatModel | null;
573550

574551
/**
575552
* Whether to enable

src/resources/images.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export interface Image {
5252
url?: string;
5353
}
5454

55+
export type ImageModel = 'dall-e-2' | 'dall-e-3';
56+
5557
export interface ImagesResponse {
5658
created: number;
5759

@@ -69,7 +71,7 @@ export interface ImageCreateVariationParams {
6971
* The model to use for image generation. Only `dall-e-2` is supported at this
7072
* time.
7173
*/
72-
model?: (string & {}) | 'dall-e-2' | null;
74+
model?: (string & {}) | ImageModel | null;
7375

7476
/**
7577
* The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
@@ -122,7 +124,7 @@ export interface ImageEditParams {
122124
* The model to use for image generation. Only `dall-e-2` is supported at this
123125
* time.
124126
*/
125-
model?: (string & {}) | 'dall-e-2' | null;
127+
model?: (string & {}) | ImageModel | null;
126128

127129
/**
128130
* The number of images to generate. Must be between 1 and 10.
@@ -160,7 +162,7 @@ export interface ImageGenerateParams {
160162
/**
161163
* The model to use for image generation.
162164
*/
163-
model?: (string & {}) | 'dall-e-2' | 'dall-e-3' | null;
165+
model?: (string & {}) | ImageModel | null;
164166

165167
/**
166168
* The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
@@ -207,6 +209,7 @@ export interface ImageGenerateParams {
207209

208210
export namespace Images {
209211
export import Image = ImagesAPI.Image;
212+
export import ImageModel = ImagesAPI.ImageModel;
210213
export import ImagesResponse = ImagesAPI.ImagesResponse;
211214
export import ImageCreateVariationParams = ImagesAPI.ImageCreateVariationParams;
212215
export import ImageEditParams = ImagesAPI.ImageEditParams;

src/resources/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
export * from './chat/index';
44
export * from './shared';
5-
export { Audio } from './audio/audio';
5+
export { AudioModel, Audio } from './audio/audio';
66
export {
77
Batch,
88
BatchError,
@@ -35,12 +35,19 @@ export {
3535
export { FineTuning } from './fine-tuning/fine-tuning';
3636
export {
3737
Image,
38+
ImageModel,
3839
ImagesResponse,
3940
ImageCreateVariationParams,
4041
ImageEditParams,
4142
ImageGenerateParams,
4243
Images,
4344
} from './images';
4445
export { Model, ModelDeleted, ModelsPage, Models } from './models';
45-
export { Moderation, ModerationCreateResponse, ModerationCreateParams, Moderations } from './moderations';
46+
export {
47+
Moderation,
48+
ModerationModel,
49+
ModerationCreateResponse,
50+
ModerationCreateParams,
51+
Moderations,
52+
} from './moderations';
4653
export { Upload, UploadCreateParams, UploadCompleteParams, Uploads } from './uploads/uploads';

src/resources/moderations.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ export namespace Moderation {
168168
}
169169
}
170170

171+
export type ModerationModel = 'text-moderation-latest' | 'text-moderation-stable';
172+
171173
/**
172174
* Represents if a given text input is potentially harmful.
173175
*/
@@ -204,11 +206,12 @@ export interface ModerationCreateParams {
204206
* model. Accuracy of `text-moderation-stable` may be slightly lower than for
205207
* `text-moderation-latest`.
206208
*/
207-
model?: (string & {}) | 'text-moderation-latest' | 'text-moderation-stable';
209+
model?: (string & {}) | ModerationModel;
208210
}
209211

210212
export namespace Moderations {
211213
export import Moderation = ModerationsAPI.Moderation;
214+
export import ModerationModel = ModerationsAPI.ModerationModel;
212215
export import ModerationCreateResponse = ModerationsAPI.ModerationCreateResponse;
213216
export import ModerationCreateParams = ModerationsAPI.ModerationCreateParams;
214217
}

0 commit comments

Comments
 (0)