mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
fix(proxy): align Codex OAuth client identity
ChatGPT's Codex backend routes model availability by the originator and version header pair. Requests identifying as cc-switch without a version were assigned to a cohort where gpt-5.6-luna resolved to an unavailable internal engine, resulting in a misleading 404 Model not found response. Identify takeover requests as codex_cli_rs and send version 0.144.1, satisfying luna's minimal_client_version requirement of 0.144.0. A direct HTTP A/B test confirmed the existing headers returned 404 while the aligned identity completed successfully, so no WebSocket transport workaround is required.
This commit is contained in:
@@ -124,7 +124,7 @@ pub enum AuthStrategy {
|
|||||||
///
|
///
|
||||||
/// - Header: `Authorization: Bearer <access_token>`
|
/// - Header: `Authorization: Bearer <access_token>`
|
||||||
/// - Header: `ChatGPT-Account-Id: <account_id>` (来自 forwarder 注入)
|
/// - Header: `ChatGPT-Account-Id: <account_id>` (来自 forwarder 注入)
|
||||||
/// - Header: `originator: cc-switch`
|
/// - Header: `originator: codex_cli_rs` + `version: <codex 版本>`(成对,后端按此做模型 cohort 路由)
|
||||||
///
|
///
|
||||||
/// 使用动态获取的 OpenAI access_token(通过 Device Code 流程获取)
|
/// 使用动态获取的 OpenAI access_token(通过 Device Code 流程获取)
|
||||||
CodexOAuth,
|
CodexOAuth,
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ const ANTHROPIC_REDACTED_THINKING_PLACEHOLDER: &str = "[redacted thinking]";
|
|||||||
// Keep hints lowercase; matching lowercases only the input value.
|
// Keep hints lowercase; matching lowercases only the input value.
|
||||||
const REASONING_VENDOR_HINTS: &[&str] = &["moonshot", "kimi", "deepseek", "mimo", "xiaomimimo"];
|
const REASONING_VENDOR_HINTS: &[&str] = &["moonshot", "kimi", "deepseek", "mimo", "xiaomimimo"];
|
||||||
|
|
||||||
|
// ChatGPT Codex 后端按 originator+version 组合做模型 cohort 路由:非官方身份会把
|
||||||
|
// gpt-5.6-luna 解析到未部署的内部引擎(HTTP 404 Model not found,openai/codex#31967,
|
||||||
|
// 本机 A/B 实测确认)。两个头必须成对发送,缺一即 404;version 需 ≥ 目标模型
|
||||||
|
// catalog 的 minimal_client_version(luna=0.144.0),新模型抬门槛时同步 bump。
|
||||||
|
const CODEX_OAUTH_ORIGINATOR: &str = "codex_cli_rs";
|
||||||
|
const CODEX_OAUTH_CLIENT_VERSION: &str = "0.144.1";
|
||||||
|
|
||||||
/// 获取 Claude 供应商的 API 格式
|
/// 获取 Claude 供应商的 API 格式
|
||||||
///
|
///
|
||||||
/// 供 handler/forwarder 外部使用的公开函数。
|
/// 供 handler/forwarder 外部使用的公开函数。
|
||||||
@@ -843,7 +850,11 @@ impl ProviderAdapter for ClaudeAdapter {
|
|||||||
(HeaderName::from_static("authorization"), hv(&bearer)?),
|
(HeaderName::from_static("authorization"), hv(&bearer)?),
|
||||||
(
|
(
|
||||||
HeaderName::from_static("originator"),
|
HeaderName::from_static("originator"),
|
||||||
HeaderValue::from_static("cc-switch"),
|
HeaderValue::from_static(CODEX_OAUTH_ORIGINATOR),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
HeaderName::from_static("version"),
|
||||||
|
HeaderValue::from_static(CODEX_OAUTH_CLIENT_VERSION),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user