skillfed

langchain-openrouter

An integration package connecting OpenRouter and LangChain

langchain-openrouter v0.2.8 567.3K downloads/30d#5,968 on PyPI144,266
Permissive license MIT Active released

What it is and what it does

langchain-openrouter is a LangChain integration that bridges your LangChain application to OpenRouter, a unified API for accessing hundreds of AI models from many providers. Instead of managing separate connections to different model providers, you point LangChain to OpenRouter and let it handle routing to the underlying models. The package wraps OpenRouter's API in LangChain's standard model interfaces, so you can swap models or providers by changing a configuration string rather than rewriting application code.

It depends on langchain-core (LangChain's base abstractions) and openrouter (the direct Python client for OpenRouter). The package is in Beta status, actively maintained, and supports Python 3.10 through 3.14. It carries no known security vulnerabilities and uses a permissive MIT license.

Use it for:

  • Build a chatbot that can switch between different AI models (GPT, Claude, Llama, etc.) without changing application logic.
  • Prototype LangChain agents with multiple model providers to compare quality and cost without rewriting integration code.
  • Deploy a production service that routes requests to different models based on availability, cost, or performance tiers via OpenRouter.
  • Evaluate different models on the same task by iterating over model names in a LangChain pipeline.
  • Reduce vendor lock-in by abstracting model selection through a single, provider-agnostic API layer.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Connects LangChain applications to OpenRouter, a unified API gateway for hundreds of AI models across multiple providers, enabling model selection and switching without changing application code.

Yes. This is a straightforward, low-friction integration for LangChain users who want to access OpenRouter's multi-provider model catalog. It has no security vulnerabilities, active maintenance, permissive licensing, and minimal dependencies. Install it if you're building with LangChain and want the flexibility to choose from hundreds of models without rewriting your code.

Install

langchain-openrouter on PyPI

pip

pip install langchain-openrouter

uv

uv add langchain-openrouter

poetry

poetry add langchain-openrouter

Installing langchain-openrouter

Before you install

Low friction: pure Python wheel with only two runtime dependencies (langchain-core and openrouter). Actively maintained with a recent release and no known vulnerabilities.

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.

Quickstart

pip install langchain-openrouter

from langchain_openrouter import ChatOpenRouter

model = ChatOpenRouter(model="openrouter/auto")
response = model.invoke("Hello, world!")

Requires Python 3.10 or later; you must have an OpenRouter API key configured (typically via OPENROUTER_API_KEY environment variable).

Verify before relying

  • Whether the package handles model fallback or error recovery when a requested model is unavailable on OpenRouter.
  • Performance characteristics and latency overhead compared to direct OpenRouter or LangChain calls.
  • Which specific OpenRouter features (routing logic, pricing tiers, rate limiting) are exposed through the LangChain integration.

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0.0,>=3.10.0)
Install friction low — pure-Python wheel
Runtime dependencies 2 — langchain-core, openrouter
Maintenance actively maintained — 0 days since the last release
Last repo commit
First released
Downloads 567,328/month — #5,968 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: langchain_openrouter-0.2.8-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering :: Artificial Intelligence

Tags

langchain openrouter integrationunified ai model api gatewaymulti-provider language model accessopenrouter langchain connectorswitch ai models without code changeshundreds of models single apilangchain model provider abstraction
langchain-integrationmodel-abstractionmulti-provider

More Artificial Intelligence packages