Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(databricks/chat/transformation.py): handle empty headers case

Krrish Dholakiaaf9db827fccc
diff --git a/litellm/llms/databricks/common_utils.py b/litellm/llms/databricks/common_utils.py
index d5b64583f6f..eab9e2f825d 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 f24bcb2c990..0ca1028a556 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):