{"id":1527,"library":"langchain-aws","title":"LangChain AWS Integrations","description":"langchain-aws provides a robust integration layer connecting AWS services like Amazon Bedrock, Amazon SageMaker, and Amazon Comprehend with the LangChain framework. It simplifies access to AWS-powered LLMs, embeddings, and vector stores within LangChain applications. The library is actively maintained with frequent releases, often bi-weekly or monthly, to support new AWS features and LangChain capabilities. The current version is 1.4.3.","status":"active","version":"1.4.3","language":"en","source_language":"en","source_url":"https://github.com/langchain-ai/langchain-aws","tags":["langchain","aws","bedrock","sagemaker","llm","embeddings","cloud"],"install":[{"cmd":"pip install langchain-aws","lang":"bash","label":"Install `langchain-aws`"}],"dependencies":[{"reason":"Required for interacting with AWS services (e.g., Bedrock, SageMaker).","package":"boto3"},{"reason":"Fundamental base package for LangChain paradigms, messages, and runnables.","package":"langchain-core"},{"reason":"Provides common LangChain integrations; langchain-aws builds upon it.","package":"langchain-community"}],"imports":[{"note":"As of LangChain 0.1.0 (and subsequent versions), AWS integrations moved to `langchain-aws`.","wrong":"from langchain.chat_models import Bedrock","symbol":"ChatBedrock","correct":"from langchain_aws.chat_models import ChatBedrock"},{"note":"Old Bedrock LLM class was directly in `langchain` before the package split.","wrong":"from langchain.llms import Bedrock","symbol":"BedrockLLM","correct":"from langchain_aws.llms import BedrockLLM"},{"note":"Embeddings integrations for AWS are now part of `langchain-aws`.","wrong":"from langchain.embeddings import BedrockEmbeddings","symbol":"BedrockEmbeddings","correct":"from langchain_aws.embeddings import BedrockEmbeddings"}],"quickstart":{"code":"import os\nfrom langchain_aws.chat_models import ChatBedrock\nfrom langchain_core.messages import HumanMessage\n\n# Ensure AWS_REGION_NAME environment variable is set\n# and AWS credentials are configured (e.g., via ~/.aws/credentials or env vars)\n\nregion = os.environ.get(\"AWS_REGION_NAME\", \"us-east-1\")\nmodel_id = \"anthropic.claude-3-sonnet-20240229-v1:0\" # Example Bedrock model ID\n\ntry:\n    llm = ChatBedrock(\n        model_id=model_id,\n        region_name=region\n    )\n\n    messages = [\n        HumanMessage(\n            content=\"Tell me a short story about a brave knight and a wise dragon.\"\n        )\n    ]\n\n    print(f\"Invoking {model_id} in {region}...\")\n    response = llm.invoke(messages)\n    print(\"\\n--- Response ---\")\n    print(response.content)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure AWS_REGION_NAME is set and AWS credentials are configured.\")\n    print(\"Example: export AWS_REGION_NAME=us-east-1\")\n    print(\"See https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Migrate 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`.","message":"The `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.","severity":"breaking","affected_versions":"All versions of `langchain-aws` (1.x.x) and `langchain` (0.1.0+)"},{"fix":"Ensure `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.","message":"Proper 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').","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify 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`.","message":"Bedrock 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `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.","message":"LangChain 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}