{"record":{"id":"70444641a1e6fa04","repo":"BerriAI/litellm","slug":"missing-boto3-to-call-bedrock-run-pip-install-bo-704446","errorCode":null,"errorMessage":"Missing boto3 to call bedrock. Run 'pip install boto3'.","messagePattern":"Missing boto3 to call bedrock\\. Run 'pip install boto3'\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/rerank/handler.py","lineNumber":142,"sourceCode":"        )\n\n        response_json: Final = response.json()\n\n        return BedrockRerankConfig()._transform_response(response_json)\n\n    def _prepare_request(\n        self,\n        model: str,\n        api_base: str | None,\n        extra_headers: dict | None,\n        data: dict,\n        optional_params: dict,\n    ) -> BedrockPreparedRequest:\n        try:\n            from botocore.auth import SigV4Auth\n            from botocore.awsrequest import AWSRequest\n        except ImportError:\n            raise ImportError(\"Missing boto3 to call bedrock. Run 'pip install boto3'.\")\n        boto3_credentials_info: Final = self._get_boto_credentials_from_optional_params(optional_params, model)\n\n        ### SET RUNTIME ENDPOINT ###\n        _, proxy_endpoint_url = self.get_runtime_endpoint(\n            api_base=api_base,\n            aws_bedrock_runtime_endpoint=boto3_credentials_info.aws_bedrock_runtime_endpoint,\n            aws_region_name=boto3_credentials_info.aws_region_name,\n        )\n        proxy_endpoint_url = proxy_endpoint_url.replace(\"bedrock-runtime\", \"bedrock-agent-runtime\")\n        proxy_endpoint_url = f\"{proxy_endpoint_url}/rerank\"\n        sigv4: Final = SigV4Auth(\n            boto3_credentials_info.credentials,\n            \"bedrock\",\n            boto3_credentials_info.aws_region_name,\n        )\n        # Make POST Request\n        body: Final = json.dumps(data).encode(\"utf-8\")\n","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/rerank/handler.py#L124-L160","documentation":"The Bedrock rerank request preparer needs botocore's SigV4Auth/AWSRequest to sign the request. If botocore (installed with boto3) is not importable, an ImportError is raised: 'Missing boto3 to call bedrock. Run pip install boto3.' Boto3 is an optional dependency for litellm's Bedrock support.","triggerScenarios":"litellm.rerank(model='bedrock/...') (or any path going through _prepare_request) in an environment where boto3/botocore was never installed or was uninstalled by a dependency resolver.","commonSituations":"Slim Docker images that strip boto3; pip dependency conflicts removing botocore; using litellm only for OpenAI previously and adding Bedrock later without installing boto3.","solutions":["pip install boto3","Add boto3 to the project's dependency manifest if any Bedrock route is used.","Verify import: python -c \"from botocore.auth import SigV4Auth\".","Check pip check for broken dependency resolution that dropped botocore."],"exampleFix":"# before: ImportError on litellm.rerank(model='bedrock/...')\npip install litellm\n\n# after\npip install litellm boto3","handlingStrategy":"try-catch","validationCode":"def boto3_available() -> bool:\n    try:\n        from botocore.auth import SigV4Auth  # noqa: F401\n        return True\n    except ImportError:\n        return False","typeGuard":"def can_prepare_bedrock_request() -> bool:\n    return boto3_available()","tryCatchPattern":"try:\n    litellm.rerank(model=\"bedrock/...\", query=q, documents=docs)\nexcept ImportError as e:\n    if \"boto3\" in str(e):\n        raise SetupError(\"pip install boto3\") from e\n    raise","preventionTips":["Install boto3 wherever any Bedrock provider is used, not just S3 workloads.","Add a startup import probe for botocore in Bedrock-enabled deployments.","Run 'pip check' in CI to catch resolvers that drop botocore."],"tags":["bedrock","rerank","import-error","boto3","installation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}