{"record":{"id":"1762fc9daec9bdf5","repo":"BerriAI/litellm","slug":"received-streaming-error-e","errorCode":null,"errorMessage":"Received streaming error - {e}","messagePattern":"Received streaming error - (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_handler.py","lineNumber":591,"sourceCode":"                        delta=Delta(\n                            content=text,\n                            role=\"assistant\",\n                            tool_calls=[tool_use] if tool_use else None,\n                            provider_specific_fields=(provider_specific_fields if provider_specific_fields else None),\n                            thinking_blocks=thinking_blocks,\n                            reasoning_content=reasoning_content,\n                        ),\n                    )\n                ],\n                id=self.response_id,\n                model=self.model,\n                usage=usage,\n                provider_specific_fields=model_response_provider_specific_fields,\n            )\n\n            return response\n        except Exception as e:\n            raise Exception(f\"Received streaming error - {e}\")\n\n    def _chunk_parser(self, chunk_data: dict) -> GChunk | ModelResponseStream | dict:\n        text = \"\"\n        is_finished = False\n        finish_reason = \"\"\n        if \"outputText\" in chunk_data:\n            text = chunk_data[\"outputText\"]\n        # ai21 mapping\n        elif \"ai21\" in self.model:  # fake ai21 streaming\n            text = chunk_data[\"completions\"][0][\"data\"][\"text\"]\n            is_finished = True\n            finish_reason = \"stop\"\n        ######## /bedrock/converse mappings ###############\n        elif (\n            \"contentBlockIndex\" in chunk_data\n            or \"stopReason\" in chunk_data\n            or \"metrics\" in chunk_data\n            or \"trace\" in chunk_data","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/chat/invoke_handler.py#L573-L609","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the text after 'Received streaming error - ': it usually contains the AWS in-stream exception name.","If it is AccessDenied/Throttling, fix IAM permissions or quota rather than the code.","Upgrade litellm to the newest release so recently added Bedrock models and chunk schemas are supported.","If the payload is malformed, capture the raw stream (litellm verbose logging, LITELLM_LOG=DEBUG) and attach it to a bug report.","Consider the bedrock/converse/<model> route, which uses the Converse stream schema and is better maintained."],"exampleFix":"# before\nfor chunk in litellm.completion(model=\"bedrock/meta.llama3-8b-instruct-v1:0\", messages=msgs, stream=True):\n    print(chunk)\n\n# after\nfrom litellm.exceptions import BedrockError\ntry:\n    for chunk in litellm.completion(model=\"bedrock/meta.llama3-8b-instruct-v1:0\", messages=msgs, stream=True):\n        print(chunk)\nexcept BedrockError as e:\n    if \"ThrottlingException\" in str(e):\n        time.sleep(10)\n        raise  # let outer retry logic handle it\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.exceptions import BedrockError\ntry:\n    for chunk in litellm.completion(model=\"bedrock/<model>\", messages=msgs, stream=True):\n        process(chunk)\nexcept BedrockError as e:\n    if \"ThrottlingException\" in str(e):\n        time.sleep(10); retry_stream()\n    else:\n        log.error(\"stream chunk error: %s\", e.message)\n        raise","preventionTips":["Prefer the bedrock/converse/<model> route for streaming - its decoder is more actively maintained.","Keep litellm updated so new model chunk schemas are handled.","Treat any 'Received streaming error - ThrottlingException' as a signal to add rate limiting, not code changes."],"tags":["aws","bedrock","streaming","chunk-parsing","exception-wrapping"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}