{"record":{"id":"95ec2f997e3e553b","repo":"BerriAI/litellm","slug":"if-the-databricks-base-url-and-api-key-are-not-set","errorCode":null,"errorMessage":"If the Databricks base URL and API key are not set, the databricks-sdk Python library must be installed. Please install the databricks-sdk, set {LLM_PROVIDER}_API_BASE and {LLM_PROVIDER}_API_KEY environment variables, or provide the base URL and API key as arguments.","messagePattern":"If the Databricks base URL and API key are not set, the databricks-sdk Python library must be installed\\. Please install the databricks-sdk, set (.+?)_API_BASE and (.+?)_API_KEY environment variables, or provide the base URL and API key as arguments\\.","errorType":"http","errorClass":"DatabricksException","httpStatus":400,"severity":"error","filePath":"litellm/llms/databricks/common_utils.py","lineNumber":294,"sourceCode":"        \"\"\"\n        headers = headers or {\"Content-Type\": \"application/json\"}\n        try:\n            from databricks.sdk import WorkspaceClient, useragent\n\n            # Register LiteLLM as partner for Databricks telemetry attribution\n            useragent.with_partner(\"litellm\")\n\n            databricks_client: Final = WorkspaceClient()\n\n            api_base = api_base or f\"{databricks_client.config.host}/serving-endpoints\"\n\n            if api_key is None:\n                databricks_auth_headers: Final[dict[str, str]] = databricks_client.config.authenticate()\n                headers = {**databricks_auth_headers, **headers}\n\n            return api_base, headers\n        except ImportError:\n            raise DatabricksException(\n                status_code=400,\n                message=(\n                    \"If the Databricks base URL and API key are not set, the databricks-sdk \"\n                    \"Python library must be installed. Please install the databricks-sdk, set \"\n                    \"{LLM_PROVIDER}_API_BASE and {LLM_PROVIDER}_API_KEY environment variables, \"\n                    \"or provide the base URL and API key as arguments.\"\n                ),\n            )\n\n    def databricks_validate_environment(\n        self,\n        api_key: str | None,\n        api_base: str | None,\n        endpoint_type: Literal[\"chat_completions\", \"embeddings\"],\n        custom_endpoint: bool | None,\n        headers: dict | None,\n        custom_user_agent: str | None = None,\n    ) -> tuple[str, dict]:","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/databricks/common_utils.py#L276-L312","documentation":"Raised when LiteLLM needs Databricks credentials, none were supplied explicitly, and falling back to the databricks-sdk fails because the library is not installed. The message enumerates all three remedies: install databricks-sdk, set the LLM_PROVIDER_API_BASE/_API_KEY env vars, or pass base URL and key as arguments.","triggerScenarios":"Databricks model call with neither api_key nor matching env vars, in a Python environment without databricks-sdk installed — the credential-resolution chain (explicit -> env -> SDK) exhausts at the SDK import.","commonSituations":"LiteLLM proxy deployments where only some Databricks env vars are set (e.g. key but no base, triggering SDK path); upgrading litellm in an image that never needed databricks-sdk before; per-model LLM_PROVIDER prefixes (e.g. DATABRICKS_API_BASE) misnamed.","solutions":["Set both DATABRICKS_API_BASE and DATABRICKS_API_KEY explicitly — preferred for server deployments","Or pip install databricks-sdk to enable SDK-based credential discovery","In proxy config, put api_base and api_key in the model's litellm_params so resolution never reaches the SDK","Check the exact env var prefix expected for your provider alias"],"exampleFix":"# litellm config.yaml — before\nmodel_list:\n  - model_name: mymodel\n    litellm_params:\n      model: databricks/databricks-dbrx-instruct\n\n# after\nmodel_list:\n  - model_name: mymodel\n    litellm_params:\n      model: databricks/databricks-dbrx-instruct\n      api_base: https://adb-123.0.azuredatabricks.net/serving-endpoints\n      api_key: os.environ/DATABRICKS_API_KEY","handlingStrategy":"validation","validationCode":"has_sdk = importlib.util.find_spec(\"databricks.sdk\") is not None\nif not (os.getenv(\"DATABRICKS_API_BASE\") and os.getenv(\"DATABRICKS_API_KEY\")) and not has_sdk:\n    raise RuntimeError(\"Databricks unconfigured: set API base+key or 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) or \"DATABRICKS\" in str(e):\n        raise ConfigError(\"Databricks provider not configured\") from e\n    raise","preventionTips":["Always set api_base and api_key explicitly in proxy config for Databricks models","Treat optional-dependency absence as a config error caught at startup, not at first request"],"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"}