BerriAI/litellm · error · ValueError

api_base is required for Azure AI Studio. Please set the…

Error message

api_base is required for Azure AI Studio. Please set the api_base parameter. Passed `api_base={api_base}`

What it means

Error "api_base is required for Azure AI Studio. Please set the api_base parameter. Passed `api_base={api_base}`" thrown in BerriAI/litellm.

Solutions

  1. Pass api_base or set AZURE_API_BASE / AZURE_AI_API_BASE for Azure AI Studio.

When it happens

Trigger: Thrown at litellm/llms/azure/common_utils.py:738 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/49518b4d71eb8d52. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/azure/common_utils.py:738

    def _get_base_azure_url(
        api_base: str | None,
        litellm_params: GenericLiteLLMParams | Mapping[str, object] | None,
        route: Literal["/openai/responses", "/openai/vector_stores"] | str,
        default_api_version: str | Literal["latest", "preview"] | None = None,
    ) -> str:
        """
        Get the base Azure URL for the given route and API version.

        Args:
            api_base: The base URL of the Azure API.
            litellm_params: The litellm parameters.
            route: The route to the API.
            default_api_version: The default API version to use if no api_version is provided. If 'latest', it will use `openai/v1/...` route.
        """

        api_base = api_base or litellm.api_base or get_secret_str("AZURE_API_BASE")
        if api_base is None:
            raise ValueError(
                f"api_base is required for Azure AI Studio. Please set the api_base parameter. Passed `api_base={api_base}`"
            )
        original_url: Final = httpx.URL(api_base)

        # Extract api_version or use default
        litellm_params = litellm_params or {}
        api_version: Final = cast(str | None, litellm_params.get("api_version")) or default_api_version

        # Create a new dictionary with existing params
        query_params: Final = dict(original_url.params)

        # Add api_version if needed
        if "api-version" not in query_params and api_version:
            query_params["api-version"] = api_version

        # Add the path to the base URL
        if route not in api_base:
            new_url = _add_path_to_api_base(api_base=api_base, ending_path=route)

View on GitHub (pinned to 77b7c6c40c)