{"record":{"id":"4ca962453c06cbe3","repo":"unslothai/unsloth","slug":"chatgpt-codex-request-failed-response-status-cod","errorCode":null,"errorMessage":"ChatGPT Codex request failed ({response.status_code}).{suffix}","messagePattern":"ChatGPT Codex request failed \\((.+?)\\)\\.(.+?)","errorType":"exception","errorClass":"CodexTransportError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/inference/openai_codex_client.py","lineNumber":406,"sourceCode":"                        metadata = {\"access_token\": token},\n                    )\n                retryable = response.status_code in _RETRYABLE_STATUSES and not _is_terminal_quota(\n                    detail\n                )\n                if retryable and attempt < _MAX_TRANSIENT_RETRIES:\n                    await _retry_pause(_retry_delay_seconds(response, attempt), cancel_event)\n                    if cancel_event is not None and cancel_event.is_set():\n                        yield None\n                        return\n                    continue\n                if response.status_code == 429:\n                    raise CodexQuotaError(\n                        \"ChatGPT subscription quota is temporarily unavailable.\",\n                        status = 429,\n                        metadata = _quota_metadata(response),\n                    )\n                suffix = f\" {detail}\" if detail else \"\"\n                raise CodexTransportError(\n                    f\"ChatGPT Codex request failed ({response.status_code}).{suffix}\",\n                    status = response.status_code,\n                )\n        except httpx.HTTPError as exc:\n            if yielded:\n                raise\n            if attempt >= _MAX_TRANSIENT_RETRIES:\n                raise CodexTransportError(\"Could not reach ChatGPT Codex.\") from exc\n            await _retry_pause(float(2**attempt), cancel_event)\n            if cancel_event is not None and cancel_event.is_set():\n                yield None\n                return\n    raise CodexTransportError(\"Could not reach ChatGPT Codex.\")\n\n\nclass OpenAICodexClient:\n    def __init__(\n        self,","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/openai_codex_client.py#L388-L424","documentation":"The generic non-success fallback for the Codex responses endpoint: any status that is not 2xx, 3xx (handled as forbidden redirect), 401 (auth refresh path), or 429 (quota path) becomes CodexTransportError with the status code and any upstream error detail extracted from the body. This is the error that surfaces upstream 4xx/5xx bodies.","triggerScenarios":"Endpoint returns e.g. 400 (bad request payload), 403 (forbidden/plan restriction), 500/502/503 (upstream failure) after retry budget for retryable statuses is spent or the status is non-retryable. detail comes from _upstream_error_detail(response).","commonSituations":"Malformed or oversized request payload (400); model not enabled for the account (403); upstream OpenAI incident (5xx); passing unsupported parameters through to the responses API.","solutions":["Log the status code and detail suffix — they come straight from the upstream body and identify the cause","For 4xx, fix the request payload (model id, parameters, size) — retries will not help","For 5xx, retry with backoff; check the OpenAI status page for incidents"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    async for chunk in client.stream(request):\n        ...\nexcept CodexTransportError as exc:\n    status = exc.status\n    if 400 <= status < 500 and status not in (408, 429):\n        log_upstream_detail(exc)   # do not retry client errors\n        raise\n    await retry_with_backoff(request)  # 5xx path","preventionTips":["Validate request payloads (model id, sizes) client-side before sending","Log the detail suffix — it carries the upstream error body verbatim","Subscribe to API changelogs when using newer responses-API features"],"tags":["http","codex","upstream","api-error"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}