{"record":{"id":"3e15d4c1751ece37","repo":"BerriAI/litellm","slug":"unable-to-get-json-response-e-original-respon-3e15d4","errorCode":null,"errorMessage":"Unable to get json response - {e}, Original Response: {raw_response.text}","messagePattern":"Unable to get json response - (.+?), Original Response: (.+?)","errorType":"http","errorClass":"DatabricksException","httpStatus":null,"severity":"error","filePath":"litellm/llms/databricks/chat/transformation.py","lineNumber":626,"sourceCode":"        json_mode: bool | None = None,\n    ) -> ModelResponse:\n        # Redact sensitive data before logging to prevent credential leakage\n        redacted_request_data: Final = self.redact_sensitive_data(request_data)\n\n        ## LOGGING - Never log actual API keys\n        logging_obj.post_call(\n            input=messages,\n            api_key=\"[REDACTED]\",\n            original_response=raw_response.text,\n            additional_args={\"complete_input_dict\": redacted_request_data},\n        )\n\n        ## RESPONSE OBJECT\n        try:\n            completion_response: Final = DatabricksResponse(**raw_response.json())\n        except Exception as e:\n            response_headers: Final = getattr(raw_response, \"headers\", None)\n            raise DatabricksException(\n                message=f\"Unable to get json response - {e}, Original Response: {raw_response.text}\",\n                status_code=raw_response.status_code,\n                headers=response_headers,\n            )\n\n        _custom_llm_provider: Final = litellm_params.get(\"custom_llm_provider\") or \"databricks\"\n        _response_model: Final = completion_response.get(\"model\") or \"\"\n        model_response.model = f\"{_custom_llm_provider}/{_response_model}\"\n        model_response.id = completion_response[\"id\"]\n        model_response.created = completion_response[\"created\"]\n        setattr(model_response, \"usage\", Usage(**completion_response[\"usage\"]))\n\n        model_response.choices = self._transform_dbrx_choices(\n            choices=completion_response[\"choices\"],\n            json_mode=json_mode,\n        )\n\n        return model_response","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/databricks/chat/transformation.py#L608-L644","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"assert os.getenv(\"DATABRICKS_API_BASE\", \"\").endswith(\"/serving-endpoints\"), \"api_base must target the serving-endpoints path\"","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=m, messages=msgs)\nexcept Exception as e:\n    if \"Unable to get json response\" in str(e):\n        logger.error(\"Non-JSON Databricks response: %s\", e)\n        raise UpstreamError(\"Check Databricks endpoint/auth config\") from e\n    raise","preventionTips":["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"],"tags":["databricks","chat","response-schema","authentication"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}