{"record":{"id":"4f703dec48e82592","repo":"BerriAI/litellm","slug":"error-parsing-response-raw-response-text-error","errorCode":null,"errorMessage":"Error parsing response: {raw_response.text}, error: {e}","messagePattern":"Error parsing response: (.+?), error: (.+?)","errorType":"exception","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_transformations/amazon_twelvelabs_pegasus_transformation.py","lineNumber":210,"sourceCode":"        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> ModelResponse:\n        \"\"\"\n        Transform TwelveLabs Pegasus response to LiteLLM format.\n\n        TwelveLabs response format:\n        {\n            \"message\": \"...\",\n            \"finishReason\": \"stop\" | \"length\"\n        }\n\n        LiteLLM format:\n        ModelResponse with choices[0].message.content and finish_reason\n        \"\"\"\n        try:\n            completion_response: Final = raw_response.json()\n        except Exception as e:\n            raise BedrockError(\n                message=f\"Error parsing response: {raw_response.text}, error: {e}\",\n                status_code=raw_response.status_code,\n            )\n\n        verbose_logger.debug(\n            \"twelvelabs pegasus response: %s\",\n            json.dumps(completion_response, indent=4, default=str),\n        )\n\n        # Extract message content\n        message_content: Final = completion_response.get(\"message\", \"\")\n\n        # Extract finish reason and map to LiteLLM format\n        finish_reason_raw: Final = completion_response.get(\"finishReason\", \"stop\")\n        finish_reason: Final = map_finish_reason(finish_reason_raw)\n\n        # Set the response content\n        try:","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/invoke_transformations/amazon_twelvelabs_pegasus_transformation.py#L192-L228","documentation":"Response-parsing failure in the TwelveLabs Pegasus response transformer: raw_response.json() raised, so the body is not valid JSON and the 'message'/'finishReason' fields cannot be extracted into a ModelResponse.","triggerScenarios":"Thrown at litellm/llms/bedrock/chat/invoke_transformations/amazon_twelvelabs_pegasus_transformation.py:210 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect raw_response.text for a Bedrock-side error message.","Verify the TwelveLabs Pegasus model id and request format.","Retry the request; if persistent, file an issue with the raw response."],"exampleFix":null,"handlingStrategy":"try-catch","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"}