{"record":{"id":"106a0c0c6928f644","repo":"conductor-oss/conductor","slug":"image-generation-api-call-failed","errorCode":null,"errorMessage":"Image generation API call failed: ","messagePattern":"Image generation API call failed: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/providers/openai/OpenAIHttpImageModel.java","lineNumber":88,"sourceCode":"                            .n(options != null && options.getN() != null ? options.getN() : 1)\n                            .size(size)\n                            .style(style)\n                            .responseFormat(responseFormat)\n                            .build();\n\n            var result = imageGenApi.createImage(request);\n\n            List<ImageGeneration> generations = new ArrayList<>();\n            if (result.data() != null) {\n                for (var imageData : result.data()) {\n                    Image image = new Image(imageData.url(), imageData.b64Json());\n                    generations.add(new ImageGeneration(image));\n                }\n            }\n\n            return new ImageResponse(generations);\n        } catch (IOException e) {\n            throw new RuntimeException(\"Image generation API call failed: \" + e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":92,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/providers/openai/OpenAIHttpImageModel.java#L70-L92","documentation":"OpenAIHttpImageModel wraps an IOException from OpenAIImageGenApi.createImage() in a RuntimeException with message \"Image generation API call failed: \". This is the HTTP-based image model used by the OpenAI provider (not Spring AI's built-in). The IOException originates from error 218 (non-2xx HTTP) or a network failure during POST /v1/images/generations.","triggerScenarios":"An image-generation task calls OpenAIHttpImageModel.call() and the POST /v1/images/generations request fails: invalid image model (not dall-e-2/dall-e-3/gpt-image-1), 401 auth, 429 rate limit, content-policy rejection, or network error.","commonSituations":"Using a non-image model name; requesting features the model doesn't support (e.g. dall-e-2 doesn't support HD quality); content policy violation in the prompt; rate limit on image generation (which is stricter than chat); API key without image-generation access.","solutions":["Inspect getCause() for the IOException — the message contains the HTTP status and OpenAI error body (see error 218).","Verify the model is an image model: dall-e-2, dall-e-3, or gpt-image-1.","For content-policy rejections (400 with safety message), revise the prompt.","For 429, implement backoff — image generation has lower rate limits than chat."],"exampleFix":"// before\n{\"model\": \"gpt-4o\", \"prompt\": \"a cat\"} // not an image model\n// after\n{\"model\": \"dall-e-3\", \"prompt\": \"a cat\"}","handlingStrategy":"try-catch","validationCode":"// Validate image generation request before calling\nImageGenRequest req = /* ... */;\nSet<String> imageModels = Set.of(\"dall-e-2\", \"dall-e-3\", \"gpt-image-1\");\nif (!imageModels.contains(req.getModel())) {\n    throw new IllegalArgumentException(\n        \"Model '\" + req.getModel() + \"' is not an image generation model. Use: \" + imageModels);\n}\nif (req.getPrompt() == null || req.getPrompt().isBlank()) {\n    throw new IllegalArgumentException(\"Prompt is required for image generation\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    ImageResponse response = imageModel.call(prompt);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof IOException) {\n        String msg = cause.getMessage();\n        if (msg.contains(\"429\")) {\n            // Image gen rate limit — backoff longer than chat\n            Thread.sleep(10000);\n            return retry(prompt);\n        }\n    }\n    throw e;\n}","preventionTips":["Validate the model is an image generation model before calling.","Implement longer backoff for image generation (stricter rate limits than chat).","Handle content-policy rejections gracefully with prompt revision suggestions.","Verify the requested size/quality/N combination is supported by the model."],"tags":["openai","image-generation","network","api-error","ai"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}