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_edit/mai_transformation.py:80

    def _validate_size_param(self, size: str) -> None:
        known_sizes: Final = {
            "1024x1024",
            "1792x1024",
            "1024x1792",
            "512x512",
            "256x256",
        }

        if size in known_sizes:
            return

        if "x" in size:
            try:
                tuple(map(int, size.lower().split("x", 1)))
                return
            except ValueError:
                raise ValueError(f"Invalid size format: '{size}'. Expected format 'WIDTHxHEIGHT' (e.g., '1024x1024').")

        raise ValueError(
            f"Unsupported size value: '{size}'. Use a known size (e.g., '1024x1024') or a custom 'WIDTHxHEIGHT' string."
        )

    def validate_environment(
        self,
        headers: dict,
        model: str,
        api_key: str | None = None,
        litellm_params: dict | None = None,
        api_base: str | None = None,
    ) -> dict:
        api_key = AzureFoundryModelInfo.get_api_key(api_key)

        if not api_key:
            raise ValueError(
                f"Azure AI API key is required for model {model}. "

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_edit/mai_transformation.py:80 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/eb57ef34f36fab83. Report an issue: GitHub.