Skip to content

The agent engineering platform.

feat(langchain): support Bedrock Mantle chat models in `init_chat_model` (#40837)

ccurme80b74090515a
diff --git a/libs/langchain_v1/langchain/chat_models/base.py b/libs/langchain_v1/langchain/chat_models/base.py
index c90ba58e20..8be8923b50 100644
--- a/libs/langchain_v1/langchain/chat_models/base.py
+++ b/libs/langchain_v1/langchain/chat_models/base.py
@@ -61,6 +61,8 @@ _BUILTIN_PROVIDERS: dict[str, tuple[str, str, Callable[..., BaseChatModel]]] = {
"baseten": ("langchain_baseten", "ChatBaseten", _call),
"bedrock": ("langchain_aws", "ChatBedrock", _call),
"bedrock_converse": ("langchain_aws", "ChatBedrockConverse", _call),
+ "bedrock_mantle_anthropic": ("langchain_aws", "ChatAnthropicMantle", _call),
+ "bedrock_mantle_openai": ("langchain_aws", "ChatOpenAIMantle", _call),
"cohere": ("langchain_cohere", "ChatCohere", _call),
"deepseek": ("langchain_deepseek", "ChatDeepSeek", _call),
"fireworks": ("langchain_fireworks", "ChatFireworks", _call),
@@ -310,6 +312,8 @@ def init_chat_model(
- `anthropic_bedrock` -> [`langchain-aws`](https://docs.langchain.com/oss/python/integrations/providers/aws)
- `bedrock` -> [`langchain-aws`](https://docs.langchain.com/oss/python/integrations/providers/aws)
- `bedrock_converse` -> [`langchain-aws`](https://docs.langchain.com/oss/python/integrations/providers/aws)
+ - `bedrock_mantle_openai` -> [`langchain-aws[openai]`](https://docs.langchain.com/oss/python/integrations/providers/aws) — install with `pip install "langchain-aws[openai]"`
+ - `bedrock_mantle_anthropic` -> [`langchain-aws[anthropic]`](https://docs.langchain.com/oss/python/integrations/providers/aws) — install with `pip install "langchain-aws[anthropic]"`
- `cohere` -> [`langchain-cohere`](https://docs.langchain.com/oss/python/integrations/providers/cohere)
- `fireworks` -> [`langchain-fireworks`](https://docs.langchain.com/oss/python/integrations/providers/fireworks)
- `together` -> [`langchain-together`](https://docs.langchain.com/oss/python/integrations/providers/together)
diff --git a/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py b/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py
index 8b13d1340c..d6e4e8e837 100644
--- a/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py
+++ b/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py
@@ -155,6 +155,18 @@ def test_supported_providers_is_sorted() -> None:
assert list(_BUILTIN_PROVIDERS) == sorted(_BUILTIN_PROVIDERS.keys())
+def test_bedrock_mantle_providers_registered() -> None:
+ """Mantle providers map to the `langchain_aws` Mantle chat model classes."""
+ assert _BUILTIN_PROVIDERS["bedrock_mantle_openai"][:2] == (
+ "langchain_aws",
+ "ChatOpenAIMantle",
+ )
+ assert _BUILTIN_PROVIDERS["bedrock_mantle_anthropic"][:2] == (
+ "langchain_aws",
+ "ChatAnthropicMantle",
+ )
+
+
@pytest.mark.parametrize(
("model_name", "expected_provider"),
[
diff --git a/libs/langchain_v1/uv.lock b/libs/langchain_v1/uv.lock
index 9986832e77..ecc45755f5 100644
--- a/libs/langchain_v1/uv.lock
+++ b/libs/langchain_v1/uv.lock
@@ -2442,7 +2442,7 @@ typing = [
[[package]]
name = "langchain-anthropic"
-version = "1.7.2"
+version = "1.7.4"
source = { editable = "../partners/anthropic" }
dependencies = [
{ name = "anthropic" },
@@ -2581,7 +2581,7 @@ wheels = [
[[package]]
name = "langchain-core"
-version = "1.6.3"
+version = "1.6.5"
source = { editable = "../core" }
dependencies = [
{ name = "httpx" },
@@ -2785,7 +2785,7 @@ wheels = [
[[package]]
name = "langchain-openai"
-version = "1.6.2"
+version = "1.6.6"
source = { editable = "../partners/openai" }
dependencies = [
{ name = "certifi" },
@@ -2796,11 +2796,14 @@ dependencies = [
[package.metadata]
requires-dist = [
+ { name = "aiohttp", marker = "extra == 'azure-identity'", specifier = ">=3.11.0,<4.0.0" },
+ { name = "azure-identity", marker = "extra == 'azure-identity'", specifier = ">=1.25.0,<2.0.0" },
{ name = "certifi", specifier = ">=2024.6.2" },
{ name = "langchain-core", editable = "../core" },
{ name = "openai", specifier = ">=2.45.0,<4.0.0" },
{ name = "tiktoken", specifier = ">=0.7.0,<1.0.0" },
]
+provides-extras = ["azure-identity"]
[package.metadata.requires-dev]
dev = []