The Docs says open router can be used with init_chat_model but throws an error

Hi, the docs directly say we can use Open Router inside init_chat_model by model_provider="openrouter"
However, when I do, I get an error that doesn’t include the open router. How do I get the init chat model to use the open router? The error I get is

ValueError: Unsupported model_provider='openrouter'.

Supported model providers are: bedrock_converse, groq, xai, google_genai, openai, huggingface, google_anthropic_vertex, azure_openai, upstage, perplexity, together, deepseek, anthropic, bedrock, fireworks, azure_ai, ibm, ollama, google_vertexai, mistralai, cohere

Yet, the docs clearly states i can use open router with init model, heres the part of the docs that says that

import os
from langchain.chat_models import init_chat_model

os.environ["OPENROUTER_API_KEY"] = "sk-..."

model = init_chat_model(
    "auto",
    model_provider="openrouter",
)
response = model.invoke("Why do parrots talk?")

How do i resolve this

The error comes from the legacy langchain package (pre-1.0). init_chat_model there has a fixed _SUPPORTED_PROVIDERS set that doesn’t include openrouter — that’s why the provider list in the error stops at the older integrations.

OpenRouter support in init_chat_model lives in langchain v1, which dispatches to the langchain-openrouter partner package. Two ways to fix:

1. Upgrade and install the partner package

pip install -U "langchain>=1" langchain-openrouter

Your original snippet then works unchanged:

import os
from langchain.chat_models import init_chat_model

os.environ["OPENROUTER_API_KEY"] = "sk-..."

model = init_chat_model("auto", model_provider="openrouter")
print(model.invoke("Why do parrots talk?"))

2. Or skip init_chat_model and instantiate directly

from langchain_openrouter import ChatOpenRouter

model = ChatOpenRouter(model="auto")

Quick check of what you have installed:

python -c "import langchain; print(langchain.__version__)"

If it prints 0.x, that’s the mismatch with the v1 docs.