{"record":{"id":"aafb658d5996e7e3","repo":"BerriAI/litellm","slug":"azure-ai-api-base-is-required-api-base-none-set","errorCode":null,"errorMessage":"Azure AI API Base is required. api_base=None. Set in call or via `AZURE_AI_API_BASE` env var.","messagePattern":"Azure AI API Base is required\\. api_base=None\\. Set in call or via `AZURE_AI_API_BASE` env var\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/rerank/transformation.py","lineNumber":29,"sourceCode":"from litellm.llms.cohere.rerank.transformation import CohereRerankConfig\nfrom litellm.secret_managers.main import get_secret_str\nfrom litellm.types.utils import RerankResponse\nfrom litellm.utils import _add_path_to_api_base\n\n\nclass AzureAIRerankConfig(CohereRerankConfig):\n    \"\"\"\n    Azure AI Rerank - Follows the same Spec as Cohere Rerank\n    \"\"\"\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        model: str,\n        optional_params: dict | None = None,\n    ) -> str:\n        if api_base is None:\n            raise ValueError(\n                \"Azure AI API Base is required. api_base=None. Set in call or via `AZURE_AI_API_BASE` env var.\"\n            )\n        original_url: Final = httpx.URL(api_base)\n        if not original_url.is_absolute_url:\n            raise ValueError(\n                \"Azure AI API Base must be an absolute URL including scheme (e.g. \"\n                \"'https://<resource>.services.ai.azure.com'). \"\n                f\"Got api_base={api_base!r}.\"\n            )\n        normalized_path: Final = original_url.path.rstrip(\"/\")\n\n        # Allow callers to pass either full v1/v2 rerank endpoints:\n        # - https://<resource>.services.ai.azure.com/v1/rerank\n        # - https://<resource>.services.ai.azure.com/providers/cohere/v2/rerank\n        if normalized_path.endswith(\"/v1/rerank\") or normalized_path.endswith(\"/v2/rerank\"):\n            return str(original_url.copy_with(path=normalized_path or \"/\"))\n\n        # If callers pass just the version path (e.g. \".../v2\" or \".../providers/cohere/v2\"), append \"/rerank\"","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/rerank/transformation.py#L11-L47","documentation":"Azure AI rerank reuses the Cohere rerank spec but targets your Azure AI resource, so it needs the resource endpoint. get_complete_url raises this when api_base is None — no fallback to a default host exists. Set it per call or via AZURE_AI_API_BASE.","triggerScenarios":"Calling litellm.rerank(model='azure_ai/<cohere-rerank-model>', query=..., documents=[...]) without api_base in the call, router model_info, or the AZURE_AI_API_BASE environment variable.","commonSituations":"Switching from cohere/rerank-v3.5 to azure_ai/... and forgetting the endpoint is not derivable from the model name; proxy config.yaml model entry missing api_base; local .env not loaded in the deployment.","solutions":["export AZURE_AI_API_BASE=https://<resource>.services.ai.azure.com","Or pass api_base='https://<resource>.services.ai.azure.com' to litellm.rerank(...)","In the proxy, set litellm_params.api_base for the azure_ai rerank model and reload config"],"exampleFix":"# before\nlitellm.rerank(model='azure_ai/cohere-rerank-v3.5', query='hello', documents=['a','b'])\n\n# after\nlitellm.rerank(model='azure_ai/cohere-rerank-v3.5', query='hello', documents=['a','b'], api_base='https://my-resource.services.ai.azure.com', api_key=os.environ['AZURE_AI_API_KEY'])","handlingStrategy":"validation","validationCode":"api_base = os.environ.get('AZURE_AI_API_BASE')\nassert api_base, 'AZURE_AI_API_BASE must be set for azure_ai rerank'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set AZURE_AI_API_BASE and AZURE_AI_API_KEY together in deployment env","Wrap azure_ai rerank calls in a thin client function that injects api_base"],"tags":["azure","rerank","configuration","missing-parameter"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}