Skip to main content
This doc will help you get started with AWS Bedrock chat models. Amazon 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. AWS Bedrock maintains a Converse API which 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.
We recommend the Converse API for users who do not need to use custom models. It can be accessed using ChatBedrockConverse.
Anthropic models on BedrockFor Anthropic models specifically, you can use ChatAnthropicBedrock which extends ChatAnthropic and provides the same API while running on AWS Bedrock. See the ChatAnthropicBedrock section below for details.
For detailed documentation of all Bedrock features and configurations head to the API reference.

Overview

Integration details

ClassPackageSerializableJS supportDownloadsVersion
ChatBedrocklangchain-awsbetaPyPI - DownloadsPyPI - Version
ChatBedrockConverselangchain-awsbetaPyPI - DownloadsPyPI - Version

Model features

The below apply to both ChatBedrock and ChatBedrockConverse.
Tool callingStructured outputImage inputAudio inputVideo inputToken-level streamingNative asyncToken usageLogprobs

Setup

To access Bedrock models you’ll need to create an AWS account, set up the Bedrock API service, get an access key ID and secret key, and install the langchain-aws integration package.

Credentials

Head to the AWS docs to sign up to AWS and setup your credentials. Alternatively, ChatBedrockConverse will read from the following environment variables by default:
You’ll also need to turn on model access for your account, which you can do by following these instructions. To enable automated tracing of your model calls, set your LangSmith API key:

Installation

The LangChain Bedrock integration lives in the langchain-aws package:

Instantiation

Now we can instantiate our model object and generate chat completions:

Invocation

Streaming

Use stream_events to stream tokens directly:

Streaming tool calls and structured output

When using tool calling or structured output with Anthropic models, tool call arguments stream as partial JSON chunks by default. To reduce latency and get more evenly distributed chunks, you can enable Anthropic’s fine-grained tool streaming beta:
Fine-grained tool streaming is supported on Claude 4.5+ models. See the Claude documentation for more details.
When using fine-grained tool streaming, you may receive invalid or partial JSON inputs. Make sure to account for these edge cases in your code.

Extended thinking

This guide focuses on implementing Extended Thinking using AWS Bedrock with LangChain’s ChatBedrockConverse integration.

Supported models

Extended Thinking is available for the following Claude models on AWS Bedrock:
ModelModel ID
Claude Opus 4anthropic.claude-opus-4-20250514-v1:0
Claude Sonnet 4anthropic.claude-sonnet-4-20250514-v1:0
Claude 3.7 Sonnetus.anthropic.claude-3-7-sonnet-20250219-v1:0

How extended thinking works

When extended thinking is turned on, Claude creates thinking content blocks where it outputs its internal reasoning. Claude incorporates insights from this reasoning before crafting a final response. The API response will include thinking content blocks, followed by text content blocks.

Prompt caching

Bedrock supports caching of elements of your prompts, including messages and tools. This allows you to reuse large documents, instructions, few-shot documents, and other data to reduce latency and costs.
Not all models support prompt caching. See Bedrock prompt caching supported models.
For LangChain agents, use BedrockPromptCachingMiddleware to let LangChain optimize stable system prompt and tool content. For direct model calls, use manual cachePoint blocks or invocation-level cache_control, depending on the model and API.
To enable caching on an element of a prompt, mark its associated content block using the cachePoint key. See example below:

Citations

Citations can be generated if they are enabled on input documents. Documents can be specified in Bedrock’s native format or LangChain’s standard types:

ChatAnthropicBedrock

For AWS Bedrock users specifically interested in Anthropic models, langchain-aws provides ChatAnthropicBedrock. This class extends ChatAnthropic and provides the same interface while running on AWS Bedrock infrastructure. This takes advantage of the Anthropic SDK’s Bedrock clients.

Installation

Install langchain-aws with the anthropic extra to get the required dependencies:

Usage

ChatAnthropicBedrock supports the same features and parameters as ChatAnthropic. You can initialize it with AWS-specific parameters:
AWS credentials can also be read from environment variables or discovered automatically by boto3:
For detailed documentation on available parameters and features, refer to the ChatAnthropic integration page.

API reference

For detailed documentation of all ChatBedrock, ChatBedrockConverse, and ChatAnthropicBedrock features and configurations head to the API reference.