BerriAI/litellm · error · ImportError

Missing aws_sdk_bedrock_runtime. Install with: pip install a

Error message

Missing aws_sdk_bedrock_runtime. Install with: pip install aws-sdk-bedrock-runtime

What it means

The Bedrock realtime (bidirectional stream) handler imports aws_sdk_bedrock_runtime (and smithy_aws_core) at call time. If the package is not installed, an ImportError is raised telling you to pip install aws-sdk-bedrock-runtime. This is an optional dependency required only for realtime voice use cases on Bedrock.

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 6c2dcb801b)

Solutions

  1. pip install aws-sdk-bedrock-runtime (which brings smithy-aws-core).
  2. Pin it in requirements/pyproject alongside litellm if you use Bedrock realtime.
  3. Verify with python -c "from aws_sdk_bedrock_runtime.client import BedrockRuntimeClient" that the install is healthy.

Example fix

# before: ImportError at realtime call
pip install litellm

# after
pip install litellm aws-sdk-bedrock-runtime
Defensive patterns

Strategy: try-catch

Validate before calling

def bedrock_realtime_deps_available() -> bool:
    try:
        import aws_sdk_bedrock_runtime  # noqa: F401
        import smithy_aws_core  # noqa: F401
        return True
    except ImportError:
        return False

Type guard

def can_use_bedrock_realtime() -> bool:
    return bedrock_realtime_deps_available()

Try / catch

try:
    await litellm.realtime(model=model, ...)
except ImportError as e:
    if "aws-sdk-bedrock-runtime" in str(e):
        raise SetupError("Install optional dep: pip install aws-sdk-bedrock-runtime") from e
    raise

Prevention

When it happens

Trigger: Calling litellm.realtime() or the realtime socket handler with provider bedrock without having installed the aws-sdk-bedrock-runtime wheel (and its smithy_aws_core dependency).

Common situations: Fresh venv with plain 'pip install litellm' — the realtime SDK is not a default dependency; CI images trimmed of optional deps; mixing python versions where the wheel is unavailable.

Related errors


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