{"record":{"id":"80bdad01b642689e","repo":"BerriAI/litellm","slug":"either-set-the-databricks-api-base-and-databricks","errorCode":null,"errorMessage":"Either set the DATABRICKS_API_BASE and DATABRICKS_API_KEY environment variables, or install the databricks-sdk Python library.","messagePattern":"Either set the DATABRICKS_API_BASE and DATABRICKS_API_KEY environment variables, or install the databricks-sdk Python library\\.","errorType":"http","errorClass":"DatabricksException","httpStatus":400,"severity":"error","filePath":"litellm/llms/databricks/common_utils.py","lineNumber":193,"sourceCode":"\n        # Default: just litellm\n        return f\"litellm/{version}\"\n\n    def _get_api_base(self, api_base: str | None) -> str:\n        \"\"\"\n        Get the Databricks API base URL.\n\n        If not provided, attempts to get it from the Databricks SDK.\n        \"\"\"\n        if api_base is None:\n            try:\n                from databricks.sdk import WorkspaceClient\n\n                databricks_client: Final = WorkspaceClient()\n                api_base = f\"{databricks_client.config.host}/serving-endpoints\"\n                return api_base\n            except ImportError:\n                raise DatabricksException(\n                    status_code=400,\n                    message=(\n                        \"Either set the DATABRICKS_API_BASE and DATABRICKS_API_KEY environment variables, \"\n                        \"or install the databricks-sdk Python library.\"\n                    ),\n                )\n        return api_base\n\n    def _get_oauth_m2m_token(\n        self,\n        api_base: str,\n        client_id: str,\n        client_secret: str,\n    ) -> str:\n        \"\"\"\n        Obtain an OAuth M2M access token using client credentials flow.\n\n        This is the recommended authentication method for production integrations","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/databricks/common_utils.py#L175-L211","documentation":"Raised when DATABRICKS_API_BASE is not provided and LiteLLM tries to derive the workspace URL from the databricks-sdk package, but the import fails because databricks-sdk is not installed. The fix paths are mutually exclusive: either provide base+key explicitly or install the SDK.","triggerScenarios":"Configuring a Databricks model without DATABRICKS_API_BASE/DATABRICKS_API_KEY env vars and without databricks-sdk in the Python environment (common in slim Docker images where the optional dependency was not included).","commonSituations":"Deploying LiteLLM proxy to a minimal container that excluded optional deps; local venv created from a requirements list that omitted databricks-sdk; CI environment differing from local.","solutions":["Set DATABRICKS_API_BASE=https://<workspace-host>/serving-endpoints and DATABRICKS_API_KEY=<token>","Or install the SDK: pip install databricks-sdk","For containerized proxy deployments, prefer explicit env vars to avoid pulling in the SDK","Pin databricks-sdk to a compatible version if SDK-based auth is required"],"exampleFix":"# before\n# no env vars, no SDK installed\n\n# after\nexport DATABRICKS_API_BASE=\"https://adb-1234567890.0.azuredatabricks.net/serving-endpoints\"\nexport DATABRICKS_API_KEY=\"dapi...\"","handlingStrategy":"validation","validationCode":"if not os.getenv(\"DATABRICKS_API_BASE\") and importlib.util.find_spec(\"databricks.sdk\") is None:\n    raise RuntimeError(\"Set DATABRICKS_API_BASE/_API_KEY or pip install databricks-sdk\")","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=\"databricks/mymodel\", messages=msgs)\nexcept Exception as e:\n    if \"databricks-sdk\" in str(e):\n        raise ConfigError(\"Missing Databricks config: set DATABRICKS_API_BASE and DATABRICKS_API_KEY\") from e\n    raise","preventionTips":["In Dockerfiles, either bake databricks-sdk or enforce env-var config at container startup","Add a config validation step at app boot for every configured provider"],"tags":["databricks","config","dependency","authentication"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}