A chat model that uses the Bedrock API.
Bedrock chat model integration built on the Bedrock converse API.
This implementation will eventually replace the existing ChatBedrock implementation once the Bedrock converse API has feature parity with older Bedrock API. Specifically the converse API does not yet support custom Bedrock models.
Anthropic Claude via AWS Bedrock.
Uses the AnthropicBedrock clients in the anthropic SDK.
See the LangChain docs for ChatAnthropic
for tutorials, feature walkthroughs, and examples.
See the Claude Platform docs for a list of the latest models, their capabilities, and pricing.
Chat model for Amazon Nova Sonic bidirectional streaming.
This provides a LangChain integration for Amazon Nova Sonic's
bidirectional streaming API (InvokeModelWithBidirectionalStream).
Nova Sonic enables real-time speech-to-speech conversations over a
persistent, full-duplex streaming connection. Unlike the Converse API
used by :class:ChatBedrockConverse, this maintains a persistent
full-duplex connection for continuous audio streaming.
This integration requires the aws-sdk-bedrock-runtime package
which is under active development. Install with:
pip install "langchain-aws[nova-sonic]"
For simple text interactions, use :meth:ainvoke or :meth:astream.
For full audio streaming, use :meth:create_session to get a
:class:NovaSonicSession.
Quick start::
import asyncio
from langchain_aws.chat_models.bedrock_nova_sonic import ChatBedrockNovaSonic
model = ChatBedrockNovaSonic(
model_id="amazon.nova-sonic-v1:0",
region_name="us-east-1",
)
# Text-only conversation
response = asyncio.run(
model.ainvoke("Hello, how are you?")
)
print(response.content)
Audio streaming::
import asyncio
from langchain_aws.chat_models.bedrock_nova_sonic import (
ChatBedrockNovaSonic,
NovaSonicSession,
)
async def stream_audio():
model = ChatBedrockNovaSonic(
model_id="amazon.nova-sonic-v1:0",
region_name="us-east-1",
voice_id="matthew",
)
async with model.create_session() as session:
# Send audio chunks
await session.send_audio_chunk(audio_bytes)
# Receive responses
async for event in session.receive_events():
if event["type"] == "audio":
play(event["audio"])
elif event["type"] == "text":
print(event["text"])
asyncio.run(stream_audio())
Amazon Nova Sonic bidirectional streaming chat model.
Anthropic Bedrock chat models.
Sagemaker Chat Model.