{"record":{"id":"355e26593c604b5c","repo":"BerriAI/litellm","slug":"completion-response-error-355e26","errorCode":null,"errorMessage":"{completion_response[\"error\"]}","messagePattern":"\\{completion_response\\[\"error\"\\]\\}","errorType":"http","errorClass":"AnthropicTextError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/completion/transformation.py","lineNumber":195,"sourceCode":"        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())\n        model_response.model = model\n        usage: Final = Usage(\n            prompt_tokens=prompt_tokens,","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/anthropic/completion/transformation.py#L177-L213","documentation":"Error \"{completion_response[\"error\"]}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/anthropic/completion/transformation.py:195 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the error field of the Anthropic completion response."],"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"}