{"record":{"id":"49518b4d71eb8d52","repo":"BerriAI/litellm","slug":"api-base-is-required-for-azure-ai-studio-please-s","errorCode":null,"errorMessage":"api_base is required for Azure AI Studio. Please set the api_base parameter. Passed `api_base={api_base}`","messagePattern":"api_base is required for Azure AI Studio\\. Please set the api_base parameter\\. Passed `api_base=(.+?)`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure/common_utils.py","lineNumber":738,"sourceCode":"    def _get_base_azure_url(\n        api_base: str | None,\n        litellm_params: GenericLiteLLMParams | Mapping[str, object] | None,\n        route: Literal[\"/openai/responses\", \"/openai/vector_stores\"] | str,\n        default_api_version: str | Literal[\"latest\", \"preview\"] | None = None,\n    ) -> str:\n        \"\"\"\n        Get the base Azure URL for the given route and API version.\n\n        Args:\n            api_base: The base URL of the Azure API.\n            litellm_params: The litellm parameters.\n            route: The route to the API.\n            default_api_version: The default API version to use if no api_version is provided. If 'latest', it will use `openai/v1/...` route.\n        \"\"\"\n\n        api_base = api_base or litellm.api_base or get_secret_str(\"AZURE_API_BASE\")\n        if api_base is None:\n            raise ValueError(\n                f\"api_base is required for Azure AI Studio. Please set the api_base parameter. Passed `api_base={api_base}`\"\n            )\n        original_url: Final = httpx.URL(api_base)\n\n        # Extract api_version or use default\n        litellm_params = litellm_params or {}\n        api_version: Final = cast(str | None, litellm_params.get(\"api_version\")) or default_api_version\n\n        # Create a new dictionary with existing params\n        query_params: Final = dict(original_url.params)\n\n        # Add api_version if needed\n        if \"api-version\" not in query_params and api_version:\n            query_params[\"api-version\"] = api_version\n\n        # Add the path to the base URL\n        if route not in api_base:\n            new_url = _add_path_to_api_base(api_base=api_base, ending_path=route)","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/common_utils.py#L720-L756","documentation":"In select_azure_base_url_or_endpoint (used to build Azure AI Studio / AI Services URLs), api_base is resolved from the argument, then litellm.api_base, then the AZURE_API_BASE env var. If all are None it raises ValueError, because there is no way to construct the deployment URL without the resource endpoint.","triggerScenarios":"Calling an azure/ai-studio or inference-endpoint model without api_base in the model metadata, without litellm.api_base set, and without AZURE_API_BASE exported. Also when a router/proxy entry omits api_base for an Azure AI Studio model.","commonSituations":"Copying an azure model config but dropping the api_base line; environment var lost in container migration (works locally via AZURE_API_BASE, fails in prod); using a model alias whose metadata lacks the endpoint.","solutions":["Pass api_base explicitly: litellm.completion(model=\"azure_ai/<model>\", api_base=\"https://<resource>.services.ai.azure.com\", ...).","Or export AZURE_API_BASE=https://<resource>.openai.azure.com in the process environment.","In the proxy/router, add api_base to the model's litellm_params entry.","Note the message prints the value passed (e.g. api_base=None) — use it to confirm which code path supplied nothing."],"exampleFix":"# before\nmodel_list:\n  - model_name: gpt4o\n    litellm_params:\n      model: azure_ai/gpt-4o\n      api_key: os.environ/AZURE_API_KEY\n\n# after\nmodel_list:\n  - model_name: gpt4o\n    litellm_params:\n      model: azure_ai/gpt-4o\n      api_key: os.environ/AZURE_API_KEY\n      api_base: https://my-resource.services.ai.azure.com","handlingStrategy":"validation","validationCode":"import litellm, os\n\ndef validate_azure_ai_studio(model: str, api_base: str | None) -> None:\n    resolved = api_base or litellm.api_base or os.getenv(\"AZURE_API_BASE\")\n    if not resolved:\n        raise ConfigError(f\"api_base required for {model}; set api_base or AZURE_API_BASE\")","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=\"azure_ai/gpt-4o\", messages=msgs)\nexcept ValueError as e:\n    if \"api_base is required\" in str(e):\n        raise ConfigError(\"Add api_base to the model's litellm_params\") from e\n    raise","preventionTips":["Require api_base in your config schema for azure/azure_ai models (fail at config load).","Set AZURE_API_BASE as a baseline default in deployment environments.","Lint proxy YAML: every azure* model entry must have api_base or an env default."],"tags":["azure","configuration","environment-variables","ai-studio"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}