{"record":{"id":"b47d9193c76fabe1","repo":"BerriAI/litellm","slug":"raw-response-text","errorCode":null,"errorMessage":"{raw_response.text}","messagePattern":"\\{raw_response\\.text\\}","errorType":"http","errorClass":"AnthropicTextError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/completion/transformation.py","lineNumber":192,"sourceCode":"\n    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: str,\n        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> ModelResponse:\n        try:\n            completion_response: Final = raw_response.json()\n        except Exception:\n            raise AnthropicTextError(message=raw_response.text, status_code=raw_response.status_code)\n        prompt: Final = self._get_anthropic_text_prompt_from_messages(messages=messages, model=model)\n        if \"error\" in completion_response:\n            raise AnthropicTextError(\n                message=str(completion_response[\"error\"]),\n                status_code=raw_response.status_code,\n            )\n        else:\n            if len(completion_response[\"completion\"]) > 0:\n                model_response.choices[0].message.content = completion_response[\"completion\"]\n            model_response.choices[0].finish_reason = completion_response[\"stop_reason\"]\n\n        ## CALCULATING USAGE\n        prompt_tokens: Final = len(encoding.encode(prompt))  ##[TODO] use the anthropic tokenizer here\n        completion_tokens: Final = len(\n            encoding.encode(model_response[\"choices\"][0][\"message\"].get(\"content\", \"\"))\n        )  ##[TODO] use the anthropic tokenizer here\n\n        model_response.created = int(time.time())","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/anthropic/completion/transformation.py#L174-L210","documentation":"Error \"{raw_response.text}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/anthropic/completion/transformation.py:192 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the Anthropic response text for the error detail."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}