Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/src/content/docs/providers/codex.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The proxy owns its tokens and does not read native Codex CLI credentials. It ref

## Models and fast mode

Use `claude-code-proxy models` as the current catalog. Model access depends on your ChatGPT account. A model rejected by the subscription produces the upstream error verbatim.
Select GPT-6.2 with `ANTHROPIC_MODEL=gpt-6.2-sol` or `ANTHROPIC_MODEL=gpt-6.2-astra`. Use `claude-code-proxy models` as the current catalog. Model access depends on your ChatGPT account. A model rejected by the subscription produces the upstream error verbatim.

The proxy also reads the Codex CLI's optional `$CODEX_HOME/models_cache.json`
(default `~/.codex/models_cache.json`) to recognize additional models. Listed
Expand Down Expand Up @@ -78,8 +78,9 @@ The gpt-5.6 and gpt-6 families use Responses Lite by default. Lite requires
`parallel_tool_calls: false`, so function tools run serially. Set
`codex.fullLane: true` or `CCP_CODEX_FULL_LANE=1` to use the full Responses lane
for `gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6.1-sol`,
and `gpt-6.1-terra`. This permits parallel calls; the model still decides whether to batch tools, and explicit
client restrictions on parallel tools remain effective.
`gpt-6.1-terra`, `gpt-6.2-astra`, and `gpt-6.2-sol`. This permits parallel calls.
The model decides whether to batch tools and respects explicit client
restrictions on parallel calls.

This is not a universal lane override: catalog-only models keep the lane
specified in the local Codex model cache. Luna models stay on Lite.
Expand Down
32 changes: 23 additions & 9 deletions src/providers/codex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2504,8 +2504,27 @@ mod tests {
}

