BerriAI/litellm · error · NotImplementedError

ImageVariationConfig implementa 'transform_request_image_var

Error message

ImageVariationConfig implementa 'transform_request_image_variation' for image variation models

What it means

In the image-variations base config, the chat-style transform_request hook (generic request pipeline signature with messages) is deliberately unimplemented and raises NotImplementedError. Image variation flows must go through transform_request_image_variation; hitting this stub means generic chat-transform plumbing was invoked on a variation config.

Source

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

        logging_obj: LiteLLMLoggingObj,
        request_data: dict,
        image: FileTypes,
        optional_params: dict,
        litellm_params: dict,
        encoding: Any,
        api_key: str | None = None,
    ) -> ImageResponse:
        pass

    def transform_request(
        self,
        model: str,
        messages: list[AllMessageValues],
        optional_params: dict,
        litellm_params: dict,
        headers: dict,
    ) -> dict:
        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(

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Invoke the image variation API path (litellm.image_variation / the variation handler) so transform_request_image_variation is used.
  2. If your provider needs the generic signature, override transform_request in the subclass instead of inheriting the stub.
  3. Correct route/handler mapping so variation models do not enter the chat pipeline.
  4. Verify the provider config registered in the provider map is the variation config and the caller is a variation caller.

Example fix

# before: variation model routed through generic chat pipeline
handler.transform_request(model, messages=[], ...)  # NotImplementedError

# after: call the variation flow
resp = litellm.image_variation(model='my-provider/model', image=f, n=2)
Defensive patterns

Strategy: type-guard

Type guard

from litellm.llms.base_llm.image_variations.transformation import ImageVariationConfig

def is_variation_only(config) -> bool:
    return isinstance(config, ImageVariationConfig) and not hasattr(config.__class__, 'transform_request__overridden')

Try / catch

try:
    result = handler.transform_request(...)
except NotImplementedError as e:
    if 'transform_request_image_variation' in str(e):
        return config.transform_request_image_variation(...)  # route to variation API
    raise

Prevention

When it happens

Trigger: A generic handler (shared with chat/completions) calls transform_request(model, messages, ...) on a config that only supports variations; routing a variation model through a completion-style endpoint; custom provider wiring that reuses the chat transformation pipeline.

Common situations: Custom providers modeled after the chat transformation interface; proxy routes that send variation models through the standard completions handler; refactors that unified request transforms under one signature.

Related errors


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