BerriAI/litellm · error · AnthropicError

{message}

Error message

{message}

What it means

Error "{message}" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/anthropic/chat/handler.py:949

                        "stop_reason": null,
                        "stop_sequence": null,
                        "usage": {
                            "input_tokens": 270,
                            "output_tokens": 1
                        }
                    }
                }
                """
                message_start_block: Final = MessageStartBlock(**chunk)
                if "usage" in message_start_block["message"]:
                    usage = self._handle_usage(anthropic_usage_chunk=message_start_block["message"]["usage"])
            elif type_chunk == "error":
                """
                {"type":"error","error":{"details":null,"type":"api_error","message":"Internal server error"}      }
                """
                _error_dict: Final = chunk.get("error", {}) or {}
                message: Final = _error_dict.get("message", None) or str(chunk)
                raise AnthropicError(
                    message=message,
                    status_code=500,  # it looks like Anthropic API does not return a status code in the chunk error - default to 500
                )

            text, tool_use = self._handle_json_mode_chunk(text=text, tool_use=tool_use)

            returned_chunk: Final = ModelResponseStream(
                choices=[
                    StreamingChoices(
                        index=index,
                        delta=Delta(
                            content=text,
                            tool_calls=[tool_use] if tool_use is not None else None,
                            provider_specific_fields=(provider_specific_fields if provider_specific_fields else None),
                            thinking_blocks=(thinking_blocks if thinking_blocks else None),
                            reasoning_content=reasoning_content,
                        ),
                        finish_reason=finish_reason,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect the streamed error message from Anthropic.

When it happens

Trigger: Thrown at litellm/llms/anthropic/chat/handler.py:949 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/2450d8f27f12b829. Report an issue: GitHub.