BerriAI/litellm · critical · BedrockError
Bedrock event-stream shape could not be loaded from botocore
Error message
Bedrock event-stream shape could not be loaded from botocore. Ensure botocore is correctly installed.
What it means
Identical condition to the decoder variant in invoke_handler.py, raised from the shared base event-stream decoder in common_utils.py: get_bedrock_response_stream_shape() returned None, so litellm could not obtain the bedrock-runtime 'responseStream' shape from the installed botocore and cannot decode the AWS binary event-stream. Surface as BedrockError 500 with the fixed botocore-installation message.
Source
Thrown at litellm/llms/bedrock/common_utils.py:1288
status_code = int(modeled_status)
return BedrockError(status_code=status_code, message=message)
class BedrockEventStreamDecoderBase:
"""
Base class for event stream decoding for Bedrock
"""
def __init__(self):
from botocore.parsers import EventStreamJSONParser
self.parser = EventStreamJSONParser()
def _parse_message_from_event(self, event) -> str | None:
response_stream_shape: Final = get_bedrock_response_stream_shape()
if response_stream_shape is None:
raise BedrockError(
status_code=500,
message=(
"Bedrock event-stream shape could not be loaded from botocore. "
"Ensure botocore is correctly installed."
),
)
response_dict: Final = event.to_response_dict()
parsed_response: Final = self.parser.parse(response_dict, response_stream_shape)
if response_dict["status_code"] != 200:
raise build_bedrock_stream_error(response_dict, response_stream_shape)
if "chunk" in parsed_response:
chunk = parsed_response.get("chunk")
if not chunk:
return None
return chunk.get("bytes").decode()
else:
chunk = response_dict.get("body")View on GitHub (pinned to 6c2dcb801b)
Solutions
- Install/upgrade a full botocore: pip install -U boto3 botocore.
- Verify the service model exists: inspect botocore.loaders for bedrock-runtime service-2.json in the installed package.
- If you must pin botocore, use a version that ships bedrock-runtime event-stream models (recent 1.3x+).
- Repair corrupted installs with pip install --force-reinstall botocore.
Example fix
# before (image installs botocore-core without service models) pip install botocore-core # after pip install -U boto3 botocore python -c "from litellm.llms.bedrock.common_utils import get_bedrock_response_stream_shape; print(get_bedrock_response_stream_shape())" # must not be None
Defensive patterns
Strategy: validation
Validate before calling
from litellm.llms.bedrock.common_utils import get_bedrock_response_stream_shape
if get_bedrock_response_stream_shape() is None:
raise RuntimeError("botocore lacks bedrock-runtime event-stream model - run: pip install -U boto3 botocore") Type guard
def event_stream_shape_available() -> bool:
try:
from litellm.llms.bedrock.common_utils import get_bedrock_response_stream_shape
return get_bedrock_response_stream_shape() is not None
except Exception:
return False Try / catch
from litellm.exceptions import BedrockError
try:
for chunk in litellm.completion(model="bedrock/<model>", messages=msgs, stream=True):
pass
except BedrockError as e:
if "event-stream shape" in str(e):
raise RuntimeError("Dependency fix required: pip install -U boto3 botocore") from e
raise Prevention
- Run a dependency smoke test (stream one chunk) in container builds that use Bedrock streaming.
- Never deploy stripped botocore packages; install full boto3.
- Alert on botocore downgrades in lockfile diffs.
When it happens
Trigger: Any Bedrock streaming decode that goes through the base decoder when botocore is absent, incomplete (missing bedrock-runtime service model), or too old to contain the event-stream shape litellm looks up.
Common situations: Docker images stripping botocore service models, dependency downgrades in lockfiles, lambda layers with partial boto3 installs, or freshly added model families hitting this code path before botocore is upgraded.
Related errors
- Bedrock event-stream shape could not be loaded from botocore
- Received streaming error - {e}
- Model needs to be set for bedrock
- Missing boto3 to call bedrock. Run 'pip install boto3'.
- Missing boto3 to call S3. Run 'pip install boto3'.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/a550dda2addc1dd6.
Report an issue: GitHub.