# langchain-aws
This package contains the LangChain integrations with AWS.
## Installation
```bash
pip install -U langchain-aws
```
All integrations in this package assume that you have the credentials setup to connect with AWS services.
## Authentication
In order to use Amazon Bedrock models, you need to configure AWS credentials. One of the options is to set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. More information can be found [here](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html).
Alternatively, set the `AWS_BEARER_TOKEN_BEDROCK` environment variable locally for API Key authentication. For additional API key details, refer to [docs](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html).
## Chat Models
`ChatBedrock` class exposes chat models from Bedrock.
```python
from langchain_aws import ChatBedrock
llm = ChatBedrock()
llm.invoke("Sing a ballad of LangChain.")
```
## Embeddings
`BedrockEmbeddings` class exposes embeddings from Bedrock.
```python
from langchain_aws import BedrockEmbeddings
embeddings = BedrockEmbeddings()
embeddings.embed_query("What is the meaning of life?")
```
## LLMs
`BedrockLLM` class exposes LLMs from Bedrock.
```python
from langchain_aws import BedrockLLM
llm = BedrockLLM()
llm.invoke("The meaning of life is")
```
## Retrievers
`AmazonKendraRetriever` class provides a retriever to connect with Amazon Kendra.
```python
from langchain_aws import AmazonKendraRetriever
retriever = AmazonKendraRetriever(
index_id="561be2b6d-9804c7e7-f6a0fbb8-5ccd350"
)
retriever.get_relevant_documents(query="What is the meaning of life?")
```
`AmazonKnowledgeBasesRetriever` class provides a retriever to connect with Amazon Knowledge Bases.
```python
from langchain_aws import AmazonKnowledgeBasesRetriever
retriever = AmazonKnowledgeBasesRetriever(
knowledge_base_id="IAPJ4QPUEU",
retrieval_config={"vectorSearchConfiguration": {"numberOfResults": 4}},
)
retriever.get_relevant_documents(query="What is the meaning of life?")
```
## VectorStores
### InMemoryVectorStore
`InMemoryVectorStore` class provides a vectorstore to connect with Amazon MemoryDB.
```python
from langchain_aws.vectorstores.inmemorydb import InMemoryVectorStore
vds = InMemoryVectorStore.from_documents(
chunks,
embeddings,
redis_url="rediss://cluster_endpoint:6379/ssl=True ssl_cert_reqs=none",
vector_schema=vector_schema,
index_name=INDEX_NAME,
)
```
### MemoryDB as Retriever
Here we go over different options for using the vector store as a retriever.
There are three different search methods we can use to do retrieval. By default, it will use semantic similarity.
```python
retriever = vds.as_retriever()
```
### AmazonS3Vectors
`AmazonS3Vectors` class provides a vectorstore to connect with Amazon S3 Vectors.
```python
from langchain_aws.vectorstores.s3_vectors import AmazonS3Vectors
vector_store = AmazonS3Vectors.from_documents(
chunks,
vector_bucket_name=S3_VECTOR_BUCKET_NAME,
index_name=INDEX_NAME,
embeddings,
)
```
### AmazonS3Vectors as Retriever
`AmazonS3VectorsRetriever` class initialized from this AmazonS3Vectors.
```python
retriever = vector_store.as_retriever()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/langchain-ai/langchain-aws",
"name": "langchain-aws",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/21/ed/0ae839d950a29f03357e20e56e503012073b7ad140741b5dd547717d3821/langchain_aws-0.2.33.tar.gz",
"platform": null,
"description": "# langchain-aws\n\nThis package contains the LangChain integrations with AWS.\n\n## Installation\n\n```bash\npip install -U langchain-aws\n```\nAll integrations in this package assume that you have the credentials setup to connect with AWS services.\n\n## Authentication\n\nIn order to use Amazon Bedrock models, you need to configure AWS credentials. One of the options is to set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. More information can be found [here](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html). \nAlternatively, set the `AWS_BEARER_TOKEN_BEDROCK` environment variable locally for API Key authentication. For additional API key details, refer to [docs](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html).\n\n## Chat Models\n\n`ChatBedrock` class exposes chat models from Bedrock.\n\n```python\nfrom langchain_aws import ChatBedrock\n\nllm = ChatBedrock()\nllm.invoke(\"Sing a ballad of LangChain.\")\n```\n\n## Embeddings\n\n`BedrockEmbeddings` class exposes embeddings from Bedrock.\n\n```python\nfrom langchain_aws import BedrockEmbeddings\n\nembeddings = BedrockEmbeddings()\nembeddings.embed_query(\"What is the meaning of life?\")\n```\n\n## LLMs\n`BedrockLLM` class exposes LLMs from Bedrock.\n\n```python\nfrom langchain_aws import BedrockLLM\n\nllm = BedrockLLM()\nllm.invoke(\"The meaning of life is\")\n```\n\n## Retrievers\n`AmazonKendraRetriever` class provides a retriever to connect with Amazon Kendra.\n\n```python\nfrom langchain_aws import AmazonKendraRetriever\n\nretriever = AmazonKendraRetriever(\n index_id=\"561be2b6d-9804c7e7-f6a0fbb8-5ccd350\"\n)\n\nretriever.get_relevant_documents(query=\"What is the meaning of life?\")\n```\n\n`AmazonKnowledgeBasesRetriever` class provides a retriever to connect with Amazon Knowledge Bases.\n\n```python\nfrom langchain_aws import AmazonKnowledgeBasesRetriever\n\nretriever = AmazonKnowledgeBasesRetriever(\n knowledge_base_id=\"IAPJ4QPUEU\",\n retrieval_config={\"vectorSearchConfiguration\": {\"numberOfResults\": 4}},\n)\n\nretriever.get_relevant_documents(query=\"What is the meaning of life?\")\n```\n\n## VectorStores \n\n### InMemoryVectorStore\n\n`InMemoryVectorStore` class provides a vectorstore to connect with Amazon MemoryDB.\n\n```python\nfrom langchain_aws.vectorstores.inmemorydb import InMemoryVectorStore\n\nvds = InMemoryVectorStore.from_documents(\n chunks,\n embeddings,\n redis_url=\"rediss://cluster_endpoint:6379/ssl=True ssl_cert_reqs=none\",\n vector_schema=vector_schema,\n index_name=INDEX_NAME,\n )\n```\n\n### MemoryDB as Retriever\n\nHere we go over different options for using the vector store as a retriever.\n\nThere are three different search methods we can use to do retrieval. By default, it will use semantic similarity.\n\n```python\nretriever = vds.as_retriever()\n```\n\n### AmazonS3Vectors\n\n`AmazonS3Vectors` class provides a vectorstore to connect with Amazon S3 Vectors.\n\n```python\nfrom langchain_aws.vectorstores.s3_vectors import AmazonS3Vectors\n\nvector_store = AmazonS3Vectors.from_documents(\n chunks,\n vector_bucket_name=S3_VECTOR_BUCKET_NAME,\n index_name=INDEX_NAME,\n embeddings,\n )\n```\n\n### AmazonS3Vectors as Retriever\n\n`AmazonS3VectorsRetriever` class initialized from this AmazonS3Vectors.\n\n```python\nretriever = vector_store.as_retriever()\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An integration package connecting AWS and LangChain",
"version": "0.2.33",
"project_urls": {
"Homepage": "https://github.com/langchain-ai/langchain-aws",
"Repository": "https://github.com/langchain-ai/langchain-aws",
"Source Code": "https://github.com/langchain-ai/langchain-aws/tree/main/libs/aws"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "51c0c41e50b5c1c3ddd33218843346b8217cc5312758b67a0a5f232c4a97358c",
"md5": "6bd67a68b50ba45714729d090ef1caef",
"sha256": "92c0b4ddcc5e789b3d61cdf20556aeb75ca5a61e8431356f429227bb2760ca39"
},
"downloads": -1,
"filename": "langchain_aws-0.2.33-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6bd67a68b50ba45714729d090ef1caef",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 143593,
"upload_time": "2025-09-15T21:05:24",
"upload_time_iso_8601": "2025-09-15T21:05:24.764443Z",
"url": "https://files.pythonhosted.org/packages/51/c0/c41e50b5c1c3ddd33218843346b8217cc5312758b67a0a5f232c4a97358c/langchain_aws-0.2.33-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "21ed0ae839d950a29f03357e20e56e503012073b7ad140741b5dd547717d3821",
"md5": "c7b2cdaed6c167cdbd8f96cb882c957f",
"sha256": "5160043fcacaf56f29b38e4ac58f9bee65872d9ab51b893a1cb7b28388c2e685"
},
"downloads": -1,
"filename": "langchain_aws-0.2.33.tar.gz",
"has_sig": false,
"md5_digest": "c7b2cdaed6c167cdbd8f96cb882c957f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 118780,
"upload_time": "2025-09-15T21:05:25",
"upload_time_iso_8601": "2025-09-15T21:05:25.873486Z",
"url": "https://files.pythonhosted.org/packages/21/ed/0ae839d950a29f03357e20e56e503012073b7ad140741b5dd547717d3821/langchain_aws-0.2.33.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-15 21:05:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "langchain-ai",
"github_project": "langchain-aws",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "langchain-aws"
}