BerriAI/litellm · error · DatabricksException
Unable to get json response - {e}, Original Response: {raw_r
Error message
Unable to get json response - {e}, Original Response: {raw_response.text} What it means
Raised when the Databricks serving-endpoint response body cannot be deserialized into DatabricksResponse (raw_response.json() fails or the schema does not fit). The exception embeds both the underlying parse error and the raw response text, plus the HTTP status and response headers, wrapped in DatabricksException.
Source
Thrown at litellm/llms/databricks/chat/transformation.py:626
json_mode: bool | None = None,
) -> ModelResponse:
# Redact sensitive data before logging to prevent credential leakage
redacted_request_data: Final = self.redact_sensitive_data(request_data)
## LOGGING - Never log actual API keys
logging_obj.post_call(
input=messages,
api_key="[REDACTED]",
original_response=raw_response.text,
additional_args={"complete_input_dict": redacted_request_data},
)
## RESPONSE OBJECT
try:
completion_response: Final = DatabricksResponse(**raw_response.json())
except Exception as e:
response_headers: Final = getattr(raw_response, "headers", None)
raise DatabricksException(
message=f"Unable to get json response - {e}, Original Response: {raw_response.text}",
status_code=raw_response.status_code,
headers=response_headers,
)
_custom_llm_provider: Final = litellm_params.get("custom_llm_provider") or "databricks"
_response_model: Final = completion_response.get("model") or ""
model_response.model = f"{_custom_llm_provider}/{_response_model}"
model_response.id = completion_response["id"]
model_response.created = completion_response["created"]
setattr(model_response, "usage", Usage(**completion_response["usage"]))
model_response.choices = self._transform_dbrx_choices(
choices=completion_response["choices"],
json_mode=json_mode,
)
return model_responseView on GitHub (pinned to 6c2dcb801b)
Solutions
- Read 'Original Response' in the message — it shows the actual body (HTML sign-in page means wrong api_base/auth)
- Verify api_base points to https://<workspace-host>/serving-endpoints and the token is a valid DATABRICKS_API_KEY
- Confirm the model is deployed and serving on the endpoint (check in the Databricks UI)
- If the endpoint is not Databricks-native, use the appropriate provider/client (e.g. OpenAI-compatible) instead
Defensive patterns
Strategy: try-catch
Validate before calling
assert os.getenv("DATABRICKS_API_BASE", "").endswith("/serving-endpoints"), "api_base must target the serving-endpoints path" Try / catch
try:
resp = litellm.completion(model=m, messages=msgs)
except Exception as e:
if "Unable to get json response" in str(e):
logger.error("Non-JSON Databricks response: %s", e)
raise UpstreamError("Check Databricks endpoint/auth config") from e
raise Prevention
- Smoke-test the endpoint with curl -H "Authorization: Bearer $DATABRICKS_API_KEY" before wiring into the app
- Ensure api_base includes /serving-endpoints and the token is a valid workspace PAT
When it happens
Trigger: Databricks model serving endpoint returns non-JSON (HTML auth page, gateway error) or a JSON shape that fails DatabricksResponse validation — e.g. hitting an external/third-party model endpoint with a Databricks-style handler, or an endpoint that errors at the LB level.
Common situations: Using Databricks provider config for a non-Databricks custom endpoint; workspace URL misconfigured so the request lands on a sign-in page; model serving endpoint returning an unexpected error body during outages.
Related errors
- Unsupported content type: {type(content)}
- KeyError: {e}, Got unexpected response from Databricks: {chu
- Either set the DATABRICKS_API_BASE and DATABRICKS_API_KEY en
- OAuth M2M token request failed: {e}
- OAuth M2M token request failed: {response.text}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/3e15d4c1751ece37.
Report an issue: GitHub.