conductor-oss/conductor · error · UnsupportedOperationException

Image generation not supported by the model yet

Error message

Image generation not supported by the model yet

What it means

Ollama.java throws UnsupportedOperationException from getImageModel(). Ollama wires a chat model (OllamaChatModel) and embeddings but has no image-generation adapter. AIModel.getImageModel() is abstract (line 141), so Ollama throws.

Source

Thrown at ai/src/main/java/org/conductoross/conductor/ai/providers/ollama/Ollama.java:111

                        .toolNames(toolNames)
                        .internalToolExecutionEnabled(false)
                        .presencePenalty(input.getPresencePenalty());

        if (input.isJsonOutput()) {
            builder.format("json");
        }

        return builder.build();
    }

    @Override
    public ChatModel getChatModel() {
        return OllamaChatModel.builder().ollamaApi(buildOllamaApi()).build();
    }

    @Override
    public ImageModel getImageModel() {
        throw new UnsupportedOperationException("Image generation not supported by the model yet");
    }

    private OllamaApi buildOllamaApi() {
        OkHttpClient effective =
                (config.getTimeout() != null)
                        ? httpClient.newBuilder().readTimeout(config.getTimeout()).build()
                        : httpClient;
        var factory =
                new org.springframework.http.client.OkHttp3ClientHttpRequestFactory(effective);
        RestClient.Builder builder = RestClient.builder().requestFactory(factory);
        if (StringUtils.isNotBlank(config.getAuthHeaderName())) {
            builder.defaultHeader(config.getAuthHeaderName(), config.getAuthHeader());
        }
        return OllamaApi.builder().baseUrl(config.getBaseURL()).restClientBuilder(builder).build();
    }
}

View on GitHub (pinned to cf7c3e4a8a)

Solutions

  1. Switch the image task to a provider with a real ImageModel: openai, stabilityai, gemini, azureopenai, bedrock, or cohere.
  2. Keep Ollama for chat and embeddings only.
  3. If running a local image model, use stabilityai with a custom baseURL.

Example fix

// before
{"llmProvider": "ollama", "prompt": "a cat"}
// after
{"llmProvider": "stabilityai", "model": "stable-diffusion-xl", "prompt": "a cat"}
Defensive patterns

Strategy: validation

Validate before calling

// Same IMAGE_CAPABLE set
private static final Set<String> IMAGE_CAPABLE = Set.of(
    "openai", "gemini", "azureopenai", "bedrock", "stabilityai", "cohere");

if (!IMAGE_CAPABLE.contains(request.getLlmProvider())) {
    throw new IllegalArgumentException(
        "Ollama does not support image generation. Use: " + IMAGE_CAPABLE);
}

Type guard

null

Try / catch

try {
    ImageModel model = llm.getImageModel();
} catch (UnsupportedOperationException e) {
    throw new IllegalArgumentException("Ollama does not support image generation", e);
}

Prevention

When it happens

Trigger: An image-generation Conductor task is configured with llmProvider="ollama". LLMHelper.generateImage() calls llm.getImageModel() and the provider throws before any HTTP call to the Ollama daemon.

Common situations: Running Ollama locally for chat and assuming the same provider handles image generation; routing an image task to a local Ollama instance that only has text/vision models loaded.

Related errors


AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14). Data as JSON: /api/errors/ddffc3e1c98ee6fd. Report an issue: GitHub.