BerriAI/litellm · error · ValueError

Invalid size format: '{size}'. Expected format 'WIDTHxHEIGHT

Error message

Invalid size format: '{size}'. Expected format 'WIDTHxHEIGHT' (e.g., '1024x1024').

What it means

Error "Invalid size format: '{size}'. Expected format 'WIDTHxHEIGHT' (e.g., '1024x1024')." thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/azure_ai/image_generation/mai_transformation.py:186

        size_mapping: Final = {
            "1024x1024": (1024, 1024),
            "1792x1024": (1792, 1024),
            "1024x1792": (1024, 1792),
            "512x512": (512, 512),
            "256x256": (256, 256),
        }

        if size in size_mapping:
            width, height = size_mapping[size]
            optional_params["width"] = width
            optional_params["height"] = height
        elif "x" in size:
            try:
                width, height = map(int, size.lower().split("x"))
                optional_params["width"] = width
                optional_params["height"] = height
            except ValueError:
                raise ValueError(f"Invalid size format: '{size}'. Expected format 'WIDTHxHEIGHT' (e.g., '1024x1024').")
        else:
            raise ValueError(
                f"Unsupported size value: '{size}'. "
                f"Use a known size (e.g., '1024x1024') or a custom 'WIDTHxHEIGHT' string."
            )

    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,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Use the 'WIDTHxHEIGHT' format, e.g. '1024x1024'.

When it happens

Trigger: Thrown at litellm/llms/azure_ai/image_generation/mai_transformation.py:186 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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