For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
  • Overview
    • Quickstart
    • Principles
    • Models
    • Stripe Projects
    • FAQ
    • Report Feedback
  • Models & Routing
    • Model Fallbacks
    • Provider Selection
    • Auto Exacto
    • Private Models
  • Features
    • Workspaces
    • Presets
    • Response Caching
    • Tool Calling
    • Structured Outputs
    • Message Transforms
    • Zero Completion Insurance
    • ZDR
    • App Attribution
    • Service Tiers
    • Sovereign AI
    • Router Metadata
    • Input & Output Logging
      • For Providers
      • Frameworks and Integrations Overview
      • Awesome OpenRouter
      • Effect AI SDK
      • Arize
      • LangChain
      • LiveKit
      • Langfuse
      • Mastra
      • OpenAI SDK
      • Anthropic Agent SDK
      • PydanticAI
      • Replit
      • TanStack AI
      • Vercel AI SDK
      • Xcode
      • Zapier
      • Infisical
LogoLogo
ModelsChatRankingsDocs
On this page
  • Using LangChain
Community

LangChain

Using OpenRouter with LangChain
Was this page helpful?
Previous

LiveKit

Using OpenRouter with LiveKit Agents
Next
Built with

Using LangChain

LangChain provides a standard interface for working with chat models. You can use OpenRouter with LangChain using the dedicated ChatOpenRouter integration packages. For more details on LangChain’s model interface, see the LangChain Models documentation.

Resources:

  • LangChain Python integration: langchain-openrouter on PyPI
  • LangChain JavaScript integration: @langchain/openrouter on npm
1import { ChatOpenRouter } from "@langchain/openrouter";
2
3const model = new ChatOpenRouter(
4 "anthropic/claude-sonnet-4.6",
5 { temperature: 0.8 }
6);
7
8// Example usage
9const response = await model.invoke([
10 { role: "system", content: "You are a helpful assistant." },
11 { role: "user", content: "Hello, how are you?" },
12]);

For full documentation — including streaming, tool calling, structured output, reasoning, multimodal inputs, provider routing, and more — see the LangChain integration guides:

  • Python: ChatOpenRouter
  • JavaScript: ChatOpenRouter