{"record":{"id":"ad8173ffba50abe9","repo":"BerriAI/litellm","slug":"azure-ai-api-base-must-be-an-absolute-url-includin","errorCode":null,"errorMessage":"Azure AI API Base must be an absolute URL including scheme (e.g. 'https://<resource>.services.ai.azure.com'). Got api_base={api_base!r}.","messagePattern":"Azure AI API Base must be an absolute URL including scheme \\(e\\.g\\. 'https://<resource>\\.services\\.ai\\.azure\\.com'\\)\\. Got api_base=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/rerank/transformation.py","lineNumber":34,"sourceCode":"\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\"\n        if (\n            normalized_path.endswith(\"/v1\")\n            or normalized_path.endswith(\"/v2\")\n            or normalized_path.endswith(\"/providers/cohere/v2\")\n        ):","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/rerank/transformation.py#L16-L52","documentation":"After confirming api_base exists, the rerank config parses it with httpx.URL and requires it to be absolute (include a scheme like https://). A bare host such as my-resource.services.ai.azure.com has no scheme, so is_absolute_url is false and the URL cannot be safely joined with the rerank path.","triggerScenarios":"Passing api_base='my-resource.services.ai.azure.com' or 'my-resource.services.ai.azure.com/v1/rerank' (no https:// prefix). Also happens when a trailing config value had the scheme stripped by string manipulation or a templating mistake.","commonSituations":"Storing endpoints in config without the scheme; environment variables copied from Azure portal 'copy host' buttons that omit https://; constructing api_base by concatenation and dropping the scheme.","solutions":["Include the scheme: api_base='https://<resource>.services.ai.azure.com'","Add a normalization step in your code: api_base = api_base if api_base.startswith('http') else 'https://' + api_base","Check the exact value being sent: log repr(api_base) before the call"],"exampleFix":"# before\nlitellm.rerank(model='azure_ai/cohere-rerank-v3.5', query=q, documents=docs, api_base='my-resource.services.ai.azure.com')\n\n# after\nlitellm.rerank(model='azure_ai/cohere-rerank-v3.5', query=q, documents=docs, api_base='https://my-resource.services.ai.azure.com')","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef normalize_api_base(base: str) -> str:\n    if not urlparse(base).scheme:\n        base = 'https://' + base\n    return base.rstrip('/')","typeGuard":"def is_absolute_http_url(value) -> bool:\n    try:\n        from urllib.parse import urlparse\n        p = urlparse(value)\n        return p.scheme in ('http', 'https') and bool(p.netloc)\n    except Exception:\n        return False","tryCatchPattern":null,"preventionTips":["Normalize scheme-less hosts once at config load","Never build api_base by string concatenation that can drop the scheme"],"tags":["azure","rerank","url","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}