#[test]
fn terra_translation_preserves_model_and_tier_across_lanes() {
for requested in ["gpt-6.1-terra", "gpt-6.1-terra-fast"] {
fn translation_preserves_model_and_tier_across_lanes() {
for (requested, model, tier) in [
("gpt-6.1-terra", "gpt-6.1-terra", None),
(
"gpt-6.1-terra-fast",
"gpt-6.1-terra",
Some(ServiceTier::Priority),
),
(
"gpt-6.2-astra-fast",
"gpt-6.2-astra",
Some(ServiceTier::Priority),
),
(
"gpt-6.2-sol-fast",
"gpt-6.2-sol",
Some(ServiceTier::Priority),
),
("gpt-6.2-astra", "gpt-6.2-astra", None),
("gpt-6.2-sol", "gpt-6.2-sol", None),
] {
for hosted_search in [false, true] {
let tools = if hosted_search {
serde_json::json!([{"type":"web_search_20250305", "name":"web_search"}])
Expand All @@ -2526,14 +2545,9 @@ mod tests {
},
)
.unwrap();
assert_eq!(translated.model, "gpt-6.1-terra");
assert_eq!(translated.model, model, "{requested}");
assert_eq!(translated.client_metadata.is_some(), !hosted_search);
assert_eq!(
translated.service_tier,
requested
.ends_with("-fast")
.then_some(ServiceTier::Priority)
);
assert_eq!(translated.service_tier, tier, "{requested}");
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/providers/codex/translate/model_allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub const ALLOWED_MODELS: &[&str] = &[
"gpt-6-sol",
"gpt-6.1-sol",
"gpt-6.1-terra",
"gpt-6.2-astra",
"gpt-6.2-sol",
];

pub const MODEL_ALIASES: &[(&str, &str)] = &[
Expand Down Expand Up @@ -81,7 +83,7 @@ pub fn allowed_models_display() -> String {
allowed_models().join(", ")
}

/// Models whose Codex catalog entry offers the `ultrafast` service tier.
/// Models that offer the `ultrafast` service tier in Codex.
/// Every other model offers `priority` at most, so it gets no `-ultrafast` form.
pub const ULTRAFAST_MODELS: &[&str] = &["gpt-6-astra", "gpt-6.1-sol"];

Expand Down Expand Up @@ -207,6 +209,8 @@ pub fn uses_responses_lite(model: &str) -> bool {
| "gpt-6-sol"
| "gpt-6.1-sol"
| "gpt-6.1-terra"
| "gpt-6.2-astra"
| "gpt-6.2-sol"
) || (!ALLOWED_MODELS.contains(&model)
&& catalog_model(model)
.is_some_and(|entry| entry.supported_in_api && entry.use_responses_lite))
Expand All @@ -224,6 +228,8 @@ pub fn uses_responses_lite_with_full_lane(model: &str, full_lane: bool) -> bool
| "gpt-6-sol"
| "gpt-6.1-sol"
| "gpt-6.1-terra"
| "gpt-6.2-astra"
| "gpt-6.2-sol"
)
{
return false;
Expand Down Expand Up @@ -272,6 +278,8 @@ mod tests {
"gpt-6-sol",
"gpt-6.1-sol",
"gpt-6.1-terra",
"gpt-6.2-astra",
"gpt-6.2-sol",
] {
assert!(uses_responses_lite_with_full_lane(model, false), "{model}");
assert!(!uses_responses_lite_with_full_lane(model, true), "{model}");
Expand Down
29 changes: 9 additions & 20 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use crate::{
anthropic::{json_error, schema::MessagesRequest},
config::AliasProvider,
provider::{CliHandlers, Provider, RequestContext},
providers::codex::translate::model_allowlist::tier_model_variants,
providers::codex::translate::model_allowlist::{
ALLOWED_MODELS, listed_catalog_models, tier_model_variants,
},
};
use anyhow::{Result, anyhow};
use async_trait::async_trait;
Expand Down Expand Up @@ -39,23 +41,6 @@ const CURSOR_LEGACY_MODELS: &[&str] = &[
"composer-2.5-fast",
];

pub(crate) const CODEX_MODELS: &[&str] = &[
"gpt-5.2",
"gpt-5.3-codex",
"gpt-5.3-codex-spark",
"gpt-5.4",
"gpt-5.4-mini",
"gpt-5.5",
"gpt-5.6-luna",
"gpt-5.6-sol",
"gpt-5.6-terra",
"gpt-6-astra",
"gpt-6-luna",
"gpt-6-sol",
"gpt-6.1-sol",
"gpt-6.1-terra",
];

pub(crate) const KIMI_MODELS: &[&str] = &["kimi-for-coding", "kimi-k2.6", "kimi-k3", "k2.6", "k3"];
pub(crate) const GROK_MODELS: &[&str] =
&["grok-composer-2.5-fast", "grok-4.5", "grok-4.6", "grok-4.7"];
Expand Down Expand Up @@ -342,8 +327,8 @@ pub(crate) fn expand_codex_models() -> Vec<String> {
let mut out = Vec::new();
// Baseline ∪ models the Codex CLI advertises in its own model cache, so a
// model OpenAI ships to Codex routes here before a proxy release lists it.
let catalog = crate::providers::codex::translate::model_allowlist::listed_catalog_models();
for model in CODEX_MODELS
let catalog = listed_catalog_models();
for model in ALLOWED_MODELS
.iter()
.map(|model| (*model).to_string())
.chain(catalog)
Expand Down Expand Up @@ -486,6 +471,10 @@ mod tests {
"gpt-6.1-sol-fast",
"gpt-6.1-terra",
"gpt-6.1-terra-fast",
"gpt-6.2-astra",
"gpt-6.2-astra-fast",
"gpt-6.2-sol",
"gpt-6.2-sol-fast",
] {
assert_eq!(
registry.provider_for_model(model, None).unwrap().name(),
Expand Down
2 changes: 2 additions & 0 deletions tests/codex_model_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ async fn catalog_drives_discovery_routing_tiers_and_lanes_in_actual_process() {
true,
Some("ultrafast"),
),
("gpt-6.2-astra", "gpt-6.2-astra", true, None),
("gpt-6.2-sol-fast", "gpt-6.2-sol", true, Some("priority")),
] {
let response = client
.post(format!("{url}/v1/responses"))
Expand Down
10 changes: 10 additions & 0 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,16 @@ async fn models_endpoint_lists_supported_models() {
assert!(ids.contains(&"gpt-6.1-terra-fast"));
assert!(ids.contains(&"gpt-6-astra-ultrafast"));
assert!(ids.contains(&"gpt-6.1-sol-ultrafast"));
for id in [
"gpt-6.2-astra",
"gpt-6.2-astra-fast",
"gpt-6.2-sol",
"gpt-6.2-sol-fast",
] {
assert!(ids.contains(&id), "{id}");
}
assert!(!ids.contains(&"gpt-6.2-astra-ultrafast"));
assert!(!ids.contains(&"gpt-6.2-sol-ultrafast"));
assert!(!ids.contains(&"gpt-6-sol-ultrafast"));
assert!(ids.contains(&"grok-4.6"));
for entry in data {
Expand Down