Agent skill · marketing growth · jeremylongshore

openrouter-model-routing

Implement intelligent model routing to optimize cost, quality, and latency

Why this skill is useful

Adds executable scripts for intelligent model routing and cost optimization that aren't available in public documentation.

What it needs

Requires python3 installed locally. Requires openrouter account access. About 4k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.

What this skill does

OpenRouter Model Routing Overview OpenRouter gives you access to 100+ models through one API. The key to cost efficiency is routing each request to the right model based on task complexity, required capabilities, cost budget, and latency requirements. This skill covers task-based routing, complexity classification, cost-aware selection, and OpenRouter's native routing features. Prerequisites An OpenRouter API key exported as OPENROUTERAPIKEY — see the openrouter-install-auth skill for setup Python 3.8+ with the OpenAI SDK and requests (pip install openai requests) A rough inventory of your task mix (classification, summarization, code generation, deep reasoning, ...) to seed the TASKROUTING table Credits sized for the tiers you route to — the premium tier (openai/o1) runs $15/$60 per 1M tokens, 250x the budget tier Instructions 1. Define your tiers per Task-Based Router: the MODELS dict (free → budget → mid → standard → premium) and the TASKROUTING map, then send requests through routerequest(), which returns content, the serving model, tier, and token count. 2. When callers can't label tasks, switch to the Complexity-Based Auto-Router — classifycomplexity() scores word count, code, reasoning, and math markers to pick a tier inside autoroute(). 3. Add resilience per OpenRouter Native Routing: extrabody={"models": [...], "route": "fallback"} tries models in order, provider.order controls which provider serves, and the :floor variant picks the cheapest provider automatically. 4. Keep pricing current per Cost-Aware Router — getmodelpricing() pulls live per-1M rates from GET /api/v1/models, and cheapestmodelfortask() selects under context/tooling constraints. 5. Log every routing decision (task type, tier, model, cost) and tune per Error Handling and Enterprise Considerations — escalate the tier on quality regressions and cap per-request cost with maxtokens. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills jeremylongshore/openrouter-model-routing

View the source on GitHub

Browse the @skills marketplace