> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-change-1791323909-75c753a.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 Mantle

The [AWS Bedrock Mantle API](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-responses-api.html#bedrock-mantle-responses) exposes models through the OpenAI and Anthropic Messages protocols. `ChatOpenAIMantle` and `ChatAnthropicMantle` are the recommended interfaces for accessing these models.

Both classes accept a Bedrock API key via the `bedrock_api_key` parameter or the `AWS_BEARER_TOKEN_BEDROCK` environment variable. When neither is available, both derive short-lived API keys from standard AWS credentials and refresh them transparently.

`ChatOpenAIMantle` inherits from `BaseChatOpenAI`. See the corresponding [Responses API docs](/oss/python/integrations/chat/openai#responses-api) for usage examples and capabilities. Refer to the [AWS Mantle OpenAI-compatible API docs](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-responses-api.html#bedrock-mantle-responses) for supported models.

`ChatAnthropicMantle` inherits from `ChatAnthropic` and targets the Anthropic Messages endpoint on Mantle. See the [`ChatAnthropic`](/oss/python/integrations/chat/anthropic) docs for usage examples and capabilities. Refer to the [AWS Mantle Anthropic API docs](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages.html) for supported models.

```python theme={null}
from langchain_aws import ChatOpenAIMantle, ChatAnthropicMantle

openai_model = ChatOpenAIMantle(
    model="openai.gpt-5.6-luna",
    region_name="us-east-1",
)

anthropic_model = ChatAnthropicMantle(
    model="anthropic.claude-opus-5-5",
    region_name="us-east-1",
)
```

### Bedrock Converse

> [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`, `OpenAI`, `Stability AI`, and `Amazon` via a single API. 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.

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. You can see a list of all
[models that are supported here](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html).

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

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

## Embedding models

### Bedrock

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

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

## Document loaders

### 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/) 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

### 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.agents import create_agent
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_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.agents import create_agent
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_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()
```

### Amazon Bedrock AgentCore Web Search

[Amazon Bedrock AgentCore Web Search](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-target-connector-web-search-tool.html) gives agents current information from the web with a source URL on every result, authenticated with your AWS credentials rather than a search API key.

<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_web_search).

```python theme={null}
from langchain.agents import create_agent
from langchain_aws.tools import create_web_search_toolkit

# Needs a gateway with a web search connector target. The factory is synchronous.
toolkit, tools = create_web_search_toolkit(
    region="us-east-1",
    gateway_id="my-web-search-gateway-abc123",
)

try:
    agent = create_agent(model=llm, tools=tools)
    result = agent.invoke(
        {"messages": [{"role": "user", "content": "What changed in the most recent boto3 release?"}]}
    )
finally:
    toolkit.close()
```

## 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 your agent of choice 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>
