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