From d4cfed48f93f64349d169f776aa274dfd4060624 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 22:32:17 +0000 Subject: [PATCH] Add BYOK GPT-5.2-codex support (#47025) (cherry-pick to stable) (#47031) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-pick of #47025 to stable ---- Screenshot 2026-01-16 at 4 52 12 PM Release Notes: - Add support for GPT-5.2-Codex via OpenAI API Key Co-authored-by: Richard Feldman --- crates/language_models/src/provider/open_ai.rs | 5 +++-- crates/open_ai/src/open_ai.rs | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/language_models/src/provider/open_ai.rs b/crates/language_models/src/provider/open_ai.rs index abd7d7ee36b807c4ff2844f610a8fe60ee464519..fe3fe143abbb9593bb7da39772e28cbea65761a7 100644 --- a/crates/language_models/src/provider/open_ai.rs +++ b/crates/language_models/src/provider/open_ai.rs @@ -311,6 +311,7 @@ impl LanguageModel for OpenAiLanguageModel { | Model::FiveNano | Model::FivePointOne | Model::FivePointTwo + | Model::FivePointTwoCodex | Model::O1 | Model::O3 | Model::O4Mini => true, @@ -1172,8 +1173,8 @@ pub fn count_open_ai_tokens( | Model::FiveCodex | Model::FiveMini | Model::FiveNano => tiktoken_rs::num_tokens_from_messages(model.id(), &messages), - // GPT-5.1 and 5.2 don't have dedicated tiktoken support; use gpt-5 tokenizer - Model::FivePointOne | Model::FivePointTwo => { + // GPT-5.1, 5.2, and 5.2-codex don't have dedicated tiktoken support; use gpt-5 tokenizer + Model::FivePointOne | Model::FivePointTwo | Model::FivePointTwoCodex => { tiktoken_rs::num_tokens_from_messages("gpt-5", &messages) } } diff --git a/crates/open_ai/src/open_ai.rs b/crates/open_ai/src/open_ai.rs index 07c913b2e7af8b50b35ca90fccbea90364ff1980..57e9db1a352daf3c24c814f44ced45073663329a 100644 --- a/crates/open_ai/src/open_ai.rs +++ b/crates/open_ai/src/open_ai.rs @@ -91,6 +91,8 @@ pub enum Model { FivePointOne, #[serde(rename = "gpt-5.2")] FivePointTwo, + #[serde(rename = "gpt-5.2-codex")] + FivePointTwoCodex, #[serde(rename = "custom")] Custom { name: String, @@ -135,6 +137,7 @@ impl Model { "gpt-5-nano" => Ok(Self::FiveNano), "gpt-5.1" => Ok(Self::FivePointOne), "gpt-5.2" => Ok(Self::FivePointTwo), + "gpt-5.2-codex" => Ok(Self::FivePointTwoCodex), invalid_id => anyhow::bail!("invalid model id '{invalid_id}'"), } } @@ -159,6 +162,7 @@ impl Model { Self::FiveNano => "gpt-5-nano", Self::FivePointOne => "gpt-5.1", Self::FivePointTwo => "gpt-5.2", + Self::FivePointTwoCodex => "gpt-5.2-codex", Self::Custom { name, .. } => name, } } @@ -183,6 +187,7 @@ impl Model { Self::FiveNano => "gpt-5-nano", Self::FivePointOne => "gpt-5.1", Self::FivePointTwo => "gpt-5.2", + Self::FivePointTwoCodex => "gpt-5.2-codex", Self::Custom { name, display_name, .. } => display_name.as_ref().unwrap_or(name), @@ -209,6 +214,7 @@ impl Model { Self::FiveNano => 272_000, Self::FivePointOne => 400_000, Self::FivePointTwo => 400_000, + Self::FivePointTwoCodex => 400_000, Self::Custom { max_tokens, .. } => *max_tokens, } } @@ -236,6 +242,7 @@ impl Model { Self::FiveNano => Some(128_000), Self::FivePointOne => Some(128_000), Self::FivePointTwo => Some(128_000), + Self::FivePointTwoCodex => Some(128_000), } } @@ -254,7 +261,7 @@ impl Model { supports_chat_completions, .. } => *supports_chat_completions, - Self::FiveCodex => false, + Self::FiveCodex | Self::FivePointTwoCodex => false, _ => true, } } @@ -277,6 +284,7 @@ impl Model { | Self::FiveMini | Self::FivePointOne | Self::FivePointTwo + | Self::FivePointTwoCodex | Self::FiveNano => true, Self::O1 | Self::O3 | Self::O3Mini | Self::O4Mini | Model::Custom { .. } => false, }