BerriAI/litellm · error · ImportError

boto3/botocore is required for AWS event stream parsing

Error message

boto3/botocore is required for AWS event stream parsing

What it means

Error "boto3/botocore is required for AWS event stream parsing" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/bedrock/chat/invoke_agent/transformation.py:172

    ) -> dict:
        # use the last message content as the query
        query: Final[str] = convert_content_list_to_str(messages[-1])
        return {
            "inputText": query,
            "enableTrace": True,
            **optional_params,
        }

    def _parse_aws_event_stream(self, raw_content: bytes) -> InvokeAgentEventList:
        """
        Parse AWS event stream format using boto3/botocore's built-in parser.
        This is the same approach used in the existing AWSEventStreamDecoder.
        """
        try:
            from botocore.eventstream import EventStreamBuffer
            from botocore.parsers import EventStreamJSONParser
        except ImportError:
            raise ImportError("boto3/botocore is required for AWS event stream parsing")

        events: Final[InvokeAgentEventList] = []
        parser: Final = EventStreamJSONParser()
        event_stream_buffer: Final = EventStreamBuffer()

        # Add the entire response to the buffer
        event_stream_buffer.add_data(raw_content)

        # Process all events in the buffer
        for event in event_stream_buffer:
            try:
                headers = self._extract_headers_from_event(event)

                event_type = headers.get("event_type", "")

                if event_type == "chunk":
                    # Handle chunk events specially - they contain decoded content, not JSON
                    message = self._parse_message_from_event(event, parser)

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Install boto3/botocore for AWS event stream parsing.

When it happens

Trigger: Thrown at litellm/llms/bedrock/chat/invoke_agent/transformation.py:172 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/ed691af8acdb065c. Report an issue: GitHub.