langchain-openrouter integration allows you to use these models in your LangChain applications.
Installation
Install thelangchain-openrouter package:
Setup
Get an API key from OpenRouter and set it as an environment variable:Basic Usage
Available Models
OpenRouter provides access to many models. Popular options include:openai/gpt-4o- OpenAI GPT-4oopenai/gpt-4o-mini- OpenAI GPT-4o Mini (cost-effective)anthropic/claude-sonnet-4-5- Anthropic Claude Sonnet 4.5anthropic/claude-opus-4- Anthropic Claude Opus 4google/gemini-2.0-flash-exp- Google Gemini 2.0 Flashmeta-llama/llama-3.3-70b-instruct- Meta Llama 3.3 70Bopenai/o3-mini- OpenAI O3 Mini (reasoning model)