Registry / llm-agents / langchain-openrouter

langchain-openrouter

JSON →
library0.2.3pypypi✓ verified 80d ago

An integration package connecting OpenRouter API with LangChain, providing a ChatOpenAI-compatible chat model and embeddings. Current version 0.2.3, requires Python >=3.10, <4.0.0. Depends on langchain-core (any version). Release cadence is irregular.

pip install langchain-openrouter
INSTALL
IMPORT
SIG · LANGCHAIN-OPENROUT
L
langchain-openrouter
llm-agentspythonv0.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ChatOpenRouter
from langchain_openrouter import ChatOpenRouter
from langchain_openrouter import ChatOpenAI

Initialize the ChatOpenAI model via OpenRouter and invoke it

from langchain_openrouter import ChatOpenAI llm = ChatOpenRouter(model_name="openai/gpt-4o-mini") response = llm.invoke("Hello") print(response.content)
Debug
Known issues
gotchaThe parameter name for the API key in `ChatOpenAI` is `openai_api_key`, not `api_key` or `openrouter_api_key`.
fix
Use `openai_api_key='your-key'` when initializing ChatOpenAI.
affects: all
gotchaThe package exports the model class under the name `ChatOpenRouter` (alias), but the correct class name is `ChatOpenAI`. Using `ChatOpenRouter` may confuse users looking for the actual class.
fix
Import `ChatOpenAI` from langchain_openrouter; do not use `ChatOpenRouter` in code.
affects: all
deprecatedThe `model_name` parameter is deprecated in favor of `model`. This applies to the underlying LangChain ChatOpenAI class.
fix
Use `model='openai/gpt-4o-mini'` instead of `model_name='openai/gpt-4o-mini'`.
affects: >=0.3.0
Upgrade
Version history
0.2.3latest on PyPI · released May 1, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
langchain-openrouter — pip install langchain-openrouter · libregistry