openrouter-routing-rules

Implement intelligent model routing based on request characteristics. Use when optimizing for cost, speed, or quality per request. Trigger with phrases like 'openrouter routing', 'model selection', 'smart routing', 'dynamic model'.

⭐878stars🔀101forks📁View on GitHub🕐Updated Jan 4, 2026⬇️1downloads

When & Why to Use This Skill

The OpenRouter Routing Rules skill enables intelligent, request-based model selection to optimize AI performance and operational costs. By analyzing specific request characteristics—such as content type, urgency, and complexity—it dynamically routes prompts to the most suitable Large Language Model (LLM) via OpenRouter. This skill is essential for developers looking to balance high-quality outputs with cost-efficiency and low latency in production-grade AI agents.

Use Cases

  • Cost Optimization: Automatically route simple or repetitive queries to lightweight, low-cost models while reserving high-tier models for complex reasoning.
  • Performance Tuning: Direct latency-sensitive tasks to the fastest available models to ensure a responsive user experience.
  • Domain-Specific Routing: Identify coding or technical requests and route them to models with proven benchmarks in software engineering, such as Claude 3.5 Sonnet.
  • Dynamic Resource Management: Implement smart fallbacks and model switching based on real-time requirements for quality, speed, or budget constraints.
nameopenrouter-routing-rules
description|
allowed-toolsRead, Write, Edit, Grep
version1.0.0
licenseMIT
authorJeremy Longshore <jeremy@intentsolutions.io>

OpenRouter Routing Rules

Overview

This skill covers implementing request-based routing logic to select optimal models based on content, urgency, or cost constraints.

Prerequisites

  • OpenRouter integration
  • Understanding of model capabilities and pricing

Instructions

Follow these steps to implement this skill:

  1. Verify Prerequisites: Ensure all prerequisites listed above are met
  2. Review the Implementation: Study the code examples and patterns below
  3. Adapt to Your Environment: Modify configuration values for your setup
  4. Test the Integration: Run the verification steps to confirm functionality
  5. Monitor in Production: Set up appropriate logging and monitoring

Overview

This skill covers implementing request-based routing logic to select optimal models based on content, urgency, or cost constraints.

Prerequisites

  • OpenRouter integration
  • Understanding of model capabilities and pricing

Basic Routing Strategies

Content-Based Routing

def route_by_content(prompt: str) -> str:
    """Route to appropriate model based on content analysis."""
    prompt_lower = prompt.lower()

    # Code-related
    if any(word in prompt_lower for word in ["code", "function", "debug", "python", "javascript"]):
        return "anthropic/claude-3.5-sonnet"

## Detailed Reference

See `{baseDir}/references/implementation.md` for complete implementation guide.