AGENT SKILL

openrouter-model-routing

Implement intelligent model routing strategies with OpenRouter. Use when optimizing cost/quality tradeoffs across models. Trigger with phrases like 'openrouter routing', 'model selection', 'route requests', 'model routing strategy'.

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

01 前言 Front Matter

name
openrouter-model-routing
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Implement intelligent model routing strategies with OpenRouter. Use when optimizing cost/quality tradeoffs across models. Trigger with phrases like 'openrouter routing', 'model selection', 'route requests', 'model routing strategy'.
allowed-tools
Read, Write, Edit, Grep
compatible-with
claude-code, codex, openclaw

02 资源文件 7

03 SKILL.md 正文

Openrouter Model Routing

Overview

This skill teaches you how to build intelligent routing logic that selects the best model based on task complexity, cost constraints, or latency requirements.

Prerequisites

  • OpenRouter integration with multiple models tested
  • Understanding of model capabilities and pricing differences

Instructions

  1. Classify request complexity: Analyze the incoming prompt to determine if it needs a simple, mid-tier, or advanced model (e.g., by token count, keyword patterns, or task type)
  2. Build a routing table: Map task categories to model IDs — e.g., simple Q&A to google/gemma-2-9b-it:free, code generation to anthropic/claude-3.5-sonnet, reasoning to openai/gpt-4-turbo
  3. Implement the router function: Create a function that takes a prompt and returns the appropriate model ID based on your classification logic
  4. Add cost guardrails: Set per-request max_tokens and budget caps to prevent expensive models from exceeding cost limits
  5. Monitor and tune: Log which model handles each request and track quality metrics to adjust routing thresholds over time

Output

  • A routing function that selects models based on task type and constraints
  • Cost savings from using cheaper models for simple tasks
  • Quality metrics per route to validate routing decisions

Error Handling

Error Cause Fix
Wrong model selected Classification logic too simple Add more granular task categories; test with diverse prompts
Model unavailable Selected model is temporarily down Chain to fallback model (see openrouter-fallback-config)
Cost overrun Complex tasks routed to expensive models Set hard max_tokens limits and daily budget caps

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