{"record":{"id":"7a4eb84c92ffb038","repo":"BerriAI/litellm","slug":"missing-azure-document-intelligence-endpoint-set","errorCode":null,"errorMessage":"Missing Azure Document Intelligence Endpoint - Set AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT environment variable or pass api_base parameter","messagePattern":"Missing Azure Document Intelligence Endpoint - Set AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT environment variable or pass api_base parameter","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/ocr/document_intelligence/transformation.py","lineNumber":233,"sourceCode":"        Validate environment and return headers for Azure Document Intelligence.\n\n        Authentication uses Ocp-Apim-Subscription-Key header.\n        \"\"\"\n        # Get API key from environment if not provided\n        if api_key is None:\n            api_key = get_secret_str(AZURE_DOCUMENT_INTELLIGENCE_API_KEY_ENV_VAR)\n\n        if api_key is None:\n            raise ValueError(\n                \"Missing Azure Document Intelligence API Key - Set AZURE_DOCUMENT_INTELLIGENCE_API_KEY environment variable or pass api_key parameter\"\n            )\n\n        # Validate API base/endpoint is provided\n        if api_base is None:\n            api_base = get_secret_str(\"AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT\")\n\n        if api_base is None:\n            raise ValueError(\n                \"Missing Azure Document Intelligence Endpoint - Set AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT environment variable or pass api_base parameter\"\n            )\n\n        headers = {\n            \"Ocp-Apim-Subscription-Key\": api_key,\n            \"Content-Type\": \"application/json\",\n            **headers,\n        }\n\n        return headers\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict | None = None,\n        **kwargs,","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py#L215-L251","documentation":"Raised during header validation for Azure Document Intelligence OCR when no endpoint is configured: api_base was not passed and the AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT environment variable is unset. The DI client needs a resource-specific endpoint (e.g. https://your-resource.cognitiveservices.azure.com) to build the analyze URL, so the call fails before any network activity. Note this is the header-building path; the same check exists independently in get_complete_url.","triggerScenarios":"Calling azure_ai doc-intelligence OCR with AZURE_DOCUMENT_INTELLIGENCE_API_KEY set (or api_key passed) but AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT unset and no api_base parameter supplied.","commonSituations":"Env var configured only on a dev machine and missing in CI/containers; typo in the variable name; assuming the key alone suffices; endpoint stored under a differently named variable (AZURE_AI_API_BASE does not apply to DI).","solutions":["Set AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT to your resource endpoint (find it in the Azure portal under your Document Intelligence resource > Keys and Endpoint).","Or pass api_base='https://<resource>.cognitiveservices.azure.com' on the call.","Verify with a preflight check of os.environ in the deployment environment."],"exampleFix":"# before\nresp = litellm.aocr_document(model=\"azure_ai/doc-intelligence/prebuilt-read\", document=doc, api_key=key)\n# no endpoint anywhere -> ValueError\n\n# after\nresp = litellm.aocr_document(\n    model=\"azure_ai/doc-intelligence/prebuilt-read\",\n    document=doc,\n    api_key=key,\n    api_base=\"https://myres.cognitiveservices.azure.com\",\n)","handlingStrategy":"validation","validationCode":"import os\nif not os.getenv(\"AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT\") and not passed_api_base:\n    raise ConfigError(\"AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT not set\")","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.aocr_document(model=m, document=doc)\nexcept ValueError as e:\n    if \"Missing Azure Document Intelligence Endpoint\" in str(e):\n        raise ConfigError(\"configure AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT\") from e\n    raise","preventionTips":["Preflight both DI env vars (key AND endpoint) at process start.","Store them together in one secret/config source so they're never half-configured."],"tags":["azure","document-intelligence","ocr","config","environment","endpoint"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}