BerriAI/litellm · error · ValueError

Azure API version is required. Set AZURE_AI_API_VERSION envi

Error message

Azure API version is required. Set AZURE_AI_API_VERSION environment variable or pass api_version parameter.

What it means

Error "Azure API version is required. Set AZURE_AI_API_VERSION environment variable or pass api_version parameter." thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/azure_ai/image_edit/transformation.py:79

        Args:
        - model: Model name (deployment name for Azure AI Foundry)
        - api_base: Base URL for Azure AI endpoint
        - litellm_params: Additional parameters including api_version

        Returns:
        - Complete URL for the image edits endpoint
        """
        api_base = AzureFoundryModelInfo.get_api_base(api_base)

        if api_base is None:
            raise ValueError(
                "Azure AI API base is required. Set AZURE_AI_API_BASE environment variable or pass api_base parameter."
            )

        api_version = litellm_params.get("api_version") or litellm.api_version or get_secret_str("AZURE_AI_API_VERSION")
        if api_version is None:
            # API version is mandatory for Azure AI Foundry
            raise ValueError(
                "Azure API version is required. Set AZURE_AI_API_VERSION environment variable or pass api_version parameter."
            )

        # Add the path to the base URL using the model as deployment name
        # Azure AI Foundry FLUX models use /images/edits for editing
        if "/openai/deployments/" in api_base:
            new_url = _add_path_to_api_base(
                api_base=api_base,
                ending_path="/images/edits",
            )
        else:
            new_url = _add_path_to_api_base(
                api_base=api_base,
                ending_path=f"/openai/deployments/{model}/images/edits",
            )

        # Use the new query_params dictionary
        final_url: Final = httpx.URL(new_url).copy_with(params={"api-version": api_version})

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Set AZURE_AI_API_VERSION or pass api_version.

When it happens

Trigger: Thrown at litellm/llms/azure_ai/image_edit/transformation.py:79 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/f237e25379e0854c. Report an issue: GitHub.