> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-opensw-1781706951-9d0138e.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS (Amazon) integrations

> Integrate with AWS (Amazon) using LangChain Python.

This page covers all LangChain integrations with the [Amazon Web Services (AWS)](https://aws.amazon.com/) platform.

## Chat models

### Bedrock chat

> [Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that offers a choice of
> high-performing foundation models (FMs) from leading AI companies like `AI21 Labs`, `Anthropic`, `Cohere`,
> `Meta`, `Stability AI`, and `Amazon` via a single API, along with a broad set of capabilities you need to
> build generative AI applications with security, privacy, and responsible AI. Using `Amazon Bedrock`,
> you can easily experiment with and evaluate top FMs for your use case, privately customize them with
> your data using techniques such as fine-tuning and `Retrieval Augmented Generation` (`RAG`), and build
> agents that execute tasks using your enterprise systems and data sources. Since `Amazon Bedrock` is
> serverless, you don't have to manage any infrastructure, and you can securely integrate and deploy
> generative AI capabilities into your applications using the AWS services you are already familiar with.

See a [usage example](/oss/python/integrations/chat/bedrock).

```python theme={null}
from langchain_aws import ChatBedrock
```

### Bedrock converse

AWS Bedrock maintains a [Converse API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html)
that provides a unified conversational interface for Bedrock models. This API does not
yet support custom models. You can see a list of all
[models that are supported here](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html).

<Info>
  **We recommend the Converse API for users who do not need to use custom models. It can be accessed using [ChatBedrockConverse](https://reference.langchain.com/python/langchain-aws/chat_models/bedrock_converse/ChatBedrockConverse).**
</Info>

See a [usage example](/oss/python/integrations/chat/bedrock).

```python theme={null}
from langchain_aws import ChatBedrockConverse
```

## LLMs

### Bedrock

See a [usage example](/oss/python/integrations/llms/bedrock).

```python theme={null}
from langchain_aws import BedrockLLM
```

### SageMaker endpoint

> [Amazon SageMaker](https://aws.amazon.com/sagemaker/) is a system that can build, train, and deploy
> machine learning (ML) models with fully managed infrastructure, tools, and workflows.

We use `SageMaker` to host our model and expose it as the `SageMaker Endpoint`.

See a [usage example](/oss/python/integrations/llms/sagemaker).

```python theme={null}
from langchain_aws import SagemakerEndpoint
```

## Embedding models

### Bedrock

See a [usage example](/oss/python/integrations/embeddings/bedrock).

```python theme={null}
from langchain_aws import BedrockEmbeddings
```

## Document loaders

### Amazon DocumentDB vector search

> [Amazon DocumentDB (with MongoDB Compatibility)](https://docs.aws.amazon.com/documentdb/) makes it easy to set up, operate, and scale MongoDB-compatible databases in the cloud.
> With Amazon DocumentDB, you can run the same application code and use the same drivers and tools that you use with MongoDB.
> Vector search for Amazon DocumentDB combines the flexibility and rich querying capability of a JSON-based document database with the power of vector search.

#### Installation and setup

See [detail configuration instructions](/oss/python/integrations/vectorstores/documentdb).

We need to install the `pymongo` python package.

<CodeGroup>
  ```bash pip theme={null}
  pip install pymongo
  ```

  ```bash uv theme={null}
  uv add pymongo
  ```
</CodeGroup>

#### Deploy DocumentDB on AWS

[Amazon DocumentDB (with MongoDB Compatibility)](https://docs.aws.amazon.com/documentdb/) is a fast, reliable, and fully managed database service. Amazon DocumentDB makes it easy to set up, operate, and scale MongoDB-compatible databases in the cloud.

AWS offers services for computing, databases, storage, analytics, and other functionality. For an overview of all AWS services, see [Cloud Computing with Amazon Web Services](https://aws.amazon.com/what-is-aws/).

See a [usage example](/oss/python/integrations/vectorstores/documentdb).

```python theme={null}
from langchain.vectorstores.documentdb import DocumentDBVectorSearch
```

### Amazon MemoryDB

[Amazon MemoryDB](https://aws.amazon.com/memorydb/) is a durable, in-memory database service that delivers ultra-fast performance. MemoryDB is compatible with Redis OSS, a popular open source data store,
enabling you to quickly build applications using the same flexible and friendly Redis OSS APIs, and commands that they already use today.

InMemoryVectorStore class provides a vectorstore to connect with Amazon MemoryDB.

```python theme={null}
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,
        )
```

See a [usage example](/oss/python/integrations/vectorstores/memorydb).

### Valkey

[Valkey](https://valkey.io/) is an open source, high-performance key/value datastore that supports workloads such as caching, message queues, and can act as a primary database. Use ValkeyVectorStore to connect with [Amazon ElastiCache for Valkey](https://aws.amazon.com/elasticache/valkey/) or [Amazon MemoryDB for Valkey](https://aws.amazon.com/memorydb/).

```python theme={null}
from langchain_aws.vectorstores import ValkeyVectorStore
```

See a [usage example](/oss/python/integrations/vectorstores/valkey).

## Retrievers

### Amazon Bedrock (Knowledge bases)

> [Knowledge bases for Amazon Bedrock](https://aws.amazon.com/bedrock/knowledge-bases/) is an
> `Amazon Web Services` (`AWS`) offering which lets you quickly build RAG applications by using your
> private data to customize foundation model response.

We need to install the `langchain-aws` library.

<CodeGroup>
  ```bash pip theme={null}
  pip install langchain-aws
  ```

  ```bash uv theme={null}
  uv add langchain-aws
  ```
</CodeGroup>

See a [usage example](/oss/python/integrations/retrievers/bedrock).

```python theme={null}
from langchain_aws import AmazonKnowledgeBasesRetriever
```

## Tools

### AWS lambda

> [`Amazon AWS Lambda`](https://aws.amazon.com/pm/lambda/) is a serverless computing service provided by
> `Amazon Web Services` (`AWS`). It helps developers to build and run applications and services without
> provisioning or managing servers. This serverless architecture enables you to focus on writing and
> deploying code, while AWS automatically takes care of scaling, patching, and managing the
> infrastructure required to run your applications.

We need to install `boto3` python library.

<CodeGroup>
  ```bash pip theme={null}
  pip install boto3
  ```

  ```bash uv theme={null}
  uv add boto3
  ```
</CodeGroup>

See a [usage example](/oss/python/integrations/tools/awslambda).

### Amazon Bedrock AgentCore Browser

> [Amazon Bedrock AgentCore Browser](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/browser-tool.html)
> enables agents to interact with web pages through a managed Chrome browser for navigation, content extraction, and web automation.

<CodeGroup>
  ```bash pip theme={null}
  pip install langchain-aws bedrock-agentcore playwright beautifulsoup4
  ```

  ```bash uv theme={null}
  uv add langchain-aws bedrock-agentcore playwright beautifulsoup4
  ```
</CodeGroup>

See a [usage example](/oss/python/integrations/tools/bedrock_agentcore_browser).

```python theme={null}
from langchain_aws.tools import create_browser_toolkit

# Create toolkit
toolkit, browser_tools = create_browser_toolkit(region="us-west-2")

# Use with an agent
agent = create_react_agent(model=llm, tools=browser_tools)
result = await agent.ainvoke(
    {"messages": [{"role": "user", "content": "Go to example.com and get the heading"}]},
    config={"configurable": {"thread_id": "session-1"}}
)

# Cleanup when done
await toolkit.cleanup()
```

### Amazon Bedrock AgentCore Code Interpreter

> [Amazon Bedrock AgentCore Code Interpreter](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/code-interpreter-tool.html)
> enables agents to execute Python, JavaScript, and TypeScript code in secure, managed sandbox environments for calculations, data analysis, and visualizations.

<CodeGroup>
  ```bash pip theme={null}
  pip install langchain-aws bedrock-agentcore
  ```

  ```bash uv theme={null}
  uv add langchain-aws bedrock-agentcore
  ```
</CodeGroup>

See a [usage example](/oss/python/integrations/tools/bedrock_agentcore_code_interpreter).

```python theme={null}
from langchain_aws.tools import create_code_interpreter_toolkit

# Create toolkit (async)
toolkit, code_tools = await create_code_interpreter_toolkit(region="us-west-2")

# Use with an agent
agent = create_react_agent(model=llm, tools=code_tools)
result = await agent.ainvoke(
    {"messages": [{"role": "user", "content": "Calculate factorial of 10"}]},
    config={"configurable": {"thread_id": "session-1"}}
)

# Cleanup when done
await toolkit.cleanup()
```

## Sandboxes

<Columns cols={2}>
  <Card title="AgentCoreSandbox" href="/oss/python/integrations/sandboxes/aws" cta="Get started" icon="terminal" arrow>
    Amazon Bedrock AgentCore Code Interpreter sandbox backend for deepagents.
  </Card>
</Columns>

## Graphs

### Amazon neptune

> [Amazon Neptune](https://aws.amazon.com/neptune/)
> is a high-performance graph analytics and serverless database for superior scalability and availability.

For the Cypher and SPARQL integrations below, we need to install the `langchain-aws` library.

<CodeGroup>
  ```bash pip theme={null}
  pip install langchain-aws
  ```

  ```bash uv theme={null}
  uv add langchain-aws
  ```
</CodeGroup>

### Amazon neptune with cypher

See a [usage example](/oss/python/integrations/graphs/amazon_neptune_open_cypher).

```python theme={null}
from langchain_aws.graphs import NeptuneGraph
from langchain_aws.graphs import NeptuneAnalyticsGraph
from langchain_aws.chains import create_neptune_opencypher_qa_chain
```

### Amazon neptune with SPARQL

```python theme={null}
from langchain_aws.graphs import NeptuneRdfGraph
from langchain_aws.chains import create_neptune_sparql_qa_chain
```

## Memory

### Amazon Bedrock AgentCore Memory

> [Amazon Bedrock AgentCore Memory](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/memory.html) provides
> managed persistence for LangGraph agents, enabling conversation history and state management across sessions with automatic scaling and high availability.

<CodeGroup>
  ```bash pip theme={null}
  pip install langgraph-checkpoint-aws
  ```

  ```bash uv theme={null}
  uv add langgraph-checkpoint-aws
  ```
</CodeGroup>

```python theme={null}
from langgraph_checkpoint_aws import AgentCoreMemorySaver

# Create checkpointer
checkpointer = AgentCoreMemorySaver(
    memory_id="your-memory-id",
    region_name="us-west-2"
)

# Use with LangGraph
graph = workflow.compile(checkpointer=checkpointer)

# Invoke with thread_id and actor_id for conversation persistence
config = {
    "configurable": {
        "thread_id": "user-123",
        "actor_id": "my-agent"  # Required for AgentCore
    }
}
result = graph.invoke({"messages": []}, config)
```

Key features:

* Managed infrastructure with no database setup required
* Automatic scaling and high availability
* Multi-agent support via `actor_id` isolation
* Encryption at rest and in transit

### Amazon Bedrock AgentCore Memory Store

> [Amazon Bedrock AgentCore Memory Store](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/memory.html) provides
> long-term memory with semantic search capabilities for LangGraph agents, enabling storage and retrieval of user preferences, facts, and extracted memories across sessions.

```python theme={null}
from langgraph_checkpoint_aws import AgentCoreMemoryStore

# Initialize store for long-term memories
store = AgentCoreMemoryStore(memory_id="your-memory-id", region_name="us-west-2")

# Use in a pre-model hook to save and retrieve memories
def pre_model_hook(state, config, *, store):
    actor_id = config["configurable"]["actor_id"]
    thread_id = config["configurable"]["thread_id"]
    namespace = (actor_id, thread_id)

    # Save a message
    store.put(namespace, str(uuid.uuid4()), {"message": msg})

    # Search for relevant memories
    results = store.search(("preferences", actor_id), query="user preferences", limit=5)
    return {"model_input_messages": state["messages"]}
```

## Chains

### Amazon Comprehend moderation chain

> [Amazon Comprehend](https://aws.amazon.com/comprehend/) is a natural-language processing (NLP) service that
> uses machine learning to uncover valuable insights and connections in text.

We need to install the `boto3` and `nltk` libraries.

<CodeGroup>
  ```bash pip theme={null}
  pip install boto3 nltk
  ```

  ```bash uv theme={null}
  uv add boto3 nltk
  ```
</CodeGroup>

See a [usage example](https://python.langchain.com/v0.1/docs/guides/productionization/safety/amazon_comprehend_chain/).

<Warning>
  The `langchain-experimental` package is no longer maintained. Examples that import from `langchain_experimental` may be outdated or broken. Use with caution.
</Warning>

```python theme={null}
from langchain_experimental.comprehend_moderation import AmazonComprehendModerationChain
```

## Runtime

### Amazon Bedrock AgentCore Runtime

> [Amazon Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agents-tools-runtime.html) provides
> managed, serverless execution for LangGraph agents with built-in observability, automatic scaling, and seamless integration with other AgentCore services.

<CodeGroup>
  ```bash pip theme={null}
  pip install bedrock-agentcore
  ```

  ```bash uv theme={null}
  uv add bedrock-agentcore
  ```
</CodeGroup>

```python theme={null}
from bedrock_agentcore.runtime import BedrockAgentCoreApp

app = BedrockAgentCoreApp()

@app.entrypoint
def agent_invocation(payload, context):
    result = graph.invoke({"messages": [{"role": "user", "content": payload["prompt"]}]})
    return {"result": result["messages"][-1].content}

app.run()
```

Deploy using the AgentCore CLI:

```bash theme={null}
# Configure your agent
agentcore configure

# Deploy to AgentCore Runtime
agentcore launch -e your_agent.py
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/providers/aws.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
