{"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":"exception","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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/databricks/chat/transformation.py#L608-L644","documentation":"The Databricks chat completion handler wraps both raw_response.json() and construction of the DatabricksResponse pydantic model in one try/except. Any failure — a non-JSON body, or JSON missing required completion fields (id/created/usage) — raises DatabricksException 'Unable to get json response' embedding the parser error plus the entire original response text (request logging already ran with a redacted api_key). The 'Original Response' portion is your diagnosis.","triggerScenarios":"litellm.completion(model='databricks/...', ...) where the serving endpoint returns HTML (workspace login redirect when the URL points at the UI), an error JSON without completion fields, a 200 from a non-OpenAI-compatible gateway schema, or a truncated body from a dropped connection.","commonSituations":"DATABRICKS_API_BASE pointing at the workspace UI instead of the serving-endpoints path; endpoint in 'building/failed' state returning an error body; external-model endpoints with non-OpenAI response shapes; response-size limits at a proxy.","solutions":["Read 'Original Response' in the message — it shows exactly what came back (login HTML, error JSON, empty string)","Verify the endpoint directly: curl <api_base>/<endpoint>/invocations with the same token","Fix DATABRICKS_API_BASE so it targets the serving-endpoints API path, not the workspace UI","If the body is valid JSON but lacks id/created/usage, the endpoint is not returning an OpenAI-compatible schema — use an OpenAI-compatible serving config or the right provider prefix"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import os\n\ndef databricks_base_ok() -> bool:\n    base = os.getenv('DATABRICKS_API_BASE', '')\n    return base.rstrip('/').endswith('/serving-endpoints')  # not the workspace UI\n\nif not databricks_base_ok():\n    raise RuntimeError('DATABRICKS_API_BASE must target the serving-endpoints API path')","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model='databricks/my-ep', messages=msgs)\nexcept Exception as e:\n    if 'Unable to get json response' in str(e):\n        log.error('non-OpenAI body from endpoint: %s', str(e)[-2000:])  # contains Original Response\n    raise","preventionTips":["Verify the serving endpoint with one curl invocation during deployment","Ensure the endpoint is deployed and OpenAI-compatible before wiring it into litellm"],"tags":["databricks","chat","json","response-parsing"],"backgroundTag":"invalid-json-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}