Install & Compatibility
Where this runs
tested against v1.7.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 3.356s · 175.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 11.8s · import 3.112s · 179MB
179MB installed
● package 179MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ChatBedrock
✓ from langchain_aws.chat_models import ChatBedrock
✗ from langchain.chat_models import Bedrock
As of LangChain 0.1.0 (and subsequent versions), AWS integrations moved to `langchain-aws`.
BedrockLLM
✓ from langchain_aws.llms import BedrockLLM
✗ from langchain.llms import Bedrock
Old Bedrock LLM class was directly in `langchain` before the package split.
BedrockEmbeddings
✓ from langchain_aws.embeddings import BedrockEmbeddings
✗ from langchain.embeddings import BedrockEmbeddings
Embeddings integrations for AWS are now part of `langchain-aws`.
This quickstart demonstrates how to initialize `ChatBedrock` and use it to invoke a large language model. It requires the `AWS_REGION_NAME` environment variable to be set, and valid AWS credentials configured for `boto3` to access Amazon Bedrock.
import os
from langchain_aws.chat_models import ChatBedrock
from langchain_core.messages import HumanMessage
# Ensure AWS_REGION_NAME environment variable is set
# and AWS credentials are configured (e.g., via ~/.aws/credentials or env vars)
region = os.environ.get("AWS_REGION_NAME", "us-east-1")
model_id = "anthropic.claude-3-sonnet-20240229-v1:0" # Example Bedrock model ID
try:
llm = ChatBedrock(
model_id=model_id,
region_name=region
)
messages = [
HumanMessage(
content="Tell me a short story about a brave knight and a wise dragon."
)
]
print(f"Invoking {model_id} in {region}...")
response = llm.invoke(messages)
print("\n--- Response ---")
print(response.content)
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure AWS_REGION_NAME is set and AWS credentials are configured.")
print("Example: export AWS_REGION_NAME=us-east-1")
print("See https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html")
Debug
Known issues
breakingThe `langchain-aws` library was split from the main `langchain` package in late 2023 / early 2024. All AWS-specific integrations (e.g., Bedrock, SageMaker) now reside in `langchain-aws` and require explicit installation and updated import paths.fixMigrate import paths from `from langchain.<module> import <Class>` to `from langchain_aws.<module> import <Class>`. For example, `from langchain.llms import Bedrock` becomes `from langchain_aws.llms import BedrockLLM`.
affects: All versions of `langchain-aws` (1.x.x) and `langchain` (0.1.0+)
gotchaProper configuration of AWS credentials and region is essential. `langchain-aws` relies on `boto3`'s default credential chain. Misconfiguration can lead to `ClientError` (e.g., 'NotAuthorizedException', 'UnrecognizedClientException').fixEnsure `AWS_REGION_NAME` is set (e.g., as an environment variable or via `~/.aws/config`). Provide credentials via environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`), shared credential files (`~/.aws/credentials`), or IAM roles/profiles. Refer to `boto3` documentation for details.
affects: All versions
gotchaBedrock model IDs are specific and may vary by AWS region or API availability. Using an incorrect or unavailable model ID will result in runtime errors from Bedrock.fixVerify the exact model ID (e.g., `anthropic.claude-3-sonnet-20240229-v1:0`) is available in your specified `region_name`. You can check available models through the AWS Bedrock console or programmatically via `boto3`.
affects: All versions
gotchaLangChain differentiates between chat models (`ChatBedrock`) and text completion models (`BedrockLLM`). Their interfaces and expected input/output formats (e.g., `HumanMessage` for chat, string for LLM) differ. Using the wrong class or input format can cause unexpected behavior or errors.fixUse `ChatBedrock` for models designed for conversational turns (e.g., Claude, Llama 2 Chat) and provide inputs as `list[BaseMessage]`. Use `BedrockLLM` for models primarily designed for text generation from a single prompt string.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'langchain_aws'
With the modularization of LangChain (v0.1.0 and newer), AWS-specific integrations were moved to the `langchain-aws` package, and imports from the top-level `langchain` package for these components are no longer valid.
fixInstall the `langchain-aws` package using `pip install langchain-aws` and update your import statements, for example, changing `from langchain.llms.bedrock import Bedrock` to `from langchain_aws.llms.bedrock import Bedrock`.
AttributeError: 'Bedrock' object has no attribute 'bind_tools'
The `Bedrock` LLM implementation in `langchain-aws` (especially for AWS Bedrock's Converse API) does not natively support the generic `bind_tools` functionality in the same way some other LangChain LLMs do, requiring a different approach for tool integration.
fixInstead of `llm.bind_tools(tools)`, create custom tools that integrate directly with Bedrock's native tool capabilities or leverage LangGraph for workflow management to define tool usage.
Could not load credentials to authenticate with AWS client. Please check that the specified profile name and/or its credentials are valid. Service error: You must specify a region.
This error occurs when the `boto3` client (used by `langchain-aws`) cannot find valid AWS credentials or a region to authenticate with Bedrock, or the configured credentials lack the necessary permissions.
fixEnsure AWS credentials (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`) and the `AWS_REGION` are set as environment variables, or configure `~/.aws/credentials` and `~/.aws/config` files with a valid profile and region. Verify that the IAM user/role has `bedrock:InvokeModel` and other required permissions for the Bedrock service.
ValueError: Error raised by bedrock services: Connection was closed before we recieved a valid response from endpoint URL
This issue typically indicates a network connectivity problem, such as a firewall, proxy, or corporate network restriction preventing the application from reaching the AWS Bedrock service endpoint.
fixCheck your network configuration, firewall rules, and proxy settings to ensure that outbound connections to the AWS Bedrock service endpoint are allowed. If in a corporate environment, consult your network administrator. You can test connectivity using the AWS CLI (e.g., `aws bedrock list-foundation-models`).
Upgrade
Version history
1.7.4latest on PyPI · released Aug 26, 2026
Audit
Dependencies
boto3requiredRequired for interacting with AWS services (e.g., Bedrock, SageMaker).
langchain-corerequiredFundamental base package for LangChain paradigms, messages, and runnables.
langchain-communityrequiredProvides common LangChain integrations; langchain-aws builds upon it.