{"id":27902,"library":"langchain-openrouter","title":"LangChain OpenRouter Integration","description":"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.","status":"active","version":"0.2.3","language":"python","source_language":"en","source_url":"https://github.com/langchain-ai/langchain","tags":["langchain","openrouter","llm","chat","integration"],"install":[{"cmd":"pip install langchain-openrouter","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"ChatOpenAI is exported at package level, not from submodule","wrong":"from langchain_openrouter.chat_models import ChatOpenAI","symbol":"ChatOpenAI","correct":"from langchain_openrouter import ChatOpenAI"},{"note":"","wrong":"","symbol":"OpenRouterEmbeddings","correct":"from langchain_openrouter import OpenRouterEmbeddings"}],"quickstart":{"code":"from langchain_openrouter import ChatOpenAI\n\nllm = ChatOpenRouter(model_name=\"openai/gpt-4o-mini\")\nresponse = llm.invoke(\"Hello\")\nprint(response.content)","lang":"python","description":"Initialize the ChatOpenAI model via OpenRouter and invoke it"},"warnings":[{"fix":"Use `openai_api_key='your-key'` when initializing ChatOpenAI.","message":"The parameter name for the API key in `ChatOpenAI` is `openai_api_key`, not `api_key` or `openrouter_api_key`.","severity":"gotcha","affected_versions":"all"},{"fix":"Import `ChatOpenAI` from langchain_openrouter; do not use `ChatOpenRouter` in code.","message":"The 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `model='openai/gpt-4o-mini'` instead of `model_name='openai/gpt-4o-mini'`.","message":"The `model_name` parameter is deprecated in favor of `model`. This applies to the underlying LangChain ChatOpenAI class.","severity":"deprecated","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run `pip install langchain-openrouter` in your Python environment.","cause":"Package not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'langchain_openrouter'"},{"fix":"Set `OPENAI_API_KEY` environment variable or pass `openai_api_key='your-key'` to ChatOpenAI.","cause":"API key not provided or incorrect environment variable name.","error":"OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable"},{"fix":"Pass the `model` parameter: `ChatOpenAI(model='openai/gpt-4o-mini', openai_api_key='...')`.","cause":"The `model` parameter is required but not provided.","error":"ValidationError: 1 validation error for ChatOpenAI\nmodel\n  Field required"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}