Prerequisites Before you begin, create an account and get your API Key.

Getting started

Connect to OpenRouter to access multiple AI models, compare model performance, and manage usage across different AI providers through AI agents.
1

Install the SDKs (optional)

pip install klavis
2

Create a server instance

from klavis import Klavis
from klavis.types import McpServerName

klavis_client = Klavis(api_key="YOUR_API_KEY")

# Create an OpenRouter MCP server instance
openrouter_server = klavis_client.mcp_server.create_server_instance(
    server_name=McpServerName.OPENROUTER,
    user_id="user123"
)
Response Information: The API returns:
  • serverUrl: The URL for connecting your MCP client to OpenRouter
  • instanceId: Unique identifier for your server instance
  • Note: OpenRouter requires an API key which should be configured after creation
3

Configure authentication

You can get your OpenRouter API key from the OpenRouter website.
# Set the OpenRouter API key for your instance
response = klavis_client.mcp_server.set_instance_auth(
    instance_id=openrouter_server.instance_id,
    auth_data={
        "token": "YOUR_OPENROUTER_API_KEY"
    }
)
🎉 Your OpenRouter MCP Server is ready! You can now use your MCP server URL with any MCP-compatible client to access multiple AI models.

Available Tools

Tool NameDescription
openrouter_list_modelsList available models on OpenRouter
openrouter_search_modelsSearch for models based on query, category, or provider
openrouter_get_model_pricingGet pricing information for a specific model
openrouter_create_chat_completionCreate a chat completion using a selected model
openrouter_create_chat_completion_streamCreate a streaming chat completion
openrouter_create_completionCreate a text completion (legacy completion endpoint)
openrouter_get_usageGet usage statistics for the authenticated user
openrouter_get_user_profileGet the current user’s profile information
openrouter_get_creditsGet the current user’s credit balance
openrouter_get_api_key_infoGet information about the current API key
openrouter_get_cost_estimateEstimate cost for a model given input/output tokens
openrouter_compare_modelsRun the same prompt across multiple models and compare
openrouter_analyze_model_performanceAnalyze one model over multiple prompts
openrouter_get_model_recommendationsGet model recommendations based on use case and constraints
For more details about tool input schema, use the get_tools API.

Next Steps