Add BYOK GPT-5.2-codex support (#47025)

<img width="449" height="559" alt="Screenshot 2026-01-16 at 4 52 12 PM"
src="https://github.com/user-attachments/assets/1b5583d7-9b90-46b1-a32f-9821543ea542"
/>

Release Notes:

- Add support for GPT-5.2-Codex via OpenAI API Key
This commit is contained in:
Richard Feldman 2026-01-16 17:09:08 -05:00 committed by GitHub
parent 3389d84e03
commit e5706f2349
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -310,6 +310,7 @@ impl LanguageModel for OpenAiLanguageModel {
| Model::FiveNano
| Model::FivePointOne
| Model::FivePointTwo
| Model::FivePointTwoCodex
| Model::O1
| Model::O3
| Model::O4Mini => true,
@ -1166,8 +1167,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)
}
}

View file

@ -93,6 +93,8 @@ pub enum Model {
FivePointOne,
#[serde(rename = "gpt-5.2")]
FivePointTwo,
#[serde(rename = "gpt-5.2-codex")]
FivePointTwoCodex,
#[serde(rename = "custom")]
Custom {
name: String,
@ -137,6 +139,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}'"),
}
}
@ -161,6 +164,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,
}
}
@ -185,6 +189,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),
@ -211,6 +216,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,
}
}
@ -238,6 +244,7 @@ impl Model {
Self::FiveNano => Some(128_000),
Self::FivePointOne => Some(128_000),
Self::FivePointTwo => Some(128_000),
Self::FivePointTwoCodex => Some(128_000),
}
}
@ -256,7 +263,7 @@ impl Model {
supports_chat_completions,
..
} => *supports_chat_completions,
Self::FiveCodex => false,
Self::FiveCodex | Self::FivePointTwoCodex => false,
_ => true,
}
}
@ -279,6 +286,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,
}