OP

openrouter-multi-provider

Manage and switch between OpenAI, Anthropic, Google, and other models using OpenRouter's unified API.

Install

mkdir -p .claude/skills/openrouter-multi-provider && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5501" && unzip -o skill.zip -d .claude/skills/openrouter-multi-provider && rm skill.zip

Installs to .claude/skills/openrouter-multi-provider

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Use multiple AI providers (OpenAI, Anthropic, Google, Meta) through
67 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Compare model performance across providers
  • Normalize model access via unified API
  • Configure provider-specific routing
  • Implement BYOK provider keys
  • Benchmark latency and token usage

How it works

This skill utilizes OpenRouter's unified API to route requests to various providers like OpenAI, Anthropic, and Google. It includes benchmarking scripts to measure performance and routing configurations to control provider selection.

Inputs & outputs

You give it
Prompt and list of model IDs
You get back
Comparison scoreboard of latency, tokens, and status

When to use openrouter-multi-provider

  • Comparing performance between different LLMs
  • Building provider-agnostic AI infrastructure
  • Switching between providers during outages
  • Managing BYOK provider keys

About this skill

OpenRouter Multi-Provider

Overview

OpenRouter's unified API lets you access models from OpenAI, Anthropic, Google, Meta, Mistral, and others with a single API key and endpoint. Model IDs use provider/model-name format. The same OpenAI SDK code works for any provider by simply changing the model ID. This skill covers provider comparison, cross-provider routing, feature normalization, and BYOK (Bring Your Own Key).

Prerequisites

  • A single OpenRouter API key exported as OPENROUTER_API_KEY — it covers every provider (OpenAI, Anthropic, Google, Meta, Mistral); see the openrouter-install-auth skill for setup
  • curl and jq for the provider-landscape query
  • Python 3.8+ with the OpenAI SDK (pip install openai)
  • For BYOK only: your own provider API key (e.g. an OpenAI key) added in the OpenRouter dashboard under Settings > Integrations > Add Provider Key

Instructions

  1. Survey what's on offer per Provider Landscape: curl -s https://openrouter.ai/api/v1/models | jq ... groups model IDs by their provider/ prefix and sorts by model count.
  2. Benchmark candidates with compare_models() from Cross-Provider Comparison — the same prompt at temperature=0 across Anthropic, OpenAI, Google, and Meta, capturing latency, tokens, and the actual serving endpoint (response.model).
  3. Shortlist by task using the Provider Strength Matrix — Anthropic for analysis/long context, OpenAI for code and tool calling, Google for multimodal and 1M context, Meta for budget work, Mistral for European data residency.
  4. Pin or fail over per Provider-Specific Routing: provider.order with allow_fallbacks: False forces one provider (e.g. for regulated data); allow_fallbacks: True fails across providers such as Anthropic → AWS Bedrock.
  5. For high-volume production, configure BYOK — requests route to your own provider key with the first 1M requests/month free, then 5% of normal provider cost.
  6. Smooth capability gaps with normalized_completion() per Feature Normalization — JSON mode uses response_format natively on openai/ models and a system-prompt instruction elsewhere.

Provider Landscape

# List all providers and their model counts
curl -s https://openrouter.ai/api/v1/models | jq '
  [.data[].id | split("/")[0]] |
  group_by(.) | map({provider: .[0], models: length}) |
  sort_by(-.models)'

Cross-Provider Comparison

import os, time, json
from openai import OpenAI

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key=os.environ["OPENROUTER_API_KEY"],
    default_headers={"HTTP-Referer": "https://my-app.com", "X-Title": "my-app"},
)

def compare_models(prompt: str, models: list[str], max_tokens: int = 500) -> list[dict]:
    """Run the same prompt across multiple models and compare results."""
    results = []
    for model in models:
        start = time.monotonic()
        try:
            response = client.chat.completions.create(
                model=model,
                messages=[{"role": "user", "content": prompt}],
                max_tokens=max_tokens,
                temperature=0,
            )
            latency = (time.monotonic() - start) * 1000
            results.append({
                "model": model,
                "served_by": response.model,
                "content": response.choices[0].message.content[:200] + "...",
                "tokens": response.usage.prompt_tokens + response.usage.completion_tokens,
                "latency_ms": round(latency, 1),
                "status": "ok",
            })
        except Exception as e:
            results.append({"model": model, "status": "error", "error": str(e)})

    return results

# Compare top-tier models on the same task
results = compare_models(
    "Explain the CAP theorem in distributed systems",
    models=[
        "anthropic/claude-3.5-sonnet",   # Anthropic
        "openai/gpt-4o",                 # OpenAI
        "google/gemini-2.0-flash-001",   # Google
        "meta-llama/llama-3.1-70b-instruct",  # Meta (open-source)
    ],
)
for r in results:
    print(f"{r['model']}: {r.get('latency_ms', 'N/A')}ms, {r.get('tokens', 'N/A')} tokens")

Provider Strength Matrix

ProviderBest ForExample ModelsPrice Range
AnthropicAnalysis, safety, long contextclaude-3.5-sonnet, claude-3-haiku$0.25-$15/1M
OpenAICode generation, tool callinggpt-4o, gpt-4o-mini, o1$0.15-$60/1M
GoogleMultimodal, huge context (1M)gemini-2.0-flash-001, gemini-pro$0.075-$7/1M
MetaBudget tasks, self-hostingllama-3.1-8b-instruct, llama-3.1-70b-instruct$0.06-$0.90/1M
MistralEuropean data residency, codemistral-large, mixtral-8x7b$0.24-$8/1M

Provider-Specific Routing

