Skip to content

The agent engineering platform.

feat: add support for IBM WatsonX AI chat models (#29688)

Jawahar S994c5465e08a
diff --git a/libs/langchain/langchain/chat_models/base.py b/libs/langchain/langchain/chat_models/base.py
index 8799f627e0..1a2ead9904 100644
--- a/libs/langchain/langchain/chat_models/base.py
+++ b/libs/langchain/langchain/chat_models/base.py
@@ -118,6 +118,7 @@ def init_chat_model(
- 'ollama' -> langchain-ollama
- 'google_anthropic_vertex' -> langchain-google-vertexai
- 'deepseek' -> langchain-deepseek
+ - 'ibm' -> langchain-ibm
- 'nvidia' -> langchain-nvidia-ai-endpoints
Will attempt to infer model_provider from model if not specified. The
@@ -428,6 +429,11 @@ def _init_chat_model_helper(
from langchain_nvidia_ai_endpoints import ChatNVIDIA
return ChatNVIDIA(model=model, **kwargs)
+ elif model_provider == "ibm":
+ _check_pkg("langchain_ibm")
+ from langchain_ibm import ChatWatsonx
+
+ return ChatWatsonx(model_id=model, **kwargs)
else:
supported = ", ".join(_SUPPORTED_PROVIDERS)
raise ValueError(
@@ -453,6 +459,7 @@ _SUPPORTED_PROVIDERS = {
"bedrock_converse",
"google_anthropic_vertex",
"deepseek",
+ "ibm",
}