{"record":{"id":"96fe10b3f4490b8c","repo":"BerriAI/litellm","slug":"invalid-json-response-raw-response-text","errorCode":null,"errorMessage":"Invalid JSON response: {raw_response.text}","messagePattern":"Invalid JSON response: (.+?)","errorType":"exception","errorClass":"GigaChatError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gigachat/chat/transformation.py","lineNumber":402,"sourceCode":"    def transform_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,\n        model_response: ModelResponse,\n        logging_obj: LiteLLMLoggingObj,\n        request_data: dict,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        encoding: Any,\n        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> ModelResponse:\n        \"\"\"Transform GigaChat response to OpenAI format.\"\"\"\n        try:\n            response_json: Final = raw_response.json()\n        except Exception:\n            raise GigaChatError(\n                status_code=raw_response.status_code,\n                message=f\"Invalid JSON response: {raw_response.text}\",\n            )\n\n        is_structured_output: Final = optional_params.get(\"_structured_output\", False)\n\n        choices: Final = []\n        for choice in response_json.get(\"choices\", []):\n            message_data = choice.get(\"message\", {})\n            finish_reason = choice.get(\"finish_reason\", \"stop\")\n\n            # Transform function_call to tool_calls or content\n            if finish_reason == \"function_call\" and message_data.get(\"function_call\"):\n                func_call = message_data[\"function_call\"]\n                args = func_call.get(\"arguments\", {})\n\n                if is_structured_output:\n                    # Convert to content for structured output","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/gigachat/chat/transformation.py#L384-L420","documentation":"Error \"Invalid JSON response: {raw_response.text}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/gigachat/chat/transformation.py:402 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["GigaChat returned a non-JSON body; inspect the raw response in the error and check the api_base and proxy settings."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}