BerriAI/litellm · error · ImportError

Missing boto3 to call AWS Polly. Run 'pip install boto3'.

Error message

Missing boto3 to call AWS Polly. Run 'pip install boto3'.

What it means

Dependency error while signing an AWS Polly text-to-speech request with SigV4. The transformation lazily imports botocore.auth.SigV4Auth / botocore.awsrequest.AWSRequest; if the boto3/botocore package is not installed, the ImportError is re-raised with an install hint. Polly requests are signed and sent directly, so botocore must be present in the calling environment.

Source

Thrown at litellm/llms/aws_polly/text_to_speech/transformation.py:267

        return "<speak>" in input or "<speak " in input

    def _sign_polly_request(
        self,
        request_body: dict[str, Any],
        endpoint_url: str,
        litellm_params: dict,
    ) -> tuple[dict[str, str], str]:
        """
        Sign the AWS Polly request using SigV4.

        Returns:
            Tuple of (signed_headers, json_body_string)
        """
        try:
            from botocore.auth import SigV4Auth
            from botocore.awsrequest import AWSRequest
        except ImportError:
            raise ImportError("Missing boto3 to call AWS Polly. Run 'pip install boto3'.")

        # Get AWS region
        aws_region_name: Final = litellm_params.get("aws_region_name", self.DEFAULT_REGION)

        # Get AWS credentials
        credentials: Final = self.get_credentials(
            aws_access_key_id=litellm_params.get("aws_access_key_id"),
            aws_secret_access_key=litellm_params.get("aws_secret_access_key"),
            aws_session_token=litellm_params.get("aws_session_token"),
            aws_region_name=aws_region_name,
            aws_session_name=litellm_params.get("aws_session_name"),
            aws_profile_name=litellm_params.get("aws_profile_name"),
            aws_role_name=litellm_params.get("aws_role_name"),
            aws_web_identity_token=litellm_params.get("aws_web_identity_token"),
            aws_sts_endpoint=litellm_params.get("aws_sts_endpoint"),
            aws_external_id=litellm_params.get("aws_external_id"),
        )

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. pip install boto3 (or add boto3 to your requirements).
  2. For serverless images, ensure boto3 is in the final layer and not pruned by size optimizers.
  3. If botocore is installed but broken, check for version conflicts: pip check, then reinstall boto3.

Example fix

# before (shell)
python -c "import botocore"  # ModuleNotFoundError -> litellm Polly call raises ImportError

# after (shell)
pip install boto3
python -c "import botocore; print(botocore.__version__)"
Defensive patterns

Strategy: validation

Validate before calling

def polly_dependency_available() -> bool:
    try:
        import botocore.auth  # noqa: F401
        return True
    except ImportError:
        return False

Try / catch

try:
    audio = litellm.text_to_speech(model="aws_polly/...", ...)
except ImportError as e:
    if "boto3" in str(e):
        raise RuntimeError("TTS unavailable: run 'pip install boto3' to enable Polly") from e
    raise

Prevention

When it happens

Trigger: Calling litellm text-to-speech with an aws_polly model in an environment where boto3 (which bundles botocore) was never installed — litellm does not ship boto3 by default. Also when a slim/vendored install strips botocore.

Common situations: Adding Polly to an existing litellm deployment without the optional dependency; lambda/serverless images trimmed of boto3; dependency conflicts where another package pinned a botocore version that fails to import.

Related errors


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