{"record":{"id":"86b2cf998128641c","repo":"BerriAI/litellm","slug":"bedrock-event-stream-shape-could-not-be-loaded-fro","errorCode":null,"errorMessage":"Bedrock event-stream shape could not be loaded from botocore. Ensure botocore is correctly installed.","messagePattern":"Bedrock event-stream shape could not be loaded from botocore\\. Ensure botocore is correctly installed\\.","errorType":"http","errorClass":"BedrockError","httpStatus":500,"severity":"critical","filePath":"litellm/llms/bedrock/chat/invoke_handler.py","lineNumber":678,"sourceCode":"                    yield self._chunk_parser(chunk_data=_data)\n\n    async def aiter_bytes(self, iterator: AsyncIterator[bytes]) -> AsyncIterator[GChunk | ModelResponseStream | dict]:\n        \"\"\"Given an async iterator that yields lines, iterate over it & yield every event encountered\"\"\"\n        from botocore.eventstream import EventStreamBuffer\n\n        event_stream_buffer: Final = EventStreamBuffer()\n        async for chunk in iterator:\n            event_stream_buffer.add_data(chunk)\n            for event in event_stream_buffer:\n                message = self._parse_message_from_event(event)\n                if message:\n                    _data = json.loads(message)\n                    yield self._chunk_parser(chunk_data=_data)\n\n    def _parse_message_from_event(self, event) -> str | None:\n        response_stream_shape: Final = get_bedrock_response_stream_shape()\n        if response_stream_shape is None:\n            raise BedrockError(\n                status_code=500,\n                message=(\n                    \"Bedrock event-stream shape could not be loaded from botocore. \"\n                    \"Ensure botocore is correctly installed.\"\n                ),\n            )\n        response_dict: Final = event.to_response_dict()\n        parsed_response: Final = self.parser.parse(response_dict, response_stream_shape)\n\n        if response_dict[\"status_code\"] != 200:\n            raise build_bedrock_stream_error(response_dict, response_stream_shape)\n        if \"chunk\" in parsed_response:\n            chunk = parsed_response.get(\"chunk\")\n            if not chunk:\n                return None\n            return chunk.get(\"bytes\").decode()\n        else:\n            chunk = response_dict.get(\"body\")","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/chat/invoke_handler.py#L660-L696","documentation":"Raised inside AWSEventStreamDecoder._parse_message_from_event when get_bedrock_response_stream_shape() returns None, i.e. litellm could not load the 'responseStream' event-stream shape from the installed botocore's Bedrock service model. Because decoding the AWS binary event-stream format depends on that shape, parsing cannot proceed and a BedrockError 500 with the fixed message is raised.","triggerScenarios":"Streaming a bedrock/ completion when botocore is missing, is a stripped/partial install without the bedrock-runtime service model, or the botocore version is so old that the service model JSON lacks the event-stream shape litellm looks up by name.","commonSituations":"Slim docker images that install botocore-core or vendor only some service models, pinned ancient boto3/botocore versions, CI environments where botocore is downgraded as a transitive dependency, or litellm versions whose shape-lookup key does not match the installed botocore model.","solutions":["Run pip install -U boto3 botocore to get a complete, current Bedrock service model.","Verify the shape loads: python -c \"import botocore; from botocore.loaders import Loader; print(Loader().load_service_model('bedrock-runtime', 'service-2'))\".","If botocore is intentionally pinned, raise the floor to a version that includes bedrock-runtime event streaming (any recent 1.3x+).","Reinstall in the failing environment (pip install --force-reinstall botocore) to repair a corrupted partial install.","Keep litellm and boto3 upgraded together so the shape-lookup code matches the model file."],"exampleFix":"# before\npip install litellm  # botocore pulled in transitively, possibly stale\n\n# after\npip install -U litellm boto3 botocore\n# verify the bedrock-runtime service model is present\npython -c \"import botocore.session; s=botocore.session.get_session(); m=s.get_service_model('bedrock-runtime'); print(m.shape_for('responseStream'))\"","handlingStrategy":"validation","validationCode":"from litellm.llms.bedrock.common_utils import get_bedrock_response_stream_shape\nif get_bedrock_response_stream_shape() is None:\n    raise RuntimeError(\"botocore bedrock-runtime service model missing - run: pip install -U boto3 botocore\")","typeGuard":"def bedrock_stream_decode_ready() -> bool:\n    try:\n        from litellm.llms.bedrock.common_utils import get_bedrock_response_stream_shape\n    except Exception:\n        return False\n    return get_bedrock_response_stream_shape() is not None","tryCatchPattern":"from litellm.exceptions import BedrockError\ntry:\n    stream = litellm.completion(model=\"bedrock/<model>\", messages=msgs, stream=True)\nexcept BedrockError as e:\n    if \"event-stream shape could not be loaded\" in str(e):\n        raise RuntimeError(\"Fix environment: pip install -U boto3 botocore\") from e\n    raise","preventionTips":["Assert get_bedrock_response_stream_shape() is not None in a startup check for streaming services.","Install full boto3 (not stripped botocore variants) in production images.","Add a CI step that runs a one-chunk Bedrock stream to catch dependency breakage before deploy."],"tags":["aws","bedrock","botocore","dependency","streaming"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}