Skip to main content

vtcode_config/constants/models/
openai.rs

1pub const DEFAULT_MODEL: &str = "gpt-5.6-sol";
2pub const SUPPORTED_MODELS: &[&str] = &[
3    GPT,
4    GPT_6_ASTRA,
5    GPT_6_SOL,
6    GPT_6_1_SOL,
7    GPT_6_LUNA,
8    "gpt-5.6",       // GPT-5.6 alias (routes to gpt-5.6-sol)
9    "gpt-5.6-sol",   // GPT-5.6 Sol flagship model
10    "gpt-5.6-terra", // GPT-5.6 Terra balanced model
11    "gpt-5.6-luna",  // GPT-5.6 Luna efficient model
12    "gpt-5.1-mini",
13    "gpt-oss-20b",
14    "gpt-oss-120b",
15];
16
17/// Models that require the OpenAI Responses API
18pub const RESPONSES_API_MODELS: &[&str] = &[
19    GPT,
20    GPT_6_ASTRA,
21    GPT_6_SOL,
22    GPT_6_1_SOL,
23    GPT_6_LUNA,
24    GPT_5_6,
25    GPT_5_6_SOL,
26    GPT_5_6_TERRA,
27    GPT_5_6_LUNA,
28    GPT_5_6_SOL,
29    GPT_5_1_MINI,
30];
31
32/// Models that support the OpenAI reasoning parameter payload
33pub const REASONING_MODELS: &[&str] = &[
34    GPT,
35    GPT_6_ASTRA,
36    GPT_6_SOL,
37    GPT_6_1_SOL,
38    GPT_6_LUNA,
39    GPT_5_6,
40    GPT_5_6_SOL,
41    GPT_5_6_TERRA,
42    GPT_5_6_LUNA,
43    GPT_5_6_SOL,
44];
45
46/// Models that support the native OpenAI `service_tier` request parameter.
47pub(crate) const SERVICE_TIER_MODELS: &[&str] = RESPONSES_API_MODELS;
48
49/// Models that do not expose structured tool calling on the OpenAI platform
50pub const TOOL_UNAVAILABLE_MODELS: &[&str] = &[];
51
52/// GPT-OSS models that use harmony tokenization
53pub const HARMONY_MODELS: &[&str] = &[GPT_OSS_20B, GPT_OSS_120B];
54
55/// Models that reject non-streaming requests on the OpenAI API. The provider
56/// advertises no non-streaming capability for them and coerces generation to
57/// an internally-streamed request (see `OpenAIProvider::requires_streaming_responses`).
58pub const STREAMING_REQUIRED_MODELS: &[&str] = &[GPT, GPT_5_6_SOL, GPT_5_6_LUNA];
59
60// Convenience constants for commonly used models
61pub const GPT: &str = "gpt";
62pub const GPT_6_ASTRA: &str = "gpt-6-astra";
63pub const GPT_6_SOL: &str = "gpt-6-sol";
64pub const GPT_6_1_SOL: &str = "gpt-6.1-sol";
65pub const GPT_6_LUNA: &str = "gpt-6-luna";
66pub const GPT_5_6_SOL: &str = "gpt-5.6-sol";
67pub const GPT_5_6_TERRA: &str = "gpt-5.6-terra";
68pub const GPT_5_6_LUNA: &str = "gpt-5.6-luna";
69pub const GPT_5_6: &str = "gpt-5.6";
70pub const GPT_5_1: &str = "gpt-5.1";
71pub const GPT_5_1_MINI: &str = "gpt-5.1-mini";
72pub const GPT_OSS_20B: &str = "gpt-oss-20b";
73pub const GPT_OSS_120B: &str = "gpt-oss-120b";
74
75// Deprecated constants retained for backward compatibility in tests and internal code
76pub const GPT_5: &str = "gpt-5";
77pub const GPT_5_MINI: &str = "gpt-5-mini";
78pub const GPT_5_NANO: &str = "gpt-5-nano";
79pub const GPT_5_CODEX: &str = "gpt-5-codex";
80pub(crate) const GPT_5_1_CODEX: &str = "gpt-5.1-codex";
81pub(crate) const GPT_5_1_CODEX_MAX: &str = "gpt-5.1-codex-max";
82pub(crate) const GPT_5_1_CODEX_MINI: &str = "gpt-5.1-codex-mini";
83pub const GPT_5_2_CODEX: &str = "gpt-5.2-codex";
84const CODEX_MINI_LATEST: &str = "codex-mini-latest";
85pub const O3: &str = "o3";
86pub const O4_MINI: &str = "o4-mini";
87
88// Oct 2026 deprecation batch (announced 2026-10-01 / 2026-10-14).
89pub(crate) const GPT_5_3_CODEX: &str = "gpt-5.3-codex";
90pub(crate) const GPT_5_4_NANO: &str = "gpt-5.4-nano";
91pub(crate) const GPT_4O: &str = "gpt-4o";
92pub(crate) const GPT_4O_MINI: &str = "gpt-4o-mini";
93pub(crate) const GPT_4_1: &str = "gpt-4.1";
94pub(crate) const GPT_4_1_MINI: &str = "gpt-4.1-mini";
95
96/// Mapping of deprecated OpenAI model IDs to their recommended replacements.
97///
98/// Mappings follow the official OpenAI deprecation table:
99/// <https://developers.openai.com/api/docs/deprecations>.
100/// Replacements are chosen from models currently in `SUPPORTED_MODELS`.
101pub const DEPRECATED_MODEL_REPLACEMENTS: &[(&str, &str, &str)] = &[
102    // (deprecated_id, replacement_id, human-readable reason)
103    // GPT-5 / o3 family — shut down Dec 11, 2026
104    (GPT_5, "gpt-5.6-sol", "GPT-5 is deprecated; use GPT-5.6 Sol for frontier work"),
105    (GPT_5_MINI, "gpt-5.6-terra", "GPT-5 Mini is deprecated; use GPT-5.6 Terra for balanced tasks"),
106    (GPT_5_NANO, "gpt-5.6-luna", "GPT-5 Nano is deprecated; use GPT-5.6 Luna for lightweight tasks"),
107    (O3, "gpt-5.6-sol", "o3 is deprecated; use GPT-5.6 Sol for reasoning tasks"),
108    (O4_MINI, "gpt-5.6-terra", "o4-mini is deprecated; use GPT-5.6 Terra for fast reasoning"),
109    // Codex variants — shut down July 23, 2026 (Apr 1, 2026 for 5.x/5.1.x).
110    // Per OpenAI/GitHub Copilot deprecation notices, the direct successor is
111    // gpt-5.3-codex (the current Codex-optimised model).
112    (GPT_5_CODEX, GPT_5_6_SOL, "GPT-5 Codex is deprecated; use GPT-5.3 Codex for agentic coding"),
113    (GPT_5_1_CODEX, GPT_5_6_SOL, "GPT-5.1 Codex is deprecated; use GPT-5.3 Codex for agentic coding"),
114    (
115        GPT_5_1_CODEX_MAX,
116        GPT_5_6_SOL,
117        "GPT-5.1 Codex Max is deprecated; use GPT-5.3 Codex for long-running coding",
118    ),
119    (
120        GPT_5_1_CODEX_MINI,
121        GPT_5_6_SOL,
122        "GPT-5.1 Codex Mini is deprecated; use GPT-5.3 Codex for cost-effective coding",
123    ),
124    (GPT_5_2_CODEX, GPT_5_6_SOL, "GPT-5.2 Codex is deprecated; use GPT-5.3 Codex for agentic coding"),
125    (
126        CODEX_MINI_LATEST,
127        GPT_5_6_SOL,
128        "codex-mini-latest is deprecated; use GPT-5.3 Codex for cost-effective coding",
129    ),
130    // Oct 1, 2026 batch — shut down Apr 1, 2027.
131    (GPT_5_1, "gpt-6-sol", "GPT-5.1 is deprecated and shuts down Apr 1, 2027; use GPT-6 Sol"),
132    (
133        GPT_5_3_CODEX,
134        "gpt-6-sol",
135        "GPT-5.3 Codex is deprecated and shuts down Apr 1, 2027; use GPT-6 Sol for agentic coding",
136    ),
137    (GPT_5_4_NANO, "gpt-6-luna", "GPT-5.4 Nano is deprecated and shuts down Apr 1, 2027; use GPT-6 Luna"),
138    // Oct 14, 2026 GPT-4 series batch — shut down Jan 14, 2027.
139    (GPT_4O, "gpt-6-luna", "GPT-4o is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna"),
140    (
141        "gpt-4o-2024-08-06",
142        "gpt-6-luna",
143        "GPT-4o (2024-08-06) is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna",
144    ),
145    (
146        "gpt-4o-2024-11-20",
147        "gpt-6-luna",
148        "GPT-4o (2024-11-20) is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna",
149    ),
150    (GPT_4O_MINI, "gpt-6-luna", "GPT-4o mini is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna"),
151    (
152        "gpt-4o-mini-2024-07-18",
153        "gpt-6-luna",
154        "GPT-4o mini (2024-07-18) is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna",
155    ),
156    (GPT_4_1, "gpt-6-luna", "GPT-4.1 is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna"),
157    (
158        "gpt-4.1-2025-04-14",
159        "gpt-6-luna",
160        "GPT-4.1 (2025-04-14) is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna",
161    ),
162    (GPT_4_1_MINI, "gpt-6-luna", "GPT-4.1 mini is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna"),
163    (
164        "gpt-4.1-mini-2025-04-14",
165        "gpt-6-luna",
166        "GPT-4.1 mini (2025-04-14) is deprecated and shuts down Jan 14, 2027; use GPT-6 Luna",
167    ),
168    // Jun 11, 2026 GPT-5/o3 snapshots — shut down Dec 11, 2026.
169    (
170        "gpt-5-2025-08-07",
171        "gpt-5.6-sol",
172        "GPT-5 snapshot 2025-08-07 is deprecated and shuts down Dec 11, 2026; use GPT-5.6 Sol",
173    ),
174    (
175        "gpt-5-mini-2025-08-07",
176        "gpt-5.6-terra",
177        "GPT-5 Mini snapshot 2025-08-07 is deprecated and shuts down Dec 11, 2026; use GPT-5.6 Terra",
178    ),
179    (
180        "gpt-5-nano-2025-08-07",
181        "gpt-5.6-luna",
182        "GPT-5 Nano snapshot 2025-08-07 is deprecated and shuts down Dec 11, 2026; use GPT-5.6 Luna",
183    ),
184    (
185        "gpt-5-pro-2025-10-06",
186        "gpt-5.6-sol",
187        "GPT-5 Pro snapshot 2025-10-06 is deprecated and shuts down Dec 11, 2026; use GPT-5.6 Sol",
188    ),
189    (
190        "o3-2025-04-16",
191        "gpt-5.6-sol",
192        "o3 snapshot 2025-04-16 is deprecated and shuts down Dec 11, 2026; use GPT-5.6 Sol",
193    ),
194    (
195        "o3-pro-2025-06-10",
196        "gpt-5.6-sol",
197        "o3 Pro snapshot 2025-06-10 is deprecated and shuts down Dec 11, 2026; use GPT-5.6 Sol",
198    ),
199    // Apr 22, 2026 legacy snapshots — shut down Oct 23, 2026.
200    (
201        "gpt-3.5-turbo-0125",
202        "gpt-5.6-terra",
203        "GPT-3.5 Turbo snapshot 0125 is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Terra",
204    ),
205    (
206        "gpt-4-0613",
207        "gpt-5.6-sol",
208        "GPT-4 snapshot 0613 is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Sol",
209    ),
210    (
211        "gpt-4-turbo-2024-04-09",
212        "gpt-5.6-sol",
213        "GPT-4 Turbo snapshot 2024-04-09 is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Sol",
214    ),
215    (
216        "gpt-4.1-nano-2025-04-14",
217        "gpt-5.6-luna",
218        "GPT-4.1 Nano is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Luna",
219    ),
220    (
221        "gpt-4o-2024-05-13",
222        "gpt-5.6-sol",
223        "GPT-4o snapshot 2024-05-13 is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Sol",
224    ),
225    ("o1-2024-12-17", "gpt-5.6-sol", "o1 is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Sol"),
226    (
227        "o1-pro-2025-03-19",
228        "gpt-5.6-sol",
229        "o1 Pro is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Sol",
230    ),
231    (
232        "o3-mini-2025-01-31",
233        "gpt-5.6-sol",
234        "o3 Mini is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Sol",
235    ),
236    (
237        "o4-mini-2025-04-16",
238        "gpt-5.6-terra",
239        "o4 Mini snapshot 2025-04-16 is deprecated and shuts down Oct 23, 2026; use GPT-5.6 Terra",
240    ),
241    // Chat / specialized variants already shut down.
242    ("gpt-5-chat-latest", "gpt-5.6-sol", "GPT-5 Chat is deprecated; use GPT-5.6 Sol"),
243    ("gpt-5.1-chat-latest", "gpt-5.6-sol", "GPT-5.1 Chat is deprecated; use GPT-5.6 Sol"),
244    (
245        "gpt-5.2-chat-latest",
246        "gpt-5.6-sol",
247        "GPT-5.2 Chat is deprecated and shut down Aug 10, 2026; use GPT-5.6 Sol",
248    ),
249    (
250        "gpt-5.3-chat-latest",
251        "gpt-5.6-sol",
252        "GPT-5.3 Chat is deprecated and shut down Aug 10, 2026; use GPT-5.6 Sol",
253    ),
254];
255
256/// Returns the recommended replacement for a deprecated OpenAI model, if known.
257///
258/// Returns `Some((replacement_id, reason))` when the model is a known
259/// deprecated ID, or `None` when it is either current or unrecognized.
260#[must_use]
261pub fn deprecated_model_replacement(model: &str) -> Option<(&'static str, &'static str)> {
262    DEPRECATED_MODEL_REPLACEMENTS
263        .iter()
264        .find(|(deprecated, _, _)| *deprecated == model)
265        .map(|(_, replacement, reason)| (*replacement, *reason))
266}
267
268#[cfg(test)]
269mod tests {
270    use super::*;
271
272    #[test]
273    fn deprecated_gpt5_maps_to_gpt56_sol() {
274        let (replacement, reason) = deprecated_model_replacement(GPT_5).expect("gpt-5 is deprecated");
275        assert_eq!(replacement, "gpt-5.6-sol");
276        assert!(reason.contains("GPT-5.6 Sol"));
277    }
278
279    #[test]
280    fn deprecated_codex_models_map_to_gpt53_codex() {
281        for (deprecated, expected) in [
282            (GPT_5_CODEX, GPT_5_6_SOL),
283            (GPT_5_1_CODEX, GPT_5_6_SOL),
284            (GPT_5_1_CODEX_MAX, GPT_5_6_SOL),
285            (GPT_5_1_CODEX_MINI, GPT_5_6_SOL),
286            (GPT_5_2_CODEX, GPT_5_6_SOL),
287            (CODEX_MINI_LATEST, GPT_5_6_SOL),
288        ] {
289            let (replacement, _reason) =
290                deprecated_model_replacement(deprecated).unwrap_or_else(|| panic!("{deprecated} should be deprecated"));
291            assert_eq!(replacement, expected, "replacement for {deprecated}");
292        }
293    }
294
295    #[test]
296    fn current_models_have_no_replacement() {
297        assert!(deprecated_model_replacement(GPT_5_6_SOL).is_none());
298        assert!(deprecated_model_replacement(GPT_5_6_SOL).is_none());
299        assert!(deprecated_model_replacement("gpt-5.6-sol").is_none());
300    }
301
302    #[test]
303    fn unknown_models_have_no_replacement() {
304        assert!(deprecated_model_replacement("nonexistent-model").is_none());
305        assert!(deprecated_model_replacement("").is_none());
306    }
307
308    #[test]
309    fn supported_models_excludes_deprecated() {
310        let deprecated_ids: Vec<&str> = DEPRECATED_MODEL_REPLACEMENTS.iter().map(|(id, _, _)| *id).collect();
311        for deprecated in &deprecated_ids {
312            assert!(
313                !SUPPORTED_MODELS.contains(deprecated),
314                "deprecated model {deprecated} should not appear in SUPPORTED_MODELS"
315            );
316        }
317    }
318
319    #[test]
320    fn replacement_targets_are_current_models() {
321        // Every replacement must be a currently supported (non-deprecated) model.
322        for (_, replacement, _) in DEPRECATED_MODEL_REPLACEMENTS {
323            assert!(
324                SUPPORTED_MODELS.contains(replacement),
325                "replacement target {replacement} must be in SUPPORTED_MODELS"
326            );
327            assert!(
328                deprecated_model_replacement(replacement).is_none(),
329                "replacement target {replacement} must not itself be deprecated"
330            );
331        }
332    }
333}