BerriAI/litellm · error · NotImplementedError

ImageVariationConfig implements 'transform_response_image_va

Error message

ImageVariationConfig implements 'transform_response_image_variation' for image variation models

What it means

Image-variations base config stub for the chat-style transform_response hook. Any attempt to parse an HTTP response through the generic (messages-based) response transformation on a variation config raises NotImplementedError, marking that path unsupported; variation responses must be handled by transform_response_image_variation.

Source

Thrown at litellm/llms/base_llm/image_variations/transformation.py:130

        raise NotImplementedError(
            "ImageVariationConfig implementa 'transform_request_image_variation' for image variation models"
        )

    def transform_response(
        self,
        model: str,
        raw_response: httpx.Response,
        model_response: ModelResponse,
        logging_obj: LiteLLMLoggingObj,
        request_data: dict,
        messages: list[AllMessageValues],
        optional_params: dict,
        litellm_params: dict,
        encoding: Any,
        api_key: str | None = None,
        json_mode: bool | None = None,
    ) -> ModelResponse:
        raise NotImplementedError(
            "ImageVariationConfig implements 'transform_response_image_variation' for image variation models"
        )

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Use the variation response path (transform_response_image_variation) — i.e. call litellm.image_variation, not completion.
  2. Override transform_response in the subclass if the generic signature must work.
  3. Fix model-to-handler routing so variation models never enter chat response processing.
  4. Add a registration test asserting each model's config supports the operation it is served for.

Example fix

# before
config.transform_response(model, raw_response, model_response, logging_obj, request_data, messages, ...)  # NotImplementedError

# after
config.transform_response_image_variation(model, raw_response, model_response, logging_obj, request_data, optional_params, litellm_params, encoding)
Defensive patterns

Strategy: type-guard

Type guard

def has_variation_response_path(config) -> bool:
    return callable(getattr(config, 'transform_response_image_variation', None))

Try / catch

try:
    config.transform_response(...)
except NotImplementedError:
    return config.transform_response_image_variation(...)  # correct path

Prevention

When it happens

Trigger: Generic response-processing code calls transform_response(model, raw_response, model_response, ..., messages, ...) on an ImageVariationConfig — e.g. a shared streaming/logging pipeline finishing a request that was mistakenly routed as a chat completion.

Common situations: Shared response handlers reused across modalities; misrouted proxy requests; provider subclasses that implement only the variation hooks but get exercised by completion tests.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/8405783c31deb25d. Report an issue: GitHub.