BigPizzaV3/CodexPlusPlus · error

当前中转未启用 Chat Completions 协议代理

Error message

当前中转未启用 Chat Completions 协议代理

What it means

Thrown by open_chat_completions_proxy_request in crates/codex-plus-core/src/protocol_proxy.rs when the chat completions proxy endpoint is called but the currently active relay profile's protocol is not RelayProtocol::ChatCompletions. The /chat/completions passthrough is only enabled for relays configured for the Chat Completions wire API; a Responses-protocol relay must use the responses proxy path instead.

Source

Thrown at crates/codex-plus-core/src/protocol_proxy.rs:872

    })
}

fn response_header_timeout(is_stream: bool) -> Duration {
    if is_stream {
        UPSTREAM_STREAM_HEADER_TIMEOUT
    } else {
        UPSTREAM_HEADER_TIMEOUT
    }
}

pub async fn open_chat_completions_proxy_request(
    body: &str,
    original_user_agent: Option<&str>,
) -> anyhow::Result<UpstreamProxyResponse> {
    let settings = SettingsStore::default().load().unwrap_or_default();
    let relay = settings.active_relay_profile();
    if relay.protocol != RelayProtocol::ChatCompletions {
        anyhow::bail!("当前中转未启用 Chat Completions 协议代理");
    }
    if relay.base_url.trim().is_empty() {
        anyhow::bail!("Chat Completions 上游 Base URL 不能为空");
    }
    if relay.api_key.trim().is_empty() {
        anyhow::bail!("Chat Completions 上游 Key 不能为空");
    }

    let request_json: Value = serde_json::from_str(body)?;
    let is_stream = request_json
        .get("stream")
        .and_then(Value::as_bool)
        .unwrap_or(false);
    let upstream = crate::http_client::proxied_client(&effective_user_agent(
        &relay.user_agent,
        original_user_agent,
    ))?
    .post(chat_completions_url(&relay.base_url))

View on GitHub (pinned to 1f431ae49b)

Solutions

  1. Switch the active relay profile's protocol to Chat Completions in the manager, or
  2. Point the client at the responses proxy path (/v1/responses) if the active provider speaks the Responses API
  3. Verify after any provider switch which wire API the new active profile uses before reusing old endpoint URLs
Defensive patterns

Strategy: validation

Validate before calling

let settings = SettingsStore::default().load().unwrap_or_default();
if settings.active_relay_profile().protocol != RelayProtocol::ChatCompletions {
    anyhow::bail!("active provider must use the Chat Completions protocol for this endpoint");
}

Prevention

When it happens

Trigger: Client POSTs to the proxy's /v1/chat/completions path while the active provider profile is configured with protocol = Responses; user switched the active provider but the client kept calling the chat completions endpoint.

Common situations: Switching active provider from a chat-completions vendor to a responses vendor without updating the client's endpoint; test scripts hardcoded to /v1/chat/completions; profile misconfiguration where the user intended Chat Completions but left protocol as Responses.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@1f431ae49b (2026-08-16). Data as JSON: /api/errors/19759313ad3c6896. Report an issue: GitHub.