openai_rust_sdk/models/
gpt5.rs1use crate::{De, Ser};
4use serde::{self, Deserialize, Serialize};
5
6pub mod models {
8 pub const GPT_5: &str = "gpt-5";
10 pub const GPT_5_MINI: &str = "gpt-5-mini";
12 pub const GPT_5_NANO: &str = "gpt-5-nano";
14 pub const GPT_5_CHAT_LATEST: &str = "gpt-5-chat-latest";
16
17 pub const GPT_5_2025_01_01: &str = "gpt-5-2025-01-01";
19 pub const GPT_5_MINI_2025_01_01: &str = "gpt-5-mini-2025-01-01";
21 pub const GPT_5_NANO_2025_01_01: &str = "gpt-5-nano-2025-01-01";
23
24 pub const GPT_4_1: &str = "gpt-4.1";
26 pub const GPT_4_1_MINI: &str = "gpt-4.1-mini";
28 pub const GPT_4_1_NANO: &str = "gpt-4.1-nano";
30
31 pub const GPT_4: &str = "gpt-4";
33 pub const GPT_4_TURBO: &str = "gpt-4-turbo";
35
36 pub const GPT_3_5_TURBO: &str = "gpt-3.5-turbo";
38
39 pub const O3: &str = "o3";
41 pub const O4_MINI: &str = "o4-mini";
43}
44
45#[derive(Debug, Clone, Copy, Ser, De, PartialEq, Eq)]
47#[serde(rename_all = "lowercase")]
48pub enum ReasoningEffort {
49 Minimal,
51 Low,
53 Medium,
55 High,
57}
58
59impl Default for ReasoningEffort {
60 fn default() -> Self {
61 Self::Medium
62 }
63}
64
65#[derive(Debug, Clone, Copy, Ser, De, PartialEq, Eq)]
67#[serde(rename_all = "lowercase")]
68pub enum Verbosity {
69 Low,
71 Medium,
73 High,
75}
76
77impl Default for Verbosity {
78 fn default() -> Self {
79 Self::Medium
80 }
81}
82
83#[derive(Debug, Clone, Ser, De, Default)]
85pub struct ReasoningConfig {
86 #[serde(skip_serializing_if = "Option::is_none")]
88 pub effort: Option<ReasoningEffort>,
89}
90
91impl ReasoningConfig {
92 #[must_use]
94 pub fn new(effort: ReasoningEffort) -> Self {
95 Self {
96 effort: Some(effort),
97 }
98 }
99
100 #[must_use]
102 pub fn minimal() -> Self {
103 Self::new(ReasoningEffort::Minimal)
104 }
105
106 #[must_use]
108 pub fn low() -> Self {
109 Self::new(ReasoningEffort::Low)
110 }
111
112 #[must_use]
114 pub fn medium() -> Self {
115 Self::new(ReasoningEffort::Medium)
116 }
117
118 #[must_use]
120 pub fn high() -> Self {
121 Self::new(ReasoningEffort::High)
122 }
123}
124
125#[derive(Debug, Clone, Ser, De, Default)]
127pub struct TextConfig {
128 #[serde(skip_serializing_if = "Option::is_none")]
130 pub verbosity: Option<Verbosity>,
131
132 #[serde(skip_serializing_if = "Option::is_none")]
134 pub format: Option<serde_json::Value>,
135}
136
137impl TextConfig {
138 #[must_use]
140 pub fn new(verbosity: Verbosity) -> Self {
141 Self {
142 verbosity: Some(verbosity),
143 format: None,
144 }
145 }
146
147 #[must_use]
149 pub fn low() -> Self {
150 Self::new(Verbosity::Low)
151 }
152
153 #[must_use]
155 pub fn medium() -> Self {
156 Self::new(Verbosity::Medium)
157 }
158
159 #[must_use]
161 pub fn high() -> Self {
162 Self::new(Verbosity::High)
163 }
164
165 #[must_use]
167 pub fn with_format(mut self, format: serde_json::Value) -> Self {
168 self.format = Some(format);
169 self
170 }
171}
172
173pub struct GPT5ModelSelector;
175
176impl GPT5ModelSelector {
177 #[must_use]
179 pub fn for_complex_reasoning() -> &'static str {
180 models::GPT_5
181 }
182
183 #[must_use]
185 pub fn for_cost_optimized() -> &'static str {
186 models::GPT_5_MINI
187 }
188
189 #[must_use]
191 pub fn for_high_throughput() -> &'static str {
192 models::GPT_5_NANO
193 }
194
195 #[must_use]
197 pub fn for_coding() -> &'static str {
198 models::GPT_5
199 }
200
201 #[must_use]
203 pub fn for_chat() -> &'static str {
204 models::GPT_5_CHAT_LATEST
205 }
206
207 #[must_use]
209 pub fn migration_from(old_model: &str) -> &'static str {
210 match old_model {
211 "o3" => models::GPT_5,
212 "gpt-4.1" | "gpt-4" | "gpt-4-turbo" => models::GPT_5,
213 "o4-mini" | "gpt-4.1-mini" => models::GPT_5_MINI,
214 "gpt-4.1-nano" | "gpt-3.5-turbo" => models::GPT_5_NANO,
215 _ => models::GPT_5,
216 }
217 }
218}