OpenRouter

by heltonteixeira

61 stars
Not rated
GitHub

About

Unifies access to diverse AI models via OpenRouter, enabling flexible model selection and usage for applications like chatbots and content generation.

Details

Author
heltonteixeira
Repository
heltonteixeira/openrouterai
GitHub stars
61
License
Apache License 2.0
Categories
Cloud Service, AI, API, Developer Tools, Design, Community, Search, Knowledge Base, Communication, Infrastructure, Frontend

- Model Access
- Direct access to all OpenRouter.ai models
- Automatic model validation and capability checking
- Default model configuration support

- Performance Optimization
- Smart model information caching (1-hour expiry)
- Automatic rate limit management
- Exponential backoff for failed requests

- Unified Response Format
- Consistent ToolResult structure for all responses
- Clear error identification with isError flag
- Structured error messages with context

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name OpenRouter
    Command (node, npx, python, etc.) npx
    Arguments
    • Argument 1 @mcpservers/openrouterai
    Environment
    • OPENROUTER_API_KEY your-api-key-here
    • OPENROUTER_MAX_TOKENS 1024
    • OPENROUTER_DEFAULT_MODEL optional-default-model
    • OPENROUTER_PROVIDER_IGNORE openai,anthropic
    • OPENROUTER_PROVIDER_QUANTIZATIONS fp16,int8

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Add to your MCP settings configuration file (cline_mcp_settings.json or claude_desktop_config.json):

{
  "mcpServers": {
    "openrouterai": {
      "command": "npx",
      "args": ["@mcpservers/openrouterai"],
      "env": {
        "OPENROUTER_API_KEY": "your-api-key-here",
        "OPENROUTER_DEFAULT_MODEL": "optional-default-model",
        "OPENROUTER_MAX_TOKENS": "1024",
        "OPENROUTER_PROVIDER_QUANTIZATIONS": "fp16,int8",
        "OPENROUTER_PROVIDER_IGNORE": "openai,anthropic"
      }
    }
  }
}

OPENROUTER_API_KEY: Required. Your OpenRouter API key.
OPENROUTER_DEFAULT_MODEL: Optional. The default model to use if not specified in the request (e.g., openrouter/auto).
OPENROUTER_MAX_TOKENS: Optional. Default maximum number of tokens to generate if max_tokens is not provided in the request.
OPENROUTER_PROVIDER_QUANTIZATIONS: Optional. Comma-separated list of default quantization levels to filter by (e.g., fp16,int8) if provider.quantizations is not provided in the request. (Phase 1)
OPENROUTER_PROVIDER_IGNORE: Optional. Comma-separated list of default provider names to ignore (e.g., mistralai,openai) if provider.ignore is not provided in the request. (Phase 1)
OPENROUTER_PROVIDER_SORT: Optional. Default sort order for providers ("price", "throughput", or "latency"). Overridden by provider.sort argument. (Phase 2)
OPENROUTER_PROVIDER_ORDER: Optional. Default prioritized list of provider IDs (JSON array string, e.g., '["openai/gpt-4o", "anthropic/claude-3-opus"]'). Overridden by provider.order argument. (Phase 2)
OPENROUTER_PROVIDER_REQUIRE_PARAMETERS: Optional. Default boolean (true or false) to only use providers supporting all specified request parameters. Overridden by provider.require_parameters argument. (Phase 2)
OPENROUTER_PROVIDER_DATA_COLLECTION: Optional. Default data collection policy ("allow" or "deny"). Overridden by provider.data_collection argument. (Phase 2)
OPENROUTER_PROVIDER_ALLOW_FALLBACKS: Optional. Default boolean (true or false) to control fallback behavior if preferred providers fail. Overridden by provider.allow_fallbacks argument. (Phase 2)

env

pnpm install

chat_completion

Sends a request to the OpenRouter Chat Completions API. Parameters: model (optional string), messages (required array), temperature (optional number), max_tokens (optional number), provider (optional object with routing configurations).

search_models

Search and filter available models. Parameters: query (optional string), provider (optional string), minContextLength (optional number), capabilities (optional object with functions and vision booleans).

get_model_info

Get detailed information about a specific model. Parameters: model (string, required).

validate_model

Check if a model ID is valid. Parameters: model (string, required).

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "openrouter": {
            "env": {
                "OPENROUTER_API_KEY": "your-api-key-here",
                "OPENROUTER_MAX_TOKENS": "1024",
                "OPENROUTER_DEFAULT_MODEL": "optional-default-model",
                "OPENROUTER_PROVIDER_IGNORE": "openai,anthropic",
                "OPENROUTER_PROVIDER_QUANTIZATIONS": "fp16,int8"
            },
            "args": [
                "@mcpservers/openrouterai"
            ],
            "command": "npx"
        }
    }
}

