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

Base-class stub: ImageVariationConfig intentionally does not implement the image-generation request transform, so any code path that routes a variation config through transform_image_generation_request raises NotImplementedError. Variation configs must only be used with image variation endpoints; the message (note the 'implementa' typo) tells you the wrong method was dispatched.

Source

Thrown at litellm/llms/base_llm/image_generation/transformation.py:81

    ) -> dict:
        return {}

    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:
        raise BaseLLMException(
            status_code=status_code,
            message=error_message,
            headers=headers,
        )

    def transform_image_generation_request(
        self,
        model: str,
        prompt: str,
        optional_params: dict,
        litellm_params: dict,
        headers: dict,
    ) -> dict:
        raise NotImplementedError(
            "ImageVariationConfig implementa 'transform_request_image_variation' for image variation models"
        )

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

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Use an image-generation config (subclass of BaseImageGenerationConfig implementing transform_image_generation_request) for generation calls.
  2. If the model supports both operations, give the provider two config classes and select based on the operation.
  3. Override transform_image_generation_request in your subclass if you genuinely need generation support there.
  4. Fix dispatch logic so variation endpoints call transform_request_image_variation instead.

Example fix

# before
class MyProviderConfig(ImageVariationConfig): ...
# wrongly used for generation:
litellm.image_generation(model='my-provider/model', prompt='a cat')  # NotImplementedError

# after
class MyProviderGenConfig(BaseImageGenerationConfig):
    def transform_image_generation_request(self, model, prompt, optional_params, litellm_params, headers):
        return {'model': model, 'prompt': prompt}
litellm.image_generation(model='my-provider/model', prompt='a cat')
Defensive patterns

Strategy: type-guard

Type guard

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

def supports_generation(config) -> bool:
    return isinstance(config, BaseImageGenerationConfig) and not isinstance(config, ImageVariationConfig)

Try / catch

try:
    litellm.image_generation(...)
except NotImplementedError as e:
    raise ModelConfigError('variation config used for generation; fix provider registration') from e

Prevention

When it happens

Trigger: Registering an ImageVariationConfig subclass as the config for image *generation* (not variation) and calling litellm.image_generation; generic handler code that unconditionally calls transform_image_generation_request on any BaseImageGenerationConfig.

Common situations: Copy-pasting a provider config class and changing only some methods; a router/handler that picks config classes by model family and selects the variation config for a generation-capable model; refactors that merged generation and variation hierarchies.

Related errors


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