{"record":{"id":"5b601cf94feb66de","repo":"huggingface/smolagents","slug":"please-install-bedrock-extra-to-use-amazonbedroc","errorCode":null,"errorMessage":"Please install 'bedrock' extra to use AmazonBedrockServerModel: `pip install 'smolagents[bedrock]'`","messagePattern":"Please install 'bedrock' extra to use AmazonBedrockServerModel: `pip install 'smolagents\\[bedrock\\]'`","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"src/smolagents/models.py","lineNumber":2014,"sourceCode":"        completion_kwargs.pop(\"toolConfig\", None)\n\n        # The Bedrock API does not support the `type` key in requests.\n        # This block of code modifies the object to meet Bedrock's requirements.\n        for message in completion_kwargs.get(\"messages\", []):\n            for content in message.get(\"content\", []):\n                if \"type\" in content:\n                    del content[\"type\"]\n\n        return {\n            \"modelId\": self.model_id,\n            **completion_kwargs,\n        }\n\n    def create_client(self):\n        try:\n            import boto3  # type: ignore\n        except ModuleNotFoundError as e:\n            raise ModuleNotFoundError(\n                \"Please install 'bedrock' extra to use AmazonBedrockServerModel: `pip install 'smolagents[bedrock]'`\"\n            ) from e\n\n        return boto3.client(\"bedrock-runtime\", **self.client_kwargs)\n\n    def generate(\n        self,\n        messages: list[ChatMessage | dict],\n        stop_sequences: list[str] | None = None,\n        response_format: dict[str, str] | None = None,\n        tools_to_call_from: list[Tool] | None = None,\n        **kwargs,\n    ) -> ChatMessage:\n        if response_format is not None:\n            raise ValueError(\"Amazon Bedrock does not support response_format\")\n        completion_kwargs: dict = self._prepare_completion_kwargs(\n            messages=messages,\n            tools_to_call_from=tools_to_call_from,","sourceCodeStart":1996,"sourceCodeEnd":2032,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/models.py#L1996-L2032","documentation":"AmazonBedrockServerModel.create_client imports boto3 to build a bedrock-runtime client; if boto3 is missing, the ModuleNotFoundError is re-raised with instructions to install the `bedrock` extra. The check happens when the model is constructed, since create_client runs from __init__.","triggerScenarios":"Instantiating AmazonBedrockServerModel in an environment where boto3 is not installed — i.e. the base smolagents install without the bedrock extra.","commonSituations":"AWS deployments with slim Lambdas/containers lacking boto3; local venvs created before bedrock support was added; CI environments with cached minimal requirements.","solutions":["Install the extra: `pip install 'smolagents[bedrock]'` (pulls boto3).","Verify in the runtime interpreter: `python -c \"import boto3\"`.","Ensure AWS credentials (env vars, profile, or IAM role) are configured afterward, since boto3.client will need them at request time."],"exampleFix":"# before\npip install smolagents\nmodel = AmazonBedrockServerModel(model_id=\"anthropic.claude-3-sonnet-...\")  # ModuleNotFoundError\n\n# after\npip install 'smolagents[bedrock]'","handlingStrategy":"validation","validationCode":"try:\n    import boto3  # noqa\n    ok = True\nexcept ModuleNotFoundError:\n    ok = False\nassert ok, \"pip install 'smolagents[bedrock]'\"","typeGuard":"null","tryCatchPattern":"try:\n    model = AmazonBedrockServerModel(model_id=mid)\nexcept ModuleNotFoundError as e:\n    print(\"Install the extra:\", e)\n    sys.exit(1)","preventionTips":["Add smolagents[bedrock] to requirements for Bedrock deployments.","Pre-verify boto3 presence and AWS credentials in slim containers/Lambdas."],"tags":["aws","bedrock","boto3","missing-dependency","pip-extra"],"backgroundTag":"missing-optional-dependency","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}