{"record":{"id":"d3bd0f4705dcdba5","repo":"BerriAI/litellm","slug":"failed-to-transform-response-to-anthropic-format","errorCode":null,"errorMessage":"Failed to transform response to Anthropic format","messagePattern":"Failed to transform response to Anthropic format","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/experimental_pass_through/adapters/handler.py","lineNumber":627,"sourceCode":"            transformed_stream: Final = ANTHROPIC_ADAPTER.translate_completion_output_params_streaming(\n                completion_response,\n                model=model,\n                tool_name_mapping=tool_name_mapping,\n                polyfill_result=polyfill_result,\n                is_async=True,\n            )\n            if transformed_stream is not None:\n                return transformed_stream\n            raise ValueError(\"Failed to transform streaming response\")\n        else:\n            anthropic_response: Final = ANTHROPIC_ADAPTER.translate_completion_output_params(\n                cast(ModelResponse, completion_response),\n                tool_name_mapping=tool_name_mapping,\n                polyfill_result=polyfill_result,\n            )\n            if anthropic_response is not None:\n                return anthropic_response\n            raise ValueError(\"Failed to transform response to Anthropic format\")\n\n    @staticmethod\n    def anthropic_messages_handler(\n        max_tokens: int,\n        messages: _AnthropicMessages,\n        model: str,\n        metadata: dict[str, object] | None = None,\n        stop_sequences: list[str] | None = None,\n        stream: bool | None = False,\n        system: str | None = None,\n        temperature: float | None = None,\n        thinking: dict[str, object] | None = None,\n        tool_choice: dict[str, object] | None = None,\n        tools: list[dict[str, object]] | None = None,\n        top_k: int | None = None,\n        top_p: float | None = None,\n        output_format: dict[str, object] | None = None,\n        _is_async: bool = False,","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py#L609-L645","documentation":"Error \"Failed to transform response to Anthropic format\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/anthropic/experimental_pass_through/adapters/handler.py:627 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the upstream response format; see logs for details."],"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"}