Linux

{
    "env": {
        "OPENROUTER_API_KEY": "your-api-key-here",
        "OPENROUTER_MAX_TOKENS": "1024",
        "OPENROUTER_DEFAULT_MODEL": "optional-default-model",
        "OPENROUTER_PROVIDER_IGNORE": "openai,anthropic",
        "OPENROUTER_PROVIDER_QUANTIZATIONS": "fp16,int8"
    },
    "args": [
        "@mcpservers/openrouterai"
    ],
    "command": "npx"
}

Macos

{
    "env": {
        "OPENROUTER_API_KEY": "your-api-key-here",
        "OPENROUTER_MAX_TOKENS": "1024",
        "OPENROUTER_DEFAULT_MODEL": "optional-default-model",
        "OPENROUTER_PROVIDER_IGNORE": "openai,anthropic",
        "OPENROUTER_PROVIDER_QUANTIZATIONS": "fp16,int8"
    },
    "args": [
        "@mcpservers/openrouterai"
    ],
    "command": "npx"
}

Windows

{
    "env": {
        "OPENROUTER_API_KEY": "your-api-key-here",
        "OPENROUTER_MAX_TOKENS": "1024",
        "OPENROUTER_DEFAULT_MODEL": "optional-default-model",
        "OPENROUTER_PROVIDER_IGNORE": "openai,anthropic",
        "OPENROUTER_PROVIDER_QUANTIZATIONS": "fp16,int8"
    },
    "args": [
        "/c",
        "npx",
        "@mcpservers/openrouterai"
    ],
    "command": "cmd"
}

OpenRouter MCP Server

MCP Server
Version
TypeScript
License

A Model Context Protocol (MCP) server providing seamless integration with OpenRouter.ai's diverse model ecosystem. Access various AI models through a unified, type-safe interface with built-in caching, rate limiting, and error handling.

<a href="https://glama.ai/mcp/servers/xdnmf8yei0">OpenRouter Server MCP server</a>

Features

- Model Access
- Direct access to all OpenRouter.ai models
- Automatic model validation and capability checking
- Default model configuration support

- Performance Optimization
- Smart model information caching (1-hour expiry)
- Automatic rate limit management
- Exponential backoff for failed requests

- Unified Response Format
- Consistent ToolResult structure for all responses
- Clear error identification with isError flag
- Structured error messages with context

Installation

pnpm install @mcpservers/openrouterai

Configuration

Prerequisites

1. Get your OpenRouter API key from OpenRouter Keys
2. Choose a default model (optional)

Environment Variables

OPENROUTER_API_KEY: Required. Your OpenRouter API key.
OPENROUTER_DEFAULT_MODEL: Optional. The default model to use if not specified in the request (e.g., openrouter/auto).
OPENROUTER_MAX_TOKENS: Optional. Default maximum number of tokens to generate if max_tokens is not provided in the request.
OPENROUTER_PROVIDER_QUANTIZATIONS: Optional. Comma-separated list of default quantization levels to filter by (e.g., fp16,int8) if provider.quantizations is not provided in the request. (Phase 1)
OPENROUTER_PROVIDER_IGNORE: Optional. Comma-separated list of default provider names to ignore (e.g., mistralai,openai) if provider.ignore is not provided in the request. (Phase 1)
OPENROUTER_PROVIDER_SORT: Optional. Default sort order for providers ("price", "throughput", or "latency"). Overridden by provider.sort argument. (Phase 2)
OPENROUTER_PROVIDER_ORDER: Optional. Default prioritized list of provider IDs (JSON array string, e.g., '["openai/gpt-4o", "anthropic/claude-3-opus"]'). Overridden by provider.order argument. (Phase 2)
OPENROUTER_PROVIDER_REQUIRE_PARAMETERS: Optional. Default boolean (true or false) to only use providers supporting all specified request parameters. Overridden by provider.require_parameters argument. (Phase 2)
OPENROUTER_PROVIDER_DATA_COLLECTION: Optional. Default data collection policy ("allow" or "deny"). Overridden by provider.data_collection argument. (Phase 2)
OPENROUTER_PROVIDER_ALLOW_FALLBACKS: Optional. Default boolean (true or false) to control fallback behavior if preferred providers fail. Overridden by provider.allow_fallbacks argument. (Phase 2)

```env

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.