BerriAI/litellm · error · DatabricksException

If the Databricks base URL and API key are not set, the data

Error message

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.

What it means

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.

Source

Thrown at litellm/llms/databricks/common_utils.py:294

        """
        headers = headers or {"Content-Type": "application/json"}
        try:
            from databricks.sdk import WorkspaceClient, useragent

            # Register LiteLLM as partner for Databricks telemetry attribution
            useragent.with_partner("litellm")

            databricks_client: Final = WorkspaceClient()

            api_base = api_base or f"{databricks_client.config.host}/serving-endpoints"

            if api_key is None:
                databricks_auth_headers: Final[dict[str, str]] = databricks_client.config.authenticate()
                headers = {**databricks_auth_headers, **headers}

            return api_base, headers
        except ImportError:
            raise DatabricksException(
                status_code=400,
                message=(
                    "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."
                ),
            )

    def databricks_validate_environment(
        self,
        api_key: str | None,
        api_base: str | None,
        endpoint_type: Literal["chat_completions", "embeddings"],
        custom_endpoint: bool | None,
        headers: dict | None,
        custom_user_agent: str | None = None,
    ) -> tuple[str, dict]:

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Set both DATABRICKS_API_BASE and DATABRICKS_API_KEY explicitly — preferred for server deployments
  2. Or pip install databricks-sdk to enable SDK-based credential discovery
  3. In proxy config, put api_base and api_key in the model's litellm_params so resolution never reaches the SDK
  4. Check the exact env var prefix expected for your provider alias

Example fix

# litellm config.yaml — before
model_list:
  - model_name: mymodel
    litellm_params:
      model: databricks/databricks-dbrx-instruct

# after
model_list:
  - model_name: mymodel
    litellm_params:
      model: databricks/databricks-dbrx-instruct
      api_base: https://adb-123.0.azuredatabricks.net/serving-endpoints
      api_key: os.environ/DATABRICKS_API_KEY
Defensive patterns

Strategy: validation

Validate before calling

has_sdk = importlib.util.find_spec("databricks.sdk") is not None
if not (os.getenv("DATABRICKS_API_BASE") and os.getenv("DATABRICKS_API_KEY")) and not has_sdk:
    raise RuntimeError("Databricks unconfigured: set API base+key or install databricks-sdk")

Try / catch

try:
    resp = litellm.completion(model="databricks/mymodel", messages=msgs)
except Exception as e:
    if "databricks-sdk" in str(e) or "DATABRICKS" in str(e):
        raise ConfigError("Databricks provider not configured") from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/95ec2f997e3e553b. Report an issue: GitHub.