AGENT SKILL

openrouter-routing-rules

Define custom routing rules for OpenRouter requests. Use when implementing complex routing logic beyond simple model selection. Trigger with phrases like 'openrouter rules', 'routing rules', 'custom routing', 'openrouter request routing'.

License 许可
MIT
最近更新
2026-05-26
Stars
★ 0
Forks
0

01 前言 Front Matter

name
openrouter-routing-rules
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Define custom routing rules for OpenRouter requests. Use when implementing complex routing logic beyond simple model selection. Trigger with phrases like 'openrouter rules', 'routing rules', 'custom routing', 'openrouter request routing'.
allowed-tools
Read, Write, Edit, Grep
compatible-with
claude-code, codex, openclaw

02 资源文件 7

03 SKILL.md 正文

Openrouter Routing Rules

Overview

This skill shows how to implement rule-based routing that dynamically selects models based on prompt content, user tier, cost constraints, or time-of-day patterns.

Prerequisites

  • OpenRouter integration with multiple models configured
  • Routing requirements defined (by user tier, task type, cost, etc.)

Instructions

  1. Define routing dimensions: Identify the factors that should influence model selection — user tier (free/paid), task type (chat/code/analysis), cost budget, latency requirement
  2. Build a rules engine: Create a configuration-driven rules engine where each rule has conditions (e.g., user.tier == "free") and actions (e.g., model = "google/gemma-2-9b-it:free")
  3. Implement rule evaluation: Process rules in priority order; the first matching rule determines the model; always include a default/catch-all rule
  4. Add dynamic rules: Support rules that query real-time data (current cost, model availability, error rates) to make routing decisions
  5. Test with rule scenarios: Write test cases for each rule to verify correct model selection under different conditions

Output

  • A configurable rules engine that selects models based on multiple dimensions
  • Rule configuration file (JSON/YAML) that can be updated without code changes
  • Test suite validating each routing rule produces the correct model selection

Error Handling

Error Cause Fix
No rule matched Conditions don't cover all cases Always include a default catch-all rule at the end
Rule evaluation error Dynamic rule query failed (e.g., cost API timeout) Add fallback values for dynamic data; never block on rule evaluation
Wrong model selected Rule priority order incorrect Add logging to show which rule matched and why; review priority ordering

See ${CLAUDE_SKILL_DIR}/references/errors.md for full error reference.

Examples

See ${CLAUDE_SKILL_DIR}/references/examples.md for runnable code samples.

Resources

04 同仓库更多 Skills

SamuelChien
SamuelChien/mega-skills-collection

zustand-store-ts

Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zustand-store-creator

Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zero-trust-config-helper

Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zapier-integration-helper

Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zai-cli

Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

yt-research

Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.

★ 0