Connectto OpenRouter MCP Server

Seamlessly integrate your LangChain and AI applications with OpenRouter using Klavis AI's comprehensive MCP server connection guide.

OpenRouter icon

OpenRouter

featured

Access to multiple AI models through a unified API. Generate chat completions, compare model performance, manage usage and costs, get model recommendations, and analyze model capabilities across various providers like OpenAI, Anthropic, Meta, Google, and more

Available Tools:

  • openrouter_list_models
  • openrouter_search_models
  • openrouter_get_model_pricing
  • +11 more tools

Quick Setup Guide

Follow these steps to connect LangChain to this MCP server

1

Create Your Account

Sign up for KlavisAI to access our MCP server management platform.

2

Configure Connections

Add the MCP server to LangChain and configure authentication settings.

3

Test & Deploy

Verify your connections work correctly and start using your enhanced AI capabilities.

LangChain + KlavisAI Integration Snippets

import os
import asyncio
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI

# Initialize clients
klavis_client = Klavis(api_key=os.getenv("KLAVIS_API_KEY"))
llm = ChatOpenAI(model="gpt-4o-mini", api_key=os.getenv("OPENAI_API_KEY"))

openrouter_mcp_instance = klavis_client.mcp_server.create_server_instance(
    server_name=McpServerName.OPENROUTER,
    user_id="1234",
    platform_name="Klavis",
    connection_type=ConnectionType.STREAMABLE_HTTP,
)

mcp_client = MultiServerMCPClient({
    "openrouter": {
        "transport": "streamable_http",
        "url": openrouter_mcp_instance.server_url
    }
})

tools = asyncio.run(mcp_client.get_tools())

agent = create_react_agent(
    model=llm,
    tools=tools,
)

response = asyncio.run(agent.ainvoke({
    "messages": [{"role": "user", "content": "Your query here"}]
}))

Frequently Asked Questions

Everything you need to know about connecting to this MCP server

Ready to Get Started?

Join developers who are already using KlavisAI to power their LangChain applications with this MCP server.

Start For Free