{"record":{"id":"ec6b16d73150099d","repo":"conductor-oss/conductor","slug":"responses-api-failed-with-status-d-s","errorCode":null,"errorMessage":"Responses API failed with status %d: %s","messagePattern":"Responses API failed with status (.+?): (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/providers/openai/api/OpenAIResponsesApi.java","lineNumber":101,"sourceCode":"\n        Request httpRequest =\n                new Request.Builder()\n                        .url(baseUrl + \"/responses\")\n                        .header(authHeaderName, authHeaderValue)\n                        .header(\"Content-Type\", \"application/json\")\n                        .post(RequestBody.create(jsonBody, JSON))\n                        .build();\n\n        try (Response response = httpClient.newCall(httpRequest).execute()) {\n            String responseBody = readBody(response);\n            if (!response.isSuccessful()) {\n                // o-series and some newer OpenAI models reject temperature — retry without it.\n                if (response.code() == 400\n                        && responseBody.contains(\"temperature\")\n                        && request.temperature() != null) {\n                    return createResponse(request.withoutTemperature());\n                }\n                throw new IOException(\n                        \"Responses API failed with status %d: %s\"\n                                .formatted(response.code(), responseBody));\n            }\n            log.debug(\"Responses API response: {}\", responseBody);\n            return objectMapper.readValue(responseBody, ResponseResult.class);\n        }\n    }\n\n    private String readBody(Response response) throws IOException {\n        ResponseBody body = response.body();\n        return body != null ? body.string() : \"\";\n    }\n\n    // -- Request DTOs --\n\n    /**\n     * Reasoning config block on the Responses API request. OpenAI's Responses API takes a nested\n     * object {@code \"reasoning\": {\"effort\": \"...\", \"summary\": \"...\"}} rather than the flat {@code","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/providers/openai/api/OpenAIResponsesApi.java#L83-L119","documentation":"OpenAIResponsesApi.createResponse() throws IOException with message \"Responses API failed with status %d: %s\" when the HTTP response is not 2xx. The %d is the HTTP status code, %s is the raw response body. This is the low-level OkHttp client for POST {baseUrl}/responses (the newer OpenAI Responses API). Before throwing, it retries once without temperature if the error is a 400 mentioning 'temperature' (o-series models reject temperature). Auth header is configurable for Azure (api-key header) vs OpenAI (Bearer).","triggerScenarios":"POST {baseUrl}/responses returns non-2xx. Common: 401 (invalid/expired API key), 429 (rate limit), 400 (model not supported by Responses API, invalid reasoning config, unsupported parameters), 404 (wrong baseURL or model), 500/502/503 (server error), 529 (overloaded).","commonSituations":"Using a model that only supports Chat Completions (not Responses API) like gpt-3.5-turbo; expired API key; rate limit; reasoning-model parameter conflicts (the code auto-retries without temperature but other params like topP/stop may conflict); Azure auth header misconfigured (using Bearer instead of api-key header); baseURL not ending in /v1.","solutions":["Read the status code and body from the IOException message.","For 400 model-not-supported: switch to a Responses-API-compatible model (gpt-4o, gpt-4o-mini, o1, o3, o4-mini, gpt-5 series).","For 401: verify the API key; if using Azure, ensure azureAuth=true so the api-key header is used instead of Bearer.","For 429: implement backoff and retry.","For 400 reasoning parameter issues: verify reasoningEffort/reasoningSummary values match what the model supports (only reasoning models accept these).","Verify baseURL ends with /v1 (the OpenAI provider constructor normalizes this via ensureV1, but direct OpenAIResponsesApi construction does not)."],"exampleFix":"// before: Azure OpenAI using Bearer auth (wrong)\nnew OpenAIResponsesApi(client, apiKey, \"https://my-resource.openai.azure.com/v1\", false)\n// after: use azureAuth=true for api-key header\nnew OpenAIResponsesApi(client, apiKey, \"https://my-resource.openai.azure.com/v1\", true)","handlingStrategy":"retry","validationCode":"// Validate response request before calling\nOpenAIResponsesApi.ResponseRequest request = /* ... */;\nif (request.model() == null || request.model().isBlank()) {\n    throw new IllegalArgumentException(\"Model is required\");\n}\nif (apiKey == null || apiKey.isBlank()) {\n    throw new IllegalArgumentException(\"API key is required\");\n}\n// Verify model is Responses-API-compatible\nString model = request.model().toLowerCase();\nboolean supportsResponses = model.startsWith(\"gpt-4o\") || model.startsWith(\"o1\")\n    || model.startsWith(\"o3\") || model.startsWith(\"o4\") || model.startsWith(\"gpt-5\");\nif (!supportsResponses) {\n    log.warn(\"Model '{}' may not support the Responses API\", request.model());\n}","typeGuard":"null","tryCatchPattern":"int maxRetries = 3;\nfor (int attempt = 0; attempt <= maxRetries; attempt++) {\n    try {\n        return api.createResponse(request);\n    } catch (IOException e) {\n        String msg = e.getMessage();\n        // Retry transient errors\n        if ((msg.contains(\"429\") || msg.contains(\"500\") || msg.contains(\"503\")\n            || msg.contains(\"529\")) && attempt < maxRetries) {\n            long delay = (long) Math.pow(2, attempt) * 1000;\n            Thread.sleep(delay);\n            continue;\n        }\n        throw e;\n    }\n}","preventionTips":["Verify the model supports the Responses API (gpt-4o, o1, o3, o4, gpt-5 series).","For Azure OpenAI, ensure azureAuth=true so the api-key header is used.","Verify the baseURL ends with /v1 (the OpenAI provider normalizes this; direct API construction does not).","Implement retry with exponential backoff for 429/5xx/529 responses.","The code auto-retries without temperature for o-series 400s — don't manually remove temperature."],"tags":["openai","responses-api","http-error","network","api-error","ai"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}