diff --git a/litellm/llms/databricks/common_utils.py b/litellm/llms/databricks/common_utils.py index d5b64583f6..eab9e2f825 100644 --- a/litellm/llms/databricks/common_utils.py +++ b/litellm/llms/databricks/common_utils.py @@ -67,7 +67,7 @@ class DatabricksBase: custom_endpoint: Optional[bool], headers: Optional[dict], ) -> Tuple[str, dict]: - if api_key is None and headers is None: + if api_key is None and not headers: # handle empty headers if custom_endpoint is not None: raise DatabricksException( status_code=400, diff --git a/tests/llm_translation/test_databricks.py b/tests/llm_translation/test_databricks.py index f24bcb2c99..0ca1028a55 100644 --- a/tests/llm_translation/test_databricks.py +++ b/tests/llm_translation/test_databricks.py @@ -216,7 +216,7 @@ def test_throws_if_api_base_or_api_key_not_set_without_databricks_sdk( # Simulate that the databricks SDK is not installed monkeypatch.setitem(sys.modules, "databricks.sdk", None) - err_msg = "the Databricks base URL and API key are not set" + err_msg = ["the Databricks base URL and API key are not set", "Missing API Key"] if set_base: monkeypatch.setenv( @@ -237,14 +237,14 @@ def test_throws_if_api_base_or_api_key_not_set_without_databricks_sdk( model="databricks/dbrx-instruct-071224", messages=[{"role": "user", "content": "How are you?"}], ) - assert err_msg in str(exc) + assert any(msg in str(exc) for msg in err_msg) with pytest.raises(BadRequestError) as exc: litellm.embedding( model="databricks/bge-12312", input=["Hello", "World"], ) - assert err_msg in str(exc) + assert any(msg in str(exc) for msg in err_msg) def test_completions_with_sync_http_handler(monkeypatch):