{"record":{"id":"c8df8054c8bf4df5","repo":"openai/codex","slug":"api-error-status-message","errorCode":null,"errorMessage":"api error {status}: {message}","messagePattern":"api error (.+?): (.+?)","errorType":"exception","errorClass":"ApiError","httpStatus":null,"severity":"error","filePath":"codex-rs/codex-api/src/error.rs","lineNumber":11,"sourceCode":"use crate::rate_limits::RateLimitError;\nuse codex_client::TransportError;\nuse http::StatusCode;\nuse std::time::Duration;\nuse thiserror::Error;\n\n#[derive(Debug, Error)]\npub enum ApiError {\n    #[error(transparent)]\n    Transport(#[from] TransportError),\n    #[error(\"api error {status}: {message}\")]\n    Api { status: StatusCode, message: String },\n    #[error(\"stream error: {0}\")]\n    Stream(String),\n    #[error(\"context window exceeded\")]\n    ContextWindowExceeded,\n    #[error(\"quota exceeded\")]\n    QuotaExceeded,\n    #[error(\"usage not included\")]\n    UsageNotIncluded,\n    #[error(\"retryable error: {message}\")]\n    Retryable {\n        message: String,\n        delay: Option<Duration>,\n    },\n    #[error(\"rate limit: {0}\")]\n    RateLimit(String),\n    #[error(\"invalid request: {message}\")]\n    InvalidRequest { message: String },","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/codex-api/src/error.rs#L1-L29","documentation":"ApiError::Api variant: the backend HTTP API returned a non-success status that is not mapped to a more specific variant. Carries the raw status code and server-provided message; handling depends on the status (4xx terminal, 5xx may be retryable).","triggerScenarios":"Thrown at codex-rs/codex-api/src/error.rs:11 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the status code and server message for the specific cause","For 401/403 re-authenticate via `codex login`","For 5xx retry after a delay","For 4xx fix the request per the API error details"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}