# Force specific provider for a model
response = client.chat.completions.create(
    model="anthropic/claude-3.5-sonnet",
    messages=[{"role": "user", "content": "Hello"}],
    max_tokens=200,
    extra_body={
        "provider": {
            "order": ["Anthropic"],        # Direct to Anthropic
            "allow_fallbacks": False,       # Don't fall back to other providers
        },
    },
)

# Cross-provider fallback: if Anthropic is down, try via AWS Bedrock
response = client.chat.completions.create(
    model="anthropic/claude-3.5-sonnet",
    messages=[{"role": "user", "content": "Hello"}],
    max_tokens=200,
    extra_body={
        "provider": {
            "order": ["Anthropic", "AWS Bedrock"],
            "allow_fallbacks": True,
        },
    },
)

BYOK (Bring Your Own Key)

# Use your own provider API key through OpenRouter
# Configure BYOK in the OpenRouter dashboard:
# Settings > Integrations > Add Provider Key

# Benefits:
# - First 1M requests/month free via OpenRouter
# - After that, 5% of normal provider cost (vs full OpenRouter markup)
# - Data flows directly to provider under your account
# - Useful for high-volume production workloads

# With BYOK configured, requests automatically use your provider key
response = client.chat.completions.create(
    model="openai/gpt-4o",  # Uses YOUR OpenAI key, routed through OpenRouter
    messages=[{"role": "user", "content": "Hello"}],
    max_tokens=200,
)

Feature Normalization

def normalized_completion(messages, model, **kwargs):
    """Handle provider-specific feature differences."""
    # JSON mode: OpenAI native, others via system prompt
    if kwargs.pop("json_mode", False):
        if model.startswith("openai/"):
            kwargs["response_format"] = {"type": "json_object"}
        else:
            # Add JSON instruction to system prompt for non-OpenAI models
            messages = [{"role": "system", "content": "Respond in valid JSON only."}] + [
                m for m in messages if m["role"] != "system"
            ] + [m for m in messages if m["role"] == "system"]

    return client.chat.completions.create(model=model, messages=messages, **kwargs)

Output

  • Comparison result rows per model: served_by (the endpoint that actually answered), truncated content, token totals, latency_ms, and status (ok or the error)
  • A provider census from the jq query: {provider, models} objects sorted by model count, showing which namespaces dominate the catalog
  • Completions attributed to their exact serving provider via response.model — the raw material for cost/quality attribution across providers

Examples

One prompt — "Explain what an API gateway is in 2 sentences." — fanned across four providers through the same client produces a directly comparable scoreboard:

[OpenAI] 450ms, 65 tokens — ok
[Anthropic] 380ms, 58 tokens — ok
[Google] 620ms, 71 tokens — ok
[Meta] 510ms, 63 tokens — ok

Anthropic answered fastest with the fewest tokens on this run; the point is that switching providers cost zero code changes beyond the model ID. More worked examples: references/examples.md.

Error Handling

ErrorCauseFix
Feature not supportedProvider lacks capability (e.g., tools on Llama)Check model capabilities via /models; use fallback
Different response qualityProviders trained differentlyTest critical prompts per model; adjust system prompts
Provider outageSingle provider downUse provider.order with fallbacks across providers
BYOK auth failureProvider key expired or invalidUpdate provider key in OpenRouter dashboard

Enterprise Considerations

  • OpenRouter normalizes the API, but models differ in output quality, feature support, and data policies
  • Use provider.order + allow_fallbacks: true for cross-provider resilience
  • Test the same prompts across providers during evaluation; don't assume equal quality
  • BYOK eliminates OpenRouter margin for high-volume workloads (5% vs standard markup)
  • Route regulated data only to approved providers using allow_fallbacks: false
  • Monitor which provider actually serves each request (response.model) for attribution

References

When not to use it

  • When ignoring provider-specific data policies
  • When failing to test prompts across different models

Prerequisites

OpenRouter API keycurljqPython 3.8+

Limitations

  • Models differ in feature support
  • Output quality varies by provider

How it compares

It enables cross-provider benchmarking and routing without requiring separate SDKs or authentication for each provider.

Compared to similar skills

openrouter-multi-provider side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
openrouter-multi-provider (this skill)126dCautionIntermediate
mcp-builder1363moReviewAdvanced
mcp-integration218moReviewIntermediate
opencode-orchestrator-creator89moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

mcp-integration

anthropics

This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context Protocol", "connect external service", mentions "${CLAUDE_PLUGIN_ROOT} with MCP", or discusses MCP server types (SSE, stdio, HTTP, WebSocket). Provides comprehensive guidance for integrating Model Context Protocol servers into Claude Code plugins for external tool and service integration.

21123

opencode-orchestrator-creator

IgorWarzocha

Creates universal OpenCode orchestrator folder structure with specialized agent that can manage swarm servers via curl commands

8104

claude-opus-4-5-migration

anthropics

Migrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5. Use when the user wants to update their codebase, prompts, or API calls to use Opus 4.5. Handles model string updates and prompt adjustments for known Opus 4.5 behavioral differences. Does NOT migrate Haiku 4.5.

9101

mcp-management

mrgoonie

Manage Model Context Protocol (MCP) servers - discover, analyze, and execute tools/prompts/resources from configured MCP servers. Use when working with MCP integrations, need to discover available MCP capabilities, filter MCP tools for specific tasks, execute MCP tools programmatically, access MCP prompts/resources, or implement MCP client functionality. Supports intelligent tool selection, multi-server management, and context-efficient capability discovery.

6100

n8n-mcp-orchestrator

manutej

Expert MCP (Model Context Protocol) orchestration with n8n workflow automation. Master bidirectional MCP integration, expose n8n workflows as AI agent tools, consume MCP servers in workflows, build agentic systems, orchestrate multi-agent workflows, and create production-ready AI-powered automation pipelines with Claude Code integration.

795

Search skills

Search the agent skills registry