Skip to content

Commit 948965c

Browse files
feat: extract out ImageModel, AudioModel, SpeechModel (#964)
1 parent a945b23 commit 948965c

File tree

13 files changed

+53
-85
lines changed

13 files changed

+53
-85
lines changed

Diff for: api.md

+10
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Methods:
8787
Types:
8888

8989
- <code><a href="./src/resources/images.ts">Image</a></code>
90+
- <code><a href="./src/resources/images.ts">ImageModel</a></code>
9091
- <code><a href="./src/resources/images.ts">ImagesResponse</a></code>
9192

9293
Methods:
@@ -97,6 +98,10 @@ Methods:
9798

9899
# Audio
99100

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

102107
Types:
@@ -119,6 +124,10 @@ Methods:
119124

120125
## Speech
121126

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

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

130139
- <code><a href="./src/resources/moderations.ts">Moderation</a></code>
140+
- <code><a href="./src/resources/moderations.ts">ModerationModel</a></code>
131141
- <code><a href="./src/resources/moderations.ts">ModerationCreateResponse</a></code>
132142

133143
Methods:

Diff for: src/index.ts

+3
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

Diff for: src/resources/audio/audio.ts

+5
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
}

Diff for: src/resources/audio/index.ts

+2-2
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';

Diff for: src/resources/audio/speech.ts

+4-1
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
}

Diff for: src/resources/audio/transcriptions.ts

+2-1
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

Diff for: src/resources/audio/translations.ts

+2-1
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

Diff for: src/resources/beta/assistants.ts

+2-24
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.

Diff for: src/resources/beta/threads/runs/runs.ts

+2-25
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { APIPromise } from '../../../../core';
66
import * as Core from '../../../../core';
77
import * as RunsAPI from './runs';
88
import * as AssistantsAPI from '../../assistants';
9+
import * as ChatAPI from '../../../chat/chat';
910
import * as MessagesAPI from '../messages';
1011
import * as ThreadsAPI from '../threads';
1112
import * as StepsAPI from './steps';
@@ -542,31 +543,7 @@ export interface RunCreateParamsBase {
542543
* model associated with the assistant. If not, the model associated with the
543544
* assistant will be used.
544545
*/
545-
model?:
546-
| (string & {})
547-
| 'gpt-4o'
548-
| 'gpt-4o-2024-05-13'
549-
| 'gpt-4o-mini'
550-
| 'gpt-4o-mini-2024-07-18'
551-
| 'gpt-4-turbo'
552-
| 'gpt-4-turbo-2024-04-09'
553-
| 'gpt-4-0125-preview'
554-
| 'gpt-4-turbo-preview'
555-
| 'gpt-4-1106-preview'
556-
| 'gpt-4-vision-preview'
557-
| 'gpt-4'
558-
| 'gpt-4-0314'
559-
| 'gpt-4-0613'
560-
| 'gpt-4-32k'
561-
| 'gpt-4-32k-0314'
562-
| 'gpt-4-32k-0613'
563-
| 'gpt-3.5-turbo'
564-
| 'gpt-3.5-turbo-16k'
565-
| 'gpt-3.5-turbo-0613'
566-
| 'gpt-3.5-turbo-1106'
567-
| 'gpt-3.5-turbo-0125'
568-
| 'gpt-3.5-turbo-16k-0613'
569-
| null;
546+
model?: (string & {}) | ChatAPI.ChatModel | null;
570547

571548
/**
572549
* Whether to enable

Diff for: src/resources/beta/threads/threads.ts

+2-25
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { APIPromise } from '../../../core';
66
import * as Core from '../../../core';
77
import * as ThreadsAPI from './threads';
88
import * as AssistantsAPI from '../assistants';
9+
import * as ChatAPI from '../../chat/chat';
910
import * as MessagesAPI from './messages';
1011
import * as RunsAPI from './runs/runs';
1112
import { Stream } from '../../../streaming';
@@ -521,31 +522,7 @@ export interface ThreadCreateAndRunParamsBase {
521522
* model associated with the assistant. If not, the model associated with the
522523
* assistant will be used.
523524
*/
524-
model?:
525-
| (string & {})
526-
| 'gpt-4o'
527-
| 'gpt-4o-2024-05-13'
528-
| 'gpt-4o-mini'
529-
| 'gpt-4o-mini-2024-07-18'
530-
| 'gpt-4-turbo'
531-
| 'gpt-4-turbo-2024-04-09'
532-
| 'gpt-4-0125-preview'
533-
| 'gpt-4-turbo-preview'
534-
| 'gpt-4-1106-preview'
535-
| 'gpt-4-vision-preview'
536-
| 'gpt-4'
537-
| 'gpt-4-0314'
538-
| 'gpt-4-0613'
539-
| 'gpt-4-32k'
540-
| 'gpt-4-32k-0314'
541-
| 'gpt-4-32k-0613'
542-
| 'gpt-3.5-turbo'
543-
| 'gpt-3.5-turbo-16k'
544-
| 'gpt-3.5-turbo-0613'
545-
| 'gpt-3.5-turbo-1106'
546-
| 'gpt-3.5-turbo-0125'
547-
| 'gpt-3.5-turbo-16k-0613'
548-
| null;
525+
model?: (string & {}) | ChatAPI.ChatModel | null;
549526

550527
/**
551528
* Whether to enable

Diff for: src/resources/images.ts

+6-3
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;

Diff for: src/resources/index.ts

+9-2
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';

Diff for: src/resources/moderations.ts

+4-1
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)