We recommend the Converse API for users who do not need to use custom models. It can be accessed using ChatBedrockConverse.
Overview
Integration details
Class | Package | Local | Serializable | JS support | Downloads | Version |
---|---|---|---|---|---|---|
ChatBedrock | langchain-aws | ❌ | beta | ✅ | ||
ChatBedrockConverse | langchain-aws | ❌ | beta | ✅ |
Model features
The below apply to bothChatBedrock
and ChatBedrockConverse
.
Tool calling | Structured output | JSON mode | Image input | Audio input | Video input | Token-level streaming | Native async | Token usage | Logprobs |
---|---|---|---|---|---|---|---|---|---|
✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ | ❌ |
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 thelangchain-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:
Installation
The LangChain Bedrock integration lives in thelangchain-aws
package:
Instantiation
Now we can instantiate our model object and generate chat completions:Invocation
Streaming
Note thatChatBedrockConverse
emits content blocks while streaming:
Extended Thinking
This guide focuses on implementing Extended Thinking using AWS Bedrock with LangChain’sChatBedrockConverse
integration.
Supported Models
Extended Thinking is available for the following Claude models on AWS Bedrock:Model | Model ID |
---|---|
Claude Opus 4 | anthropic.claude-opus-4-20250514-v1:0 |
Claude Sonnet 4 | anthropic.claude-sonnet-4-20250514-v1:0 |
Claude 3.7 Sonnet | us.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 re-use large documents, instructions, few-shot documents, and other data to reduce latency and costs.Not all models support prompt caching. See supported models here.
cachePoint
key. See example below: