1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
//!
//! Note: all contents copied from OpenAI documentation on November 7, 2023.
//!
//! Source: <https://platform.openai.com/docs/models/overview>
//!
//! # Models
//!
//! | MODELS | DESCRIPTION |
//! | :----------- | :---------- |
//! | GPT-4 | A set of models that improve on GPT-3.5 and can understand as well as generate natural language or code |
//! | GPT-3.5 | A set of models that improve on GPT-3 and can understand as well as generate natural language or code |
//! | DALL·E | A model that can generate and edit images given a natural language prompt |
//! | Whisper | A model that can convert audio into text |
//! | Embeddings | A set of models that can convert text into a numerical form |
//! | CodexLimited | A set of models that can understand and generate code, including translating natural language to code |
//! | Moderation | A fine-tuned model that can detect whether text may be sensitive or unsafe |
//! | GPT-3 | A set of models that can understand and generate natural language |
//! | TTS | A set of models that can convert text into natural sounding spoken audio |
////////////////////////////////////////////////////////////////////////////////
use serde::{Deserialize, Serialize};
/// An enum of OpenAI models
///
/// Note: GPT-4 are not publicly availble yet (Mar 22, 2023).
#[allow(non_camel_case_types)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub enum Model {
/// **GPT-4 Turbo**
///
/// The latest GPT-4 model intended to reduce cases of “laziness” where the
/// model doesn’t complete a task. Returns a maximum of 4,096 output
/// tokens. [Learn more](https://openai.com/blog/new-embedding-models-and-api-updates).
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :------------ | :------------- | :----- |
/// | 128000 tokens | Up to Dec 2023 | GPT-4 |
#[serde(rename = "gpt-4-0125-preview")]
GPT_4_0125_PREVIEW,
/// Currently points to gpt-4-0125-preview.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :------------ | :------------- | :----- |
/// | 128000 tokens | Up to Dec 2023 | GPT-4 |
#[serde(rename = "gpt-4-turbo-preview")]
GPT_4_TURBO_PREVIEW,
/// GPT-4 Turbo model featuring improved instruction following, JSON mode,
/// reproducible outputs, parallel function calling, and more. Returns a
/// maximum of 4,096 output tokens. This is a preview model. [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :------------ | :------------- | :----- |
/// | 128000 tokens | Up to Apr 2023 | GPT-4 |
#[serde(rename = "gpt-4-1106-preview")]
GPT_4_1106_PREVIEW,
/// Ability to understand images, in addition to all other GPT-4 Turbo
/// capabilties. Returns a maximum of 4,096 output tokens. This is a
/// preview model version and not suited yet for production traffic.
/// [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :------------ | :------------- | :----- |
/// | 128000 tokens | Up to Apr 2023 | GPT-4 |
#[serde(rename = "gpt-4-vision-preview")]
GPT_4_TURBO_WITH_VISION,
/// GPT-4 with the ability to understand images, in addition to all other
/// GPT-4 Turbo capabilities. Returns a maximum of 4,096 output tokens.
/// This is a preview model version. [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :------------ | :------------- | :----- |
/// | 128000 tokens | Up to Apr 2023 | GPT-4 |
#[serde(rename = "gpt-4-1106-vision-preview")]
GPT_4_TURBO_1106_WITH_VISION,
/// More capable than any GPT-3.5 model, able to do more complex tasks, and
/// optimized for chat. Will be updated with our latest model iteration.
///
/// Note: on June 27th, 2023, `gpt-4` will be updated to point from
/// `gpt-4-0314` to `gpt-4-0613`, the latest model iteration.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 8192 tokens | Up to Sep 2021 | GPT-4 |
#[serde(rename = "gpt-4")]
GPT_4,
/// Snapshot of `gpt-4` from March 14th 2023. Unlike `gpt-4`, this model
/// will not receive updates, and will only be supported for a three month
/// period ending on June 13th 2023.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 8192 tokens | Up to Sep 2021 | GPT-4 |
#[deprecated(note = "Discontinuation date 2024-06-13, use `gpt-4-0613` instead")]
#[serde(rename = "gpt-4-0314")]
GPT_4_0314,
/// Snapshot of `gpt-4` from June 13th 2023 with function calling data.
/// Unlike `gpt-4`, this model will not receive updates, and will be
/// deprecated 3 months after a new version is released.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :----------- | :------------- | :----- |
/// | 8,192 tokens | Up to Sep 2021 | GPT-4 |
#[serde(rename = "gpt-4-0613")]
GPT_4_0613,
/// Same capabilities as the base `gpt-4` mode but with 4x the context
/// length. Will be updated with our latest model iteration.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :----------- | :------------- | :----- |
/// | 32768 tokens | Up to Sep 2021 | GPT-4 |
#[serde(rename = "gpt-4-32k")]
GPT_4_32K,
/// Snapshot of `gpt-4-32` from June 13th 2023. Unlike `gpt-4-32k`, this
/// model will not receive updates, and will be deprecated 3 months after a
/// new version is released.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :------------ | :------------- | :----- |
/// | 32,768 tokens | Up to Sep 2021 | GPT-4 |
#[serde(rename = "gpt-4-0613")]
GPT_4_32K_0613,
/// Snapshot of `gpt-4-32` from March 14th 2023. Unlike `gpt-4-32k`, this
/// model will not receive updates, and will be deprecated 3 months after a
/// new version is released.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :----------- | :------------- | :----- |
/// | 32768 tokens | Up to Sep 2021 | GPT-4 |
#[deprecated(note = "Discontinuation date 2023-09-13, use `gpt-4-32k-0613` instead")]
#[serde(rename = "gpt-4-32k-0314")]
GPT_4_32K_0314,
/// **Updated GPT 3.5 Turbo**
///
/// The latest GPT-3.5 Turbo model with higher accuracy at responding in
/// requested formats and a fix for a bug which caused a text encoding
/// issue for non-English language function calls. Returns a maximum of
/// 4,096 output tokens. [Learn more](https://openai.com/blog/new-embedding-models-and-api-updates#:~:text=Other%20new%20models%20and%20lower%20pricing)
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :------ |
/// | 16,385 tokens | Up to Sep 2021 | GPT-3.5 |
#[serde(rename = "gpt-3.5-turbo-0125")]
GPT_3_5_TURBO_0125,
/// Most capable GPT-3.5 model and optimized for chat at 1/10th the cost of
/// `text-davinci-003`. Will be updated with our latest model iteration.
///
/// Note: on June 27th, 2023, `gpt-3.5-turbo` will be updated to point from
/// `gpt-3.5-turbo-0301` to `gpt-3.5-turbo-0613`.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :------ |
/// | 4096 tokens | Up to Sep 2021 | GPT-3.5 |
#[serde(rename = "gpt-3.5-turbo")]
GPT_3_5_TURBO,
/// The latest GPT-3.5 Turbo model with improved instruction following,
/// JSON mode, reproducible outputs, parallel function calling, and more.
/// Returns a maximum of 4,096 output tokens. [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :----------- | :------------- | :------ |
/// | 16385 tokens | Up to Sep 2021 | GPT-3.5 |
#[serde(rename = "gpt-3.5-turbo-1106")]
GPT_3_5_TURBO_1106,
/// Same capabilities as the standard `gpt-3.5-turbo` model but with 4
/// times the context.
///
/// Note: currently points to gpt-3.5-turbo-16k-0613
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :------------ | :------------- | :------ |
/// | 16,385 tokens | Up to Sep 2021 | GPT-3.5 |
#[serde(rename = "gpt-3.5-turbo-16k")]
GPT_3_5_TURBO_16K,
/// Snapshot of `gpt-3.5-turbo-16k` from June 13th 2023. Unlike
/// `gpt-3.5-turbo-16k`, this model will not receive updates, and will be
/// deprecated 3 months after a new version is released.
///
/// Note: Will be deprecated on June 13, 2024.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :------------ | :------------- | :------ |
/// | 16,385 tokens | Up to Sep 2021 | GPT-3.5 |
#[deprecated(note = "Discontinuation date 2024-06-13")]
#[serde(rename = "gpt-3.5-turbo-16k-0613")]
GPT_3_5_TURBO_16K_0613,
/// Snapshot of `gpt-3.5-turbo` from June 13th 2023 with function calling
/// data. Unlike `gpt-3.5-turbo`, this model will not receive updates, and
/// will be deprecated 3 months after a new version is released.
///
/// Note: Will be deprecated on June 13, 2024.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :----------- | :------------- | :------ |
/// | 4,096 tokens | Up to Sep 2021 | GPT-3.5 |
#[deprecated(note = "Discontinuation date 2024-06-13")]
#[serde(rename = "gpt-3.5-turbo-0613")]
GPT_3_5_TURBO_0613,
/// Snapshot of `gpt-3.5-turbo` from March 1st 2023. Unlike
/// `gpt-3.5-turbo`, this model will not receive updates, and will only be
/// supported for a three month period ending on June 1st 2023.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :------ |
/// | 4096 tokens | Up to Sep 2021 | GPT-3.5 |
#[deprecated(note = "Discontinuation date 2023-09-13, use `gpt-3.5-turbo-0613` instead")]
#[serde(rename = "gpt-3.5-turbo-0301")]
GPT_3_5_TURBO_0301,
/// Can do any language task with better quality, longer output, and
/// consistent instruction-following than the curie, babbage, or ada
/// models. Also supports some additional features such as [inserting text](https://platform.openai.com/docs/guides/gpt/inserting-text).
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :------ |
/// | 4097 tokens | Up to Sep 2021 | GPT-3.5 |
#[serde(rename = "text-davinci-003")]
TEXT_DAVINCI_003,
/// Similar capabilities to `text-davinci-003` but trained with supervised
/// fine-tuning instead of reinforcement learning
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :------ |
/// | 4097 tokens | Up to Sep 2021 | GPT-3.5 |
#[serde(rename = "text-davinci-002")]
TEXT_DAVINCI_002,
#[serde(rename = "text-davinci-edit-001")]
TEXT_DAVINCI_EDIT_001,
/// Optimized for code-completion tasks
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :------ |
/// | 8001 tokens | Up to Sep 2021 | GPT-3.5 |
#[serde(rename = "code-davinci-edit-001")]
CODE_DAVINCI_EDIT_001,
#[serde(rename = "whisper-1")]
WHISPER_1,
#[serde(rename = "text-embedding-ada-002")]
TEXT_EMBEDDING_ADA_002,
#[serde(rename = "text-embedding-ada-002-v2")]
TEXT_EMBEDDING_ADA_002_v2,
#[serde(rename = "text-search-ada-doc-001")]
TEXT_SEARCH_ADA_DOC_001,
/// Most capable Codex model. Particularly good at translating natural
/// language to code. In addition to completing code, also supports
/// [inserting](https://platform.openai.com/docs/guides/code/inserting-code) completions within code.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 8001 tokens | Up to Jun 2021 | Codex |
#[deprecated(note = "The Codex models are now deprecated.")]
#[serde(rename = "code-davinci-002")]
CODE_DAVINCI_002,
/// Earlier version of `code-davinci-002`
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 8001 tokens | Up to Jun 2021 | Codex |
#[deprecated(note = "The Codex models are now deprecated.")]
#[serde(rename = "code-davinci-001")]
CODE_DAVINCI_001,
/// Almost as capable as Davinci Codex, but slightly faster. This speed
/// advantage may make it preferable for real-time applications.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2048 tokens | - | Codex |
#[deprecated(note = "The Codex models are now deprecated.")]
#[serde(rename = "code-cushman-002")]
CODE_CUSHMAN_002,
/// Earlier version of `code-cushman-002`
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2048 tokens | - | Codex |
#[deprecated(note = "The Codex models are now deprecated.")]
#[serde(rename = "code-cushman-001")]
CODE_CUSHMAN_001,
/// Most capable moderation model. Accuracy will be slighlty higher than
/// the stable model
///
/// Series: Moderation
#[serde(rename = "text-moderation-latest")]
TEXT_MODERATION_LATEST,
#[serde(rename = "text-moderation-004")]
TEXT_MODERATION_004,
#[serde(rename = "text-moderation-003")]
TEXT_MODERATION_003,
#[serde(rename = "text-moderation-002")]
TEXT_MODERATION_002,
#[serde(rename = "text-moderation-001")]
TEXT_MODERATION_001,
/// Almost as capable as the latest model, but slightly older.
///
/// Series: Moderation
#[serde(rename = "text-moderation-stable")]
TEXT_MODERATION_STABLE,
/// Very capable, faster and lower cost than Davinci.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2049 tokens | Up to Oct 2019 | GPT-3 |
#[serde(rename = "text-curie-001")]
TEXT_CURIE_001,
/// Capable of straightforward tasks, very fast, and lower cost.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2049 tokens | Up to Oct 2019 | GPT-3 |
#[serde(rename = "text-babbage-001")]
TEXT_BABBAGE_001,
/// Capable of very simple tasks, usually the fastest model in the GPT-3
/// series, and lowest cost.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2049 tokens | Up to Oct 2019 | GPT-3 |
#[serde(rename = "text-ada-001")]
TEXT_ADA_001,
/// Most capable GPT-3 model. Can do any task the other models can do,
/// often with higher quality.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2049 tokens | Up to Oct 2019 | GPT-3 |
#[serde(rename = "davinci")]
DAVINCI,
/// Very capable, but faster and lower cost than Davinci.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2049 tokens | Up to Oct 2019 | GPT-3 |
#[serde(rename = "curie")]
CURIE,
/// Capable of straightforward tasks, very fast, and lower cost.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2049 tokens | Up to Oct 2019 | GPT-3 |
#[serde(rename = "babbage")]
BABBAGE,
/// Capable of very simple tasks, usually the fastest model in the GPT-3 series, and lowest cost.
///
/// | MAX TOKENS | TRAINING DATA | SERIES |
/// | :---------- | :------------- | :----- |
/// | 2049 tokens | Up to Oct 2019 | GPT-3 |
#[serde(rename = "ada")]
ADA,
/// The latest DALL·E model released in Nov 2023. [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
#[serde(rename = "dall-e-3")]
DALL_E_3,
/// The previous DALL·E model released in Nov 2022. The 2nd iteration of
/// DALL·E with more realistic, accurate, and 4x greater resolution images
/// than the original model.
#[serde(rename = "dall-e-2")]
DALL_E_2,
/// The latest text to speech model, optimized for speed.
#[serde(rename = "tts-1")]
TTS_1,
/// The latest text to speech model, optimized for quality.
#[serde(rename = "tts-1-hd")]
TTS_1_HD,
#[serde(other)]
UNKNOWN,
}
#[allow(deprecated)]
impl Into<&'static str> for Model {
fn into(self) -> &'static str {
match self {
Model::GPT_4 => "gpt-4",
Model::GPT_4_0613 => "gpt-4-0613",
Model::GPT_4_0314 => "gpt-4-0314",
Model::GPT_4_32K => "gpt-4-32k",
Model::GPT_4_32K_0613 => "gpt-4-32k-0613",
Model::GPT_4_32K_0314 => "gpt-4-32k-0314",
Model::GPT_3_5_TURBO => "gpt-3.5-turbo",
Model::GPT_3_5_TURBO_16K => "gpt-3.5-turbo-16k",
Model::GPT_3_5_TURBO_16K_0613 => "gpt-3.5-turbo-16k-0613",
Model::GPT_3_5_TURBO_0613 => "gpt-3.5-turbo-0613",
Model::GPT_3_5_TURBO_0301 => "gpt-3.5-turbo-0301",
Model::TEXT_DAVINCI_003 => "text-davinci-003",
Model::TEXT_DAVINCI_002 => "text-davinci-002",
Model::TEXT_DAVINCI_EDIT_001 => "text-davinci-edit-001",
Model::CODE_DAVINCI_EDIT_001 => "code-davinci-edit-001",
Model::WHISPER_1 => "whisper-1",
Model::TEXT_EMBEDDING_ADA_002 => "text-embedding-ada-002",
Model::TEXT_EMBEDDING_ADA_002_v2 => "text-embedding-ada-002-v2",
Model::TEXT_SEARCH_ADA_DOC_001 => "text-search-ada-doc-001",
Model::CODE_DAVINCI_002 => "code-davinci-002",
Model::CODE_DAVINCI_001 => "code-davinci-001",
Model::CODE_CUSHMAN_002 => "code-cushman-002",
Model::CODE_CUSHMAN_001 => "code-cushman-001",
Model::TEXT_MODERATION_LATEST => "text-moderation-latest",
Model::TEXT_MODERATION_STABLE => "text-moderation-stable",
Model::TEXT_CURIE_001 => "text-curie-001",
Model::TEXT_BABBAGE_001 => "text-babbage-001",
Model::TEXT_ADA_001 => "text-ada-001",
Model::DAVINCI => "davinci",
Model::CURIE => "curie",
Model::BABBAGE => "babbage",
Model::ADA => "ada",
Model::TEXT_MODERATION_001 => "text-moderation-001",
Model::TEXT_MODERATION_002 => "text-moderation-002",
Model::TEXT_MODERATION_003 => "text-moderation-003",
Model::TEXT_MODERATION_004 => "text-moderation-004",
Model::UNKNOWN => "unknown",
Model::GPT_4_TURBO_WITH_VISION => "gpt-4-vision-preview",
Model::GPT_3_5_TURBO_1106 => "gpt-3.5-turbo-1106",
Model::DALL_E_3 => "dall-e-3",
Model::DALL_E_2 => "dall-e-2",
Model::TTS_1 => "tts-1",
Model::TTS_1_HD => "tts-1-hd",
Model::GPT_4_0125_PREVIEW => "gpt-4-0125-preview",
Model::GPT_4_TURBO_PREVIEW => "gpt-4-turbo-preview",
Model::GPT_4_1106_PREVIEW => "gpt-4-1106-preview",
Model::GPT_4_TURBO_1106_WITH_VISION => "gpt-4-1106-vision-preview",
Model::GPT_3_5_TURBO_0125 => "gpt-3.5-turbo-0125",
}
}
}