BerriAI/litellm · error · Exception

Received streaming error - {e}

Error message

Received streaming error - {e}

What it means

AWSEventStreamDecoder._chunk_parser (and its surrounding stream-processing loop) wraps every exception raised while converting a Bedrock event-stream chunk into a litellm GenericStreamingChunk. The generic message 'Received streaming error - {e}' re-raises as a plain Exception with the original error appended, so the real cause (parsing, unexpected chunk schema, in-stream service error) is embedded after the dash.

Source

Thrown at litellm/llms/bedrock/chat/invoke_handler.py:591

                        delta=Delta(
                            content=text,
                            role="assistant",
                            tool_calls=[tool_use] if tool_use else None,
                            provider_specific_fields=(provider_specific_fields if provider_specific_fields else None),
                            thinking_blocks=thinking_blocks,
                            reasoning_content=reasoning_content,
                        ),
                    )
                ],
                id=self.response_id,
                model=self.model,
                usage=usage,
                provider_specific_fields=model_response_provider_specific_fields,
            )

            return response
        except Exception as e:
            raise Exception(f"Received streaming error - {e}")

    def _chunk_parser(self, chunk_data: dict) -> GChunk | ModelResponseStream | dict:
        text = ""
        is_finished = False
        finish_reason = ""
        if "outputText" in chunk_data:
            text = chunk_data["outputText"]
        # ai21 mapping
        elif "ai21" in self.model:  # fake ai21 streaming
            text = chunk_data["completions"][0]["data"]["text"]
            is_finished = True
            finish_reason = "stop"
        ######## /bedrock/converse mappings ###############
        elif (
            "contentBlockIndex" in chunk_data
            or "stopReason" in chunk_data
            or "metrics" in chunk_data
            or "trace" in chunk_data

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Read the text after 'Received streaming error - ': it usually contains the AWS in-stream exception name.
  2. If it is AccessDenied/Throttling, fix IAM permissions or quota rather than the code.
  3. Upgrade litellm to the newest release so recently added Bedrock models and chunk schemas are supported.
  4. If the payload is malformed, capture the raw stream (litellm verbose logging, LITELLM_LOG=DEBUG) and attach it to a bug report.
  5. Consider the bedrock/converse/<model> route, which uses the Converse stream schema and is better maintained.

Example fix

# before
for chunk in litellm.completion(model="bedrock/meta.llama3-8b-instruct-v1:0", messages=msgs, stream=True):
    print(chunk)

# after
from litellm.exceptions import BedrockError
try:
    for chunk in litellm.completion(model="bedrock/meta.llama3-8b-instruct-v1:0", messages=msgs, stream=True):
        print(chunk)
except BedrockError as e:
    if "ThrottlingException" in str(e):
        time.sleep(10)
        raise  # let outer retry logic handle it
    raise
Defensive patterns

Strategy: try-catch

Try / catch

from litellm.exceptions import BedrockError
try:
    for chunk in litellm.completion(model="bedrock/<model>", messages=msgs, stream=True):
        process(chunk)
except BedrockError as e:
    if "ThrottlingException" in str(e):
        time.sleep(10); retry_stream()
    else:
        log.error("stream chunk error: %s", e.message)
        raise

Prevention

When it happens

Trigger: Iterating a bedrock/ streaming response when a chunk fails to parse: unexpected provider payload shape, an in-stream AccessDeniedException/ThrottlingException event from Bedrock, or a stopReason/usage field with an unexpected type for the model being streamed.

Common situations: New model returning fields the installed litellm version does not map yet (version lag after a Bedrock model update), corrupted chunk from a proxy, or provider-specific streaming schemas (Titan vs AI21 vs Llama) hitting the wrong parser branch.

Related errors


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