openrouter-routing-rules
Installation
SKILL.md
OpenRouter Routing Rules
Overview
Beyond simple task-based model selection, production systems need configurable routing rules that consider user tier, cost budget, time of day, model availability, and feature requirements. This skill covers building a rules engine for OpenRouter model selection with config-driven rules, dynamic conditions, and override capabilities.
Prerequisites
- An OpenRouter API key (
sk-or-v1-...) exported asOPENROUTER_API_KEY— see theopenrouter-install-authskill for setup - Python 3.8+ with the OpenAI SDK — the rules engine itself is stdlib (
dataclasses,json,random) layered on top - Per-request metadata available in your app: user tier, task type, remaining budget, tool/vision needs, latency SLA (the
RoutingContextfields) - Budget tracking wired up (see
openrouter-cost-controls) if you use budget-conditioned rules likelow-budget