{"record":{"id":"914ba363e106a4b5","repo":"conductor-oss/conductor","slug":"image-generation-not-supported-by-cohere","errorCode":null,"errorMessage":"Image generation not supported by Cohere","messagePattern":"Image generation not supported by Cohere","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/providers/cohere/CohereAI.java","lineNumber":105,"sourceCode":"        return CohereChatOptions.builder()\n                .model(input.getModel())\n                .temperature(input.getTemperature())\n                .topP(input.getTopP())\n                .maxTokens(input.getMaxTokens())\n                .stopSequences(input.getStopWords())\n                .frequencyPenalty(input.getFrequencyPenalty())\n                .presencePenalty(input.getPresencePenalty())\n                .build();\n    }\n\n    @Override\n    public ChatModel getChatModel() {\n        return this.chatModel;\n    }\n\n    @Override\n    public ImageModel getImageModel() {\n        throw new UnsupportedOperationException(\"Image generation not supported by Cohere\");\n    }\n\n    // Initialization helpers\n\n    private CohereApi createCohereApi(OkHttpClient httpClient) {\n        OkHttpClient effective =\n                (config.getTimeout() != null)\n                        ? httpClient.newBuilder().readTimeout(config.getTimeout()).build()\n                        : httpClient;\n        var factory =\n                new org.springframework.http.client.OkHttp3ClientHttpRequestFactory(effective);\n        CohereApi.Builder builder =\n                CohereApi.builder()\n                        .apiKey(config.getApiKey())\n                        .restClientBuilder(RestClient.builder().requestFactory(factory));\n\n        if (config.getBaseURL() != null && !config.getBaseURL().isEmpty()) {\n            builder.baseUrl(config.getBaseURL());","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/providers/cohere/CohereAI.java#L87-L123","documentation":"CohereAI.getImageModel() throws unconditionally because Cohere is a text-generation and embedding provider with no image-generation API. The AIModel contract is satisfied by throwing UnsupportedOperationException with a provider-specific message. This is a permanent limitation, not a future feature.","triggerScenarios":"Calling getImageModel() on a Cohere provider instance — a GenerateImage task or image-generation code path routed to provider 'cohere'.","commonSituations":"Routing an image generation workflow to the Cohere provider. A capability-agnostic dispatcher that calls getImageModel() on all registered providers.","solutions":["Route image generation to a provider with an ImageModel implementation: 'openai', 'azure_openai', 'vertex_ai'/'google_gemini', or 'stabilityai'.","Add a capability check (provider name whitelist) before calling getImageModel().","If building a generic task runner, catch UnsupportedOperationException and return a clear user-facing error."],"exampleFix":"// before\nString provider = \"cohere\";\nImageModel img = registry.get(provider).getImageModel(); // throws\n\n// after — guard by provider capability\nprivate static final Set<String> IMAGE_PROVIDERS =\n    Set.of(\"openai\", \"azure_openai\", \"vertex_ai\", \"google_gemini\", \"stabilityai\");\nif (!IMAGE_PROVIDERS.contains(provider)) {\n    throw new IllegalArgumentException(\n        \"Provider \" + provider + \" does not support image generation\");\n}\nImageModel img = registry.get(provider).getImageModel();","handlingStrategy":"validation","validationCode":"// Validate Cohere supports the requested capability\nprivate static final Set<String> IMAGE_CAPABLE =\n    Set.of(\"openai\", \"azure_openai\", \"vertex_ai\", \"google_gemini\", \"stabilityai\");\n\nvoid validateCohereImageCapability(String provider) {\n    if (\"cohere\".equals(provider)) {\n        throw new IllegalArgumentException(\n            \"Cohere does not support image generation. \"\n            + \"Use: \" + IMAGE_CAPABLE);\n    }\n}","typeGuard":"static boolean supportsImageGeneration(AIModel model) {\n    try {\n        model.getImageModel();\n        return true;\n    } catch (UnsupportedOperationException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    return cohereAI.getImageModel();\n} catch (UnsupportedOperationException e) {\n    throw new IllegalArgumentException(\n        \"Cohere is a text/embedding provider — no image generation.\", e);\n}","preventionTips":["Cohere is text and embeddings only — never route image tasks to it.","Check the provider name against an image-capable whitelist before dispatching image tasks.","Build a capability matrix in the provider registry so the task mapper can reject incompatible provider+task combinations at registration time."],"tags":["cohere","image-generation","unsupported-operation","capability-mismatch"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}