{"record":{"id":"d53e423a017412bb","repo":"BerriAI/litellm","slug":"imagevariationconfig-implementa-transform-request","errorCode":null,"errorMessage":"ImageVariationConfig implementa 'transform_request_image_variation' for image variation models","messagePattern":"ImageVariationConfig implementa 'transform_request_image_variation' for image variation models","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"litellm/llms/base_llm/image_generation/transformation.py","lineNumber":81,"sourceCode":"    ) -> dict:\n        return {}\n\n    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:\n        raise BaseLLMException(\n            status_code=status_code,\n            message=error_message,\n            headers=headers,\n        )\n\n    def transform_image_generation_request(\n        self,\n        model: str,\n        prompt: str,\n        optional_params: dict,\n        litellm_params: dict,\n        headers: dict,\n    ) -> dict:\n        raise NotImplementedError(\n            \"ImageVariationConfig implementa 'transform_request_image_variation' for image variation models\"\n        )\n\n    def transform_image_generation_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,\n        model_response: ImageResponse,\n        logging_obj: LiteLLMLoggingObj,\n        request_data: dict,\n        optional_params: dict,\n        litellm_params: dict,\n        encoding: Any,\n        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> ImageResponse:\n        raise NotImplementedError(\n            \"ImageVariationConfig implements 'transform_response_image_variation' for image variation models\"","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/base_llm/image_generation/transformation.py#L63-L99","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use an image-generation config (subclass of BaseImageGenerationConfig implementing transform_image_generation_request) for generation calls.","If the model supports both operations, give the provider two config classes and select based on the operation.","Override transform_image_generation_request in your subclass if you genuinely need generation support there.","Fix dispatch logic so variation endpoints call transform_request_image_variation instead."],"exampleFix":"# before\nclass MyProviderConfig(ImageVariationConfig): ...\n# wrongly used for generation:\nlitellm.image_generation(model='my-provider/model', prompt='a cat')  # NotImplementedError\n\n# after\nclass MyProviderGenConfig(BaseImageGenerationConfig):\n    def transform_image_generation_request(self, model, prompt, optional_params, litellm_params, headers):\n        return {'model': model, 'prompt': prompt}\nlitellm.image_generation(model='my-provider/model', prompt='a cat')","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"from litellm.llms.base_llm.image_generation.transformation import BaseImageGenerationConfig\nfrom litellm.llms.base_llm.image_variations.transformation import ImageVariationConfig\n\ndef supports_generation(config) -> bool:\n    return isinstance(config, BaseImageGenerationConfig) and not isinstance(config, ImageVariationConfig)","tryCatchPattern":"try:\n    litellm.image_generation(...)\nexcept NotImplementedError as e:\n    raise ModelConfigError('variation config used for generation; fix provider registration') from e","preventionTips":["Register one config per operation (generation vs variation) per provider.","Add a capability matrix test asserting each registered model's config implements the ops it serves.","Treat NotImplementedError from base stubs as a wiring bug, not a runtime hazard to catch."],"tags":["image-generation","image-variation","not-implemented","base-class"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}