conductor-oss/conductor · error · UnsupportedOperationException
Image generation not supported by Cohere
Error message
Image generation not supported by Cohere
What it means
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.
Source
Thrown at ai/src/main/java/org/conductoross/conductor/ai/providers/cohere/CohereAI.java:105
return CohereChatOptions.builder()
.model(input.getModel())
.temperature(input.getTemperature())
.topP(input.getTopP())
.maxTokens(input.getMaxTokens())
.stopSequences(input.getStopWords())
.frequencyPenalty(input.getFrequencyPenalty())
.presencePenalty(input.getPresencePenalty())
.build();
}
@Override
public ChatModel getChatModel() {
return this.chatModel;
}
@Override
public ImageModel getImageModel() {
throw new UnsupportedOperationException("Image generation not supported by Cohere");
}
// Initialization helpers
private CohereApi createCohereApi(OkHttpClient httpClient) {
OkHttpClient effective =
(config.getTimeout() != null)
? httpClient.newBuilder().readTimeout(config.getTimeout()).build()
: httpClient;
var factory =
new org.springframework.http.client.OkHttp3ClientHttpRequestFactory(effective);
CohereApi.Builder builder =
CohereApi.builder()
.apiKey(config.getApiKey())
.restClientBuilder(RestClient.builder().requestFactory(factory));
if (config.getBaseURL() != null && !config.getBaseURL().isEmpty()) {
builder.baseUrl(config.getBaseURL());View on GitHub (pinned to cf7c3e4a8a)
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.
Example fix
// before
String provider = "cohere";
ImageModel img = registry.get(provider).getImageModel(); // throws
// after — guard by provider capability
private static final Set<String> IMAGE_PROVIDERS =
Set.of("openai", "azure_openai", "vertex_ai", "google_gemini", "stabilityai");
if (!IMAGE_PROVIDERS.contains(provider)) {
throw new IllegalArgumentException(
"Provider " + provider + " does not support image generation");
}
ImageModel img = registry.get(provider).getImageModel(); Defensive patterns
Strategy: validation
Validate before calling
// Validate Cohere supports the requested capability
private static final Set<String> IMAGE_CAPABLE =
Set.of("openai", "azure_openai", "vertex_ai", "google_gemini", "stabilityai");
void validateCohereImageCapability(String provider) {
if ("cohere".equals(provider)) {
throw new IllegalArgumentException(
"Cohere does not support image generation. "
+ "Use: " + IMAGE_CAPABLE);
}
} Type guard
static boolean supportsImageGeneration(AIModel model) {
try {
model.getImageModel();
return true;
} catch (UnsupportedOperationException e) {
return false;
}
} Try / catch
try {
return cohereAI.getImageModel();
} catch (UnsupportedOperationException e) {
throw new IllegalArgumentException(
"Cohere is a text/embedding provider — no image generation.", e);
} Prevention
- 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.
When it happens
Trigger: Calling getImageModel() on a Cohere provider instance — a GenerateImage task or image-generation code path routed to provider 'cohere'.
Common situations: Routing an image generation workflow to the Cohere provider. A capability-agnostic dispatcher that calls getImageModel() on all registered providers.
Related errors
- Image generation not supported by the model yet
- Image generation not supported by the model yet
- Not supported
- Image generation not supported by the model yet
- Image generation not supported by the model yet
AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14).
Data as JSON: /api/errors/914ba363e106a4b5.
Report an issue: GitHub.