BerriAI/litellm · error · ImportError
Missing aws_sdk_bedrock_runtime. Install with: pip install…
Error message
Missing aws_sdk_bedrock_runtime. Install with: pip install aws-sdk-bedrock-runtime
What it means
The Bedrock realtime handler (bidirectional streaming, e.g. Nova Sonic) imports the aws_sdk_bedrock_runtime preview SDK and smithy_aws_core.identity at session start; an ImportError is caught and re-raised with this pip hint. boto3/botocore alone is not enough for realtime: the separate aws-sdk-bedrock-runtime package is required because bimi-directional streaming is not in boto3.
Solutions
- pip install aws-sdk-bedrock-runtime
- Add aws-sdk-bedrock-runtime to requirements.txt/pyproject alongside litellm
- Verify with: python -c "import aws_sdk_bedrock_runtime"
Example fix
# before: ImportError at session start # after pip install aws-sdk-bedrock-runtime
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec("aws_sdk_bedrock_runtime") is None:
raise SystemExit(
"bedrock realtime requires the preview SDK; install with: pip install aws-sdk-bedrock-runtime"
) Type guard
def bedrock_realtime_available() -> bool:
"""True when the realtime preview SDK and its smithy dependency are importable."""
return importlib.util.find_spec("aws_sdk_bedrock_runtime") is not None and importlib.util.find_spec("smithy_aws_core") is not None Try / catch
try:
session = litellm.realtime(model="bedrock/amazon.nova-sonic-v1:0", ...)
except ImportError as e:
if "aws_sdk_bedrock_runtime" in str(e):
raise SystemExit("pip install aws-sdk-bedrock-runtime") from e
raise Prevention
- Add aws-sdk-bedrock-runtime to requirements whenever realtime models are deployed
- Fail fast at container startup with find_spec checks for optional heavy deps
- Keep a smoke test that opens a realtime session in CI to catch missing extras
When it happens
Trigger: Starting a litellm realtime session against a Bedrock realtime model in an environment where aws_sdk_bedrock_runtime is not installed (only litellm base deps or boto3 present).
Common situations: Slim Docker images, CI environments, or requirements files that never included the realtime extra; environments where chat/completion via SigV4 works fine, masking the missing package.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Missing boto3 to call bedrock. Run 'pip install boto3'.
- A2A SDK is required for localhost retry handling. Install…
- boto3/botocore is required for AWS event stream parsing
- google-cloud-iam is required for GCP IAM Redis…
- Importing torch, transformers, petals failed Try pip…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/8e15c40985371500.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/realtime/handler.py:69
"""
Establish bidirectional streaming connection with Bedrock Nova Sonic.
Args:
model: Model ID (e.g., 'amazon.nova-sonic-v1:0')
websocket: Client WebSocket connection
logging_obj: LiteLLM logging object
aws_region_name: AWS region
Various AWS authentication parameters
"""
try:
from aws_sdk_bedrock_runtime.client import (
BedrockRuntimeClient,
InvokeModelWithBidirectionalStreamOperationInput,
)
from aws_sdk_bedrock_runtime.config import Config
from smithy_aws_core.identity import StaticCredentialsResolver
except ImportError:
raise ImportError("Missing aws_sdk_bedrock_runtime. Install with: pip install aws-sdk-bedrock-runtime")
# Get AWS region
if aws_region_name is None:
optional_params: Final = {
"aws_region_name": aws_region_name,
}
aws_region_name = self._get_aws_region_name(optional_params, model)
# Get endpoint URL
if api_base is not None:
endpoint_uri = api_base
elif aws_bedrock_runtime_endpoint is not None:
endpoint_uri = aws_bedrock_runtime_endpoint
else:
endpoint_uri = f"https://bedrock-runtime.{aws_region_name}.amazonaws.com"
verbose_proxy_logger.debug("Bedrock Realtime: Connecting to %s with model %s", endpoint_uri, model)
View on GitHub (pinned to 77b7c6c40c)