BigPizzaV3/CodexPlusPlus · error · anyhow::Error
OpenAI 会话身份仅支持 Responses API
Error message
OpenAI 会话身份仅支持 Responses API
What it means
apply_relay_config_to_home_with_session_provider (crates/codex-plus-core/src/relay_config.rs:335) enforces that the OpenAI session identity (RelaySessionProvider::Openai, ChatGPT-style login auth) is only combined with the Responses wire protocol. Codex OpenAI-session auth works only against the Responses API, so a chat-protocol config would break at runtime; this guard fails at apply time instead.
Source
Thrown at crates/codex-plus-core/src/relay_config.rs:335
pub fn apply_relay_config_to_home_with_session_provider(
home: &Path,
base_url: &str,
bearer_token: &str,
protocol: RelayProtocol,
proxy_port: u16,
session_provider: RelaySessionProvider,
) -> anyhow::Result<RelayApplyResult> {
let base_url = base_url.trim();
if base_url.is_empty() {
anyhow::bail!("中转 Base URL 不能为空");
}
let bearer_token = bearer_token.trim();
if bearer_token.is_empty() {
anyhow::bail!("中转 Key 不能为空");
}
if session_provider == RelaySessionProvider::Openai && protocol != RelayProtocol::Responses {
anyhow::bail!("OpenAI 会话身份仅支持 Responses API");
}
let codex_base_url = codex_base_url_for_protocol(base_url, protocol, proxy_port);
let updated = upsert_model_provider_config_with_session_provider(
"",
&codex_base_url,
bearer_token,
true,
session_provider,
)?;
let auth_contents = serde_json::to_string_pretty(&json!({
"OPENAI_API_KEY": bearer_token
}))?;
let backup_path =
write_codex_live_atomic(home, Some(&updated), Some(auth_contents.as_bytes()))?;
let status = relay_config_status_from_home(home);
Ok(RelayApplyResult {
config_path: status.config_path,
backup_path,View on GitHub (pinned to f2074595a2)
Solutions
- Keep protocol = Responses whenever the session provider is Openai
- Switch to RelaySessionProvider::Custom with an API key if the upstream only speaks chat completions
- In the UI, disable the chat protocol option (or auto-reset the session provider to Custom) while OpenAI login is active
Example fix
// before apply_relay_config_to_home_with_session_provider(&home, url, &token, RelayProtocol::ChatCompletions, port, RelaySessionProvider::Openai)?; // after apply_relay_config_to_home_with_session_provider(&home, url, &token, RelayProtocol::Responses, port, RelaySessionProvider::Openai)?;
Defensive patterns
Strategy: validation
Validate before calling
fn session_protocol_combo_ok(provider: RelaySessionProvider, protocol: RelayProtocol) -> bool {
provider != RelaySessionProvider::Openai || protocol == RelayProtocol::Responses
}
if !session_protocol_combo_ok(provider, protocol) {
anyhow::bail!("OpenAI session identity requires Responses; use a Custom provider for chat");
} Try / catch
if let Err(e) = apply_relay_config_to_home_with_session_provider(&home, url, token, protocol, port, provider) {
if e.to_string().contains("OpenAI") {
// invalid combo: pick Responses + Openai, or chat + Custom; do not retry unchanged
}
} Prevention
- Encode the invariant in the UI: OpenAI session login forces wire protocol Responses
- When the user picks chat protocol, auto-switch the session provider to Custom and ask for an API key
- Keep a unit test asserting the (Openai, ChatCompletions) combination stays rejected
When it happens
Trigger: Calling apply_relay_config_to_home_with_session_provider with session_provider = RelaySessionProvider::Openai and protocol = RelayProtocol::ChatCompletions. apply_relay_config_to_home_with_protocol always passes Custom, so this comes from the session-provider-aware entry point used by official-login flows.
Common situations: A user logs in with an OpenAI account, then switches the profile wire protocol to chat to reach a chat-only aggregator, and the UI forwards the Openai session provider together with the chat protocol.
Related errors
- Chat Completions 协议暂不支持 Responses compact 请求
- 中转 Base URL 不能为空
- 中转 Key 不能为空
- config.toml 内容不能为空
- 发送微信回复被拒绝:ret={} errcode={} {}
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23).
Data as JSON: /api/errors/deffc367da3eb5d0.
Report an issue: GitHub.