openai_api_rs/v1/
common.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Deserialize, Serialize)]
4pub struct Usage {
5    pub prompt_tokens: i32,
6    pub completion_tokens: i32,
7    pub total_tokens: i32,
8}
9
10#[derive(Debug, Deserialize, Serialize)]
11pub struct DeletionStatus {
12    pub id: String,
13    pub object: String,
14    pub deleted: bool,
15}
16
17#[macro_export]
18macro_rules! impl_builder_methods {
19    ($builder:ident, $($field:ident: $field_type:ty),*) => {
20        impl $builder {
21            $(
22                pub fn $field(mut self, $field: $field_type) -> Self {
23                    self.$field = Some($field);
24                    self
25                }
26            )*
27        }
28    };
29}
30
31#[derive(Debug, Serialize, Deserialize)]
32pub struct EmptyRequestBody {}
33
34// O-series models
35pub const O1: &str = "o1";
36pub const O1_2024_12_17: &str = "o1-2024-12-17";
37pub const O1_MINI: &str = "o1-mini";
38pub const O1_MINI_2024_09_12: &str = "o1-mini-2024-09-12";
39pub const O1_PREVIEW: &str = "o1-preview";
40pub const O1_PREVIEW_2024_09_12: &str = "o1-preview-2024-09-12";
41pub const O1_PRO: &str = "o1-pro";
42pub const O1_PRO_2025_03_19: &str = "o1-pro-2025-03-19";
43
44pub const O3: &str = "o3";
45pub const O3_2025_04_16: &str = "o3-2025-04-16";
46pub const O3_MINI: &str = "o3-mini";
47pub const O3_MINI_2025_01_31: &str = "o3-mini-2025-01-31";
48
49pub const O4_MINI: &str = "o4-mini";
50pub const O4_MINI_2025_04_16: &str = "o4-mini-2025-04-16";
51pub const O4_MINI_DEEP_RESEARCH: &str = "o4-mini-deep-research";
52pub const O4_MINI_DEEP_RESEARCH_2025_06_26: &str = "o4-mini-deep-research-2025-06-26";
53
54// GPT-5 models
55pub const GPT5: &str = "gpt-5";
56pub const GPT5_2025_08_07: &str = "gpt-5-2025-08-07";
57pub const GPT5_CHAT_LATEST: &str = "gpt-5-chat-latest";
58pub const GPT5_CODEX: &str = "gpt-5-codex";
59pub const GPT5_MINI: &str = "gpt-5-mini";
60pub const GPT5_MINI_2025_08_07: &str = "gpt-5-mini-2025-08-07";
61pub const GPT5_NANO: &str = "gpt-5-nano";
62pub const GPT5_NANO_2025_08_07: &str = "gpt-5-nano-2025-08-07";
63
64// GPT-4.1 models
65pub const GPT4_1: &str = "gpt-4.1";
66pub const GPT4_1_2025_04_14: &str = "gpt-4.1-2025-04-14";
67pub const GPT4_1_MINI: &str = "gpt-4.1-mini";
68pub const GPT4_1_MINI_2025_04_14: &str = "gpt-4.1-mini-2025-04-14";
69pub const GPT4_1_NANO: &str = "gpt-4.1-nano";
70pub const GPT4_1_NANO_2025_04_14: &str = "gpt-4.1-nano-2025-04-14";
71
72// GPT-4o models
73pub const GPT4_O: &str = "gpt-4o";
74pub const GPT4_O_2024_05_13: &str = "gpt-4o-2024-05-13";
75pub const GPT4_O_2024_08_06: &str = "gpt-4o-2024-08-06";
76pub const GPT4_O_2024_11_20: &str = "gpt-4o-2024-11-20";
77pub const GPT4_O_LATEST: &str = "chatgpt-4o-latest";
78
79pub const GPT4_O_MINI: &str = "gpt-4o-mini";
80pub const GPT4_O_MINI_2024_07_18: &str = "gpt-4o-mini-2024-07-18";
81
82// GPT-4o search models
83pub const GPT4_O_SEARCH_PREVIEW: &str = "gpt-4o-search-preview";
84pub const GPT4_O_SEARCH_PREVIEW_2025_03_11: &str = "gpt-4o-search-preview-2025-03-11";
85pub const GPT4_O_MINI_SEARCH_PREVIEW: &str = "gpt-4o-mini-search-preview";
86pub const GPT4_O_MINI_SEARCH_PREVIEW_2025_03_11: &str = "gpt-4o-mini-search-preview-2025-03-11";
87
88// GPT-4o realtime models
89pub const GPT4_O_REALTIME_PREVIEW: &str = "gpt-4o-realtime-preview";
90pub const GPT4_O_REALTIME_PREVIEW_2024_10_01: &str = "gpt-4o-realtime-preview-2024-10-01";
91pub const GPT4_O_REALTIME_PREVIEW_2024_12_17: &str = "gpt-4o-realtime-preview-2024-12-17";
92pub const GPT4_O_REALTIME_PREVIEW_2025_06_03: &str = "gpt-4o-realtime-preview-2025-06-03";
93pub const GPT4_O_MINI_REALTIME_PREVIEW: &str = "gpt-4o-mini-realtime-preview";
94pub const GPT4_O_MINI_REALTIME_PREVIEW_2024_12_17: &str = "gpt-4o-mini-realtime-preview-2024-12-17";
95
96// GPT-4o audio models
97pub const GPT4_O_AUDIO_PREVIEW: &str = "gpt-4o-audio-preview";
98pub const GPT4_O_AUDIO_PREVIEW_2024_10_01: &str = "gpt-4o-audio-preview-2024-10-01";
99pub const GPT4_O_AUDIO_PREVIEW_2024_12_17: &str = "gpt-4o-audio-preview-2024-12-17";
100pub const GPT4_O_AUDIO_PREVIEW_2025_06_03: &str = "gpt-4o-audio-preview-2025-06-03";
101pub const GPT4_O_MINI_AUDIO_PREVIEW: &str = "gpt-4o-mini-audio-preview";
102pub const GPT4_O_MINI_AUDIO_PREVIEW_2024_12_17: &str = "gpt-4o-mini-audio-preview-2024-12-17";
103
104// GPT-4o transcription models
105pub const GPT4_O_TRANSCRIBE: &str = "gpt-4o-transcribe";
106pub const GPT4_O_MINI_TRANSCRIBE: &str = "gpt-4o-mini-transcribe";
107
108// GPT-4 and GPT-4 Turbo models
109pub const GPT4: &str = "gpt-4";
110pub const GPT4_0613: &str = "gpt-4-0613";
111pub const GPT4_32K: &str = "gpt-4-32k";
112pub const GPT4_32K_0613: &str = "gpt-4-32k-0613";
113pub const GPT4_0314: &str = "gpt-4-0314";
114pub const GPT4_32K_0314: &str = "gpt-4-32k-0314";
115
116pub const GPT4_TURBO: &str = "gpt-4-turbo";
117pub const GPT4_TURBO_2024_04_09: &str = "gpt-4-turbo-2024-04-09";
118pub const GPT4_TURBO_PREVIEW: &str = "gpt-4-turbo-preview";
119pub const GPT4_0125_PREVIEW: &str = "gpt-4-0125-preview";
120pub const GPT4_1106_PREVIEW: &str = "gpt-4-1106-preview";
121pub const GPT4_VISION_PREVIEW: &str = "gpt-4-vision-preview";
122
123// GPT-3.5 Turbo models
124pub const GPT3_5_TURBO: &str = "gpt-3.5-turbo";
125pub const GPT3_5_TURBO_0125: &str = "gpt-3.5-turbo-0125";
126pub const GPT3_5_TURBO_1106: &str = "gpt-3.5-turbo-1106";
127pub const GPT3_5_TURBO_16K: &str = "gpt-3.5-turbo-16k";
128pub const GPT3_5_TURBO_0613: &str = "gpt-3.5-turbo-0613";
129pub const GPT3_5_TURBO_16K_0613: &str = "gpt-3.5-turbo-16k-0613";
130pub const GPT3_5_TURBO_0301: &str = "gpt-3.5-turbo-0301";
131
132pub const GPT3_5_TURBO_INSTRUCT: &str = "gpt-3.5-turbo-instruct";
133pub const GPT3_5_TURBO_INSTRUCT_0914: &str = "gpt-3.5-turbo-instruct-0914";
134
135// Audio models
136pub const GPT_AUDIO: &str = "gpt-audio";
137pub const GPT_AUDIO_2025_08_28: &str = "gpt-audio-2025-08-28";
138pub const GPT_REALTIME: &str = "gpt-realtime";
139pub const GPT_REALTIME_2025_08_28: &str = "gpt-realtime-2025-08-28";
140
141// Text-to-Speech models
142pub const TTS_1: &str = "tts-1";
143pub const TTS_1_HD: &str = "tts-1-hd";
144pub const TTS_1_1106: &str = "tts-1-1106";
145pub const TTS_1_HD_1106: &str = "tts-1-hd-1106";
146pub const GPT4_O_MINI_TTS: &str = "gpt-4o-mini-tts";
147
148// Speech-to-Text models
149pub const WHISPER_1: &str = "whisper-1";
150
151// Image generation models
152pub const DALL_E_2: &str = "dall-e-2";
153pub const DALL_E_3: &str = "dall-e-3";
154pub const GPT_IMAGE_1: &str = "gpt-image-1";
155
156// Embedding models
157pub const TEXT_EMBEDDING_3_SMALL: &str = "text-embedding-3-small";
158pub const TEXT_EMBEDDING_3_LARGE: &str = "text-embedding-3-large";
159pub const TEXT_EMBEDDING_ADA_002: &str = "text-embedding-ada-002";
160
161// Moderation models
162pub const OMNI_MODERATION_LATEST: &str = "omni-moderation-latest";
163pub const OMNI_MODERATION_2024_09_26: &str = "omni-moderation-2024-09-26";
164
165// Legacy models
166pub const DAVINCI_002: &str = "davinci-002";
167pub const BABBAGE_002: &str = "babbage-002";
168
169// Code models
170pub const CODEX_MINI_LATEST: &str = "codex-mini-latest";
171
172// Preview models (GPT-4.5)
173pub const GPT4_5_PREVIEW: &str = "gpt-4.5-preview";
174pub const GPT4_5_PREVIEW_2025_02_27: &str = "gpt-4.5-preview-2025-02-27";