Skip to main content

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_PRO: &str = "o1-pro";
38pub const O1_PRO_2025_03_19: &str = "o1-pro-2025-03-19";
39
40pub const O3: &str = "o3";
41pub const O3_2025_04_16: &str = "o3-2025-04-16";
42pub const O3_MINI: &str = "o3-mini";
43pub const O3_MINI_2025_01_31: &str = "o3-mini-2025-01-31";
44
45pub const O4_MINI: &str = "o4-mini";
46pub const O4_MINI_2025_04_16: &str = "o4-mini-2025-04-16";
47pub const O4_MINI_DEEP_RESEARCH: &str = "o4-mini-deep-research";
48pub const O4_MINI_DEEP_RESEARCH_2025_06_26: &str = "o4-mini-deep-research-2025-06-26";
49
50// GPT-5.4 models
51pub const GPT5_4: &str = "gpt-5.4";
52pub const GPT5_4_2026_03_05: &str = "gpt-5.4-2026-03-05";
53pub const GPT5_4_MINI: &str = "gpt-5.4-mini";
54pub const GPT5_4_MINI_2026_03_17: &str = "gpt-5.4-mini-2026-03-17";
55pub const GPT5_4_NANO: &str = "gpt-5.4-nano";
56pub const GPT5_4_NANO_2026_03_17: &str = "gpt-5.4-nano-2026-03-17";
57pub const GPT5_4_PRO: &str = "gpt-5.4-pro";
58pub const GPT5_4_PRO_2026_03_05: &str = "gpt-5.4-pro-2026-03-05";
59
60// GPT-5.3 models
61pub const GPT5_3_CHAT_LATEST: &str = "gpt-5.3-chat-latest";
62pub const GPT5_3_CODEX: &str = "gpt-5.3-codex";
63
64// GPT-5.2 models
65pub const GPT5_2: &str = "gpt-5.2";
66pub const GPT5_2_2025_12_11: &str = "gpt-5.2-2025-12-11";
67pub const GPT5_2_CHAT_LATEST: &str = "gpt-5.2-chat-latest";
68pub const GPT5_2_CODEX: &str = "gpt-5.2-codex";
69pub const GPT5_2_PRO: &str = "gpt-5.2-pro";
70pub const GPT5_2_PRO_2025_12_11: &str = "gpt-5.2-pro-2025-12-11";
71
72// GPT-5.1 models
73pub const GPT5_1: &str = "gpt-5.1";
74pub const GPT5_1_2025_11_13: &str = "gpt-5.1-2025-11-13";
75pub const GPT5_1_CHAT_LATEST: &str = "gpt-5.1-chat-latest";
76pub const GPT5_1_CODEX: &str = "gpt-5.1-codex";
77pub const GPT5_1_CODEX_MAX: &str = "gpt-5.1-codex-max";
78pub const GPT5_1_CODEX_MINI: &str = "gpt-5.1-codex-mini";
79
80// GPT-5 models
81pub const GPT5: &str = "gpt-5";
82pub const GPT5_2025_08_07: &str = "gpt-5-2025-08-07";
83pub const GPT5_CHAT_LATEST: &str = "gpt-5-chat-latest";
84pub const GPT5_CODEX: &str = "gpt-5-codex";
85pub const GPT5_MINI: &str = "gpt-5-mini";
86pub const GPT5_MINI_2025_08_07: &str = "gpt-5-mini-2025-08-07";
87pub const GPT5_NANO: &str = "gpt-5-nano";
88pub const GPT5_NANO_2025_08_07: &str = "gpt-5-nano-2025-08-07";
89pub const GPT5_PRO: &str = "gpt-5-pro";
90pub const GPT5_PRO_2025_10_06: &str = "gpt-5-pro-2025-10-06";
91pub const GPT5_SEARCH_API: &str = "gpt-5-search-api";
92pub const GPT5_SEARCH_API_2025_10_14: &str = "gpt-5-search-api-2025-10-14";
93
94// GPT-4.1 models
95pub const GPT4_1: &str = "gpt-4.1";
96pub const GPT4_1_2025_04_14: &str = "gpt-4.1-2025-04-14";
97pub const GPT4_1_MINI: &str = "gpt-4.1-mini";
98pub const GPT4_1_MINI_2025_04_14: &str = "gpt-4.1-mini-2025-04-14";
99pub const GPT4_1_NANO: &str = "gpt-4.1-nano";
100pub const GPT4_1_NANO_2025_04_14: &str = "gpt-4.1-nano-2025-04-14";
101
102// GPT-4o models
103pub const GPT4_O: &str = "gpt-4o";
104pub const GPT4_O_2024_05_13: &str = "gpt-4o-2024-05-13";
105pub const GPT4_O_2024_08_06: &str = "gpt-4o-2024-08-06";
106pub const GPT4_O_2024_11_20: &str = "gpt-4o-2024-11-20";
107
108pub const GPT4_O_MINI: &str = "gpt-4o-mini";
109pub const GPT4_O_MINI_2024_07_18: &str = "gpt-4o-mini-2024-07-18";
110
111// GPT-4o search models
112pub const GPT4_O_SEARCH_PREVIEW: &str = "gpt-4o-search-preview";
113pub const GPT4_O_SEARCH_PREVIEW_2025_03_11: &str = "gpt-4o-search-preview-2025-03-11";
114pub const GPT4_O_MINI_SEARCH_PREVIEW: &str = "gpt-4o-mini-search-preview";
115pub const GPT4_O_MINI_SEARCH_PREVIEW_2025_03_11: &str = "gpt-4o-mini-search-preview-2025-03-11";
116
117// GPT-4o realtime models
118pub const GPT4_O_REALTIME_PREVIEW: &str = "gpt-4o-realtime-preview";
119pub const GPT4_O_REALTIME_PREVIEW_2024_12_17: &str = "gpt-4o-realtime-preview-2024-12-17";
120pub const GPT4_O_REALTIME_PREVIEW_2025_06_03: &str = "gpt-4o-realtime-preview-2025-06-03";
121pub const GPT4_O_MINI_REALTIME_PREVIEW: &str = "gpt-4o-mini-realtime-preview";
122pub const GPT4_O_MINI_REALTIME_PREVIEW_2024_12_17: &str = "gpt-4o-mini-realtime-preview-2024-12-17";
123
124// GPT-4o audio models
125pub const GPT4_O_AUDIO_PREVIEW: &str = "gpt-4o-audio-preview";
126pub const GPT4_O_AUDIO_PREVIEW_2024_12_17: &str = "gpt-4o-audio-preview-2024-12-17";
127pub const GPT4_O_AUDIO_PREVIEW_2025_06_03: &str = "gpt-4o-audio-preview-2025-06-03";
128pub const GPT4_O_MINI_AUDIO_PREVIEW: &str = "gpt-4o-mini-audio-preview";
129pub const GPT4_O_MINI_AUDIO_PREVIEW_2024_12_17: &str = "gpt-4o-mini-audio-preview-2024-12-17";
130
131// GPT-4o transcription and TTS models
132pub const GPT4_O_TRANSCRIBE: &str = "gpt-4o-transcribe";
133pub const GPT4_O_TRANSCRIBE_DIARIZE: &str = "gpt-4o-transcribe-diarize";
134pub const GPT4_O_MINI_TRANSCRIBE: &str = "gpt-4o-mini-transcribe";
135pub const GPT4_O_MINI_TRANSCRIBE_2025_03_20: &str = "gpt-4o-mini-transcribe-2025-03-20";
136pub const GPT4_O_MINI_TRANSCRIBE_2025_12_15: &str = "gpt-4o-mini-transcribe-2025-12-15";
137pub const GPT4_O_MINI_TTS: &str = "gpt-4o-mini-tts";
138pub const GPT4_O_MINI_TTS_2025_03_20: &str = "gpt-4o-mini-tts-2025-03-20";
139pub const GPT4_O_MINI_TTS_2025_12_15: &str = "gpt-4o-mini-tts-2025-12-15";
140
141// GPT-4 models
142pub const GPT4: &str = "gpt-4";
143pub const GPT4_0613: &str = "gpt-4-0613";
144pub const GPT4_TURBO: &str = "gpt-4-turbo";
145pub const GPT4_TURBO_2024_04_09: &str = "gpt-4-turbo-2024-04-09";
146
147// GPT-3.5 models
148pub const GPT3_5_TURBO: &str = "gpt-3.5-turbo";
149pub const GPT3_5_TURBO_0125: &str = "gpt-3.5-turbo-0125";
150pub const GPT3_5_TURBO_1106: &str = "gpt-3.5-turbo-1106";
151pub const GPT3_5_TURBO_16K: &str = "gpt-3.5-turbo-16k";
152pub const GPT3_5_TURBO_INSTRUCT: &str = "gpt-3.5-turbo-instruct";
153pub const GPT3_5_TURBO_INSTRUCT_0914: &str = "gpt-3.5-turbo-instruct-0914";
154
155// Audio models
156pub const GPT_AUDIO: &str = "gpt-audio";
157pub const GPT_AUDIO_1_5: &str = "gpt-audio-1.5";
158pub const GPT_AUDIO_2025_08_28: &str = "gpt-audio-2025-08-28";
159pub const GPT_AUDIO_MINI: &str = "gpt-audio-mini";
160pub const GPT_AUDIO_MINI_2025_10_06: &str = "gpt-audio-mini-2025-10-06";
161pub const GPT_AUDIO_MINI_2025_12_15: &str = "gpt-audio-mini-2025-12-15";
162
163pub const GPT_REALTIME: &str = "gpt-realtime";
164pub const GPT_REALTIME_1_5: &str = "gpt-realtime-1.5";
165pub const GPT_REALTIME_2025_08_28: &str = "gpt-realtime-2025-08-28";
166pub const GPT_REALTIME_MINI: &str = "gpt-realtime-mini";
167pub const GPT_REALTIME_MINI_2025_10_06: &str = "gpt-realtime-mini-2025-10-06";
168pub const GPT_REALTIME_MINI_2025_12_15: &str = "gpt-realtime-mini-2025-12-15";
169
170// Text-to-Speech models
171pub const TTS_1: &str = "tts-1";
172pub const TTS_1_1106: &str = "tts-1-1106";
173pub const TTS_1_HD: &str = "tts-1-hd";
174pub const TTS_1_HD_1106: &str = "tts-1-hd-1106";
175
176// Speech-to-Text models
177pub const WHISPER_1: &str = "whisper-1";
178
179// Image generation models
180pub const CHATGPT_IMAGE_LATEST: &str = "chatgpt-image-latest";
181pub const DALL_E_2: &str = "dall-e-2";
182pub const DALL_E_3: &str = "dall-e-3";
183pub const GPT_IMAGE_1: &str = "gpt-image-1";
184pub const GPT_IMAGE_1_5: &str = "gpt-image-1.5";
185pub const GPT_IMAGE_1_MINI: &str = "gpt-image-1-mini";
186
187// Embedding models
188pub const TEXT_EMBEDDING_3_SMALL: &str = "text-embedding-3-small";
189pub const TEXT_EMBEDDING_3_LARGE: &str = "text-embedding-3-large";
190pub const TEXT_EMBEDDING_ADA_002: &str = "text-embedding-ada-002";
191
192// Moderation models
193pub const OMNI_MODERATION_LATEST: &str = "omni-moderation-latest";
194pub const OMNI_MODERATION_2024_09_26: &str = "omni-moderation-2024-09-26";
195
196// Legacy models
197pub const BABBAGE_002: &str = "babbage-002";
198pub const DAVINCI_002: &str = "davinci-002";
199
200// Video models
201pub const SORA_2: &str = "sora-2";
202pub const SORA_2_PRO: &str = "sora-2-pro";