{"record":{"id":"cef81aab07305fbd","repo":"Hmbown/CodeWhale","slug":"responses-api-error-http-status-raw","errorCode":null,"errorMessage":"Responses API error (HTTP {status}): {raw}","messagePattern":"Responses API error \\(HTTP (.+?)\\): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/client/responses.rs","lineNumber":191,"sourceCode":"                            .header(\"OpenAI-Beta\", \"responses=experimental\")\n                            .header(\"originator\", \"codex_cli_rs\");\n                        if let Some(account_id) = &account_id {\n                            builder = builder.header(\"chatgpt-account-id\", account_id);\n                        }\n                    }\n                    builder.body(request_body.clone())\n                })\n                .await\n                .context(\"Responses API request failed\")\n            }\n        })\n        .await?;\n\n        let status = response.status();\n        crate::client::record_provider_response(self.api_provider, status.as_u16());\n        if !status.is_success() {\n            let raw = bounded_error_text(response, ERROR_BODY_MAX_BYTES).await;\n            anyhow::bail!(\"Responses API error (HTTP {status}): {raw}\");\n        }\n\n        let stream_idle_timeout = self.stream_idle_timeout;\n        let byte_stream = response.bytes_stream();\n\n        let stream = async_stream::stream! {\n            use futures_util::StreamExt;\n\n            // Emit synthetic MessageStart.\n            yield Ok(StreamEvent::MessageStart {\n                message: MessageResponse {\n                    id: String::new(),\n                    r#type: \"message\".to_string(),\n                    role: \"assistant\".to_string(),\n                    content: vec![],\n                    model: wire_model.clone(),\n                    stop_reason: None,\n                    stop_sequence: None,","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/client/responses.rs#L173-L209","documentation":"The OpenAI Responses API request returned a non-2xx status. The body is read bounded (`bounded_error_text` up to `ERROR_BODY_MAX_BYTES`) and embedded raw (unlike the chat route, no sanitization pass here), and the status is recorded via `record_provider_response`. Transport-level failures to even send the request surface separately as \"Responses API request failed\" via `.context`.","triggerScenarios":"401 invalid API key; 404 unknown model or wrong base URL; 400 invalid parameters per the embedded message; 429 rate limit/quota; 5xx provider errors.","commonSituations":"Expired or mistyped OpenAI key; requesting a deprecated or nonexistent model id; Responses API not enabled for the account/key; bursts hitting org rate limits.","solutions":["Read the HTTP status and raw body first — the provider message identifies the exact cause","401/403: fix the API key and its Responses API access","429: back off and retry; reduce request rate","400/404: correct the model id, base URL, and request fields per the body text"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"fn is_retryable_http_status_from_message(msg: &str) -> bool {\n    [408, 409, 429, 500, 502, 503, 504]\n        .iter()\n        .any(|s| msg.contains(&format!(\"HTTP {s}\")))\n}","tryCatchPattern":"match client.send_responses(request).await {\n    Err(e) if is_retryable_http_status_from_message(&e.to_string()) => {\n        backoff_retry(client, request, MAX_ATTEMPTS).await\n    }\n    Err(e) if e.to_string().contains(\"HTTP 401\") || e.to_string().contains(\"HTTP 403\") => {\n        Err(e) // credentials/access: fix the key, never retry\n    }\n    result => result,\n}","preventionTips":["Verify the API key has Responses API access before relying on the route","Confirm model ids against current OpenAI docs at config time","Apply exponential backoff on 429 and 5xx; parse the raw body for the exact cause"],"tags":["openai","responses-api","http","status-code"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}