openrouter-model-routing
Skill by jeremylongshore
Implements model routing on OpenRouter to balance cost, quality and latency. It is for developers building multi-model systems or trying to cut spend across task types.
Install openrouter-model-routing
Built from the published package, never by AI.
git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.claude/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-model-routing ~/.claude/skills/openrouter-model-routingRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install openrouter-model-routing in Claude Code
git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-model-routing ~/.gemini/antigravity-cli/skills/openrouter-model-routingAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install openrouter-model-routing in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill shows how to route LLM requests on OpenRouter to different models based on task type, prompt complexity, cost and latency. It provides a Python task-based router with a tier table (free, budget, mid, standard, premium), a complexity-based auto-router that scores word count, code, reasoning and math markers, and examples of OpenRouter's native fallback and provider routing. It also includes a cost-aware helper that fetches live per-1M-token pricing from the models endpoint.
The skill is aimed at developers building multi-model systems or optimizing spend across different task types. It expects an OpenRouter API key, Python with the OpenAI SDK and requests, and a rough inventory of the task mix. It recommends logging each routing decision and capping cost with max_tokens.
Written from the project's SKILL.md and checked against it.
What it can do
- route_request()Routes a request to a model tier chosen from the task type and returns content, model, tier and token count.
- classify_complexity()Scores prompt word count, code, reasoning and math markers to pick a model tier.
- auto_route()Selects a model from the latest user message's complexity and sends the chat completion.
- Fallback routingUses extra_body models with route set to fallback to try models in order until one succeeds.
- Provider routingSets provider order and allow_fallbacks to control which provider serves a model.
- :floor model variantAppends :floor to a model ID to pick the cheapest provider automatically.
- get_model_pricing()Fetches current per-1M-token prompt and completion prices and context length from the models endpoint.
- cheapest_model_for_task()Picks the cheapest paid model that meets a minimum context length.
What you need
- OpenRouter API key exported as OPENROUTER_API_KEY
- Python 3.8 or later
- OpenAI SDK and requests Python packages
- Credits sized for the model tiers used
Try asking
- Route this code review request to a standard-tier model using my task router
- Use auto_route to pick a model for this prompt based on its complexity
- Show me the cheapest OpenRouter model with at least 8k context
Good to know
- classify_complexity uses simple heuristics and should be replaced with a trained classifier for production
- cheapest_model_for_task excludes free models because the source calls them unreliable
- Model names and prices shown in the code comments are examples and may change; get_model_pricing fetches live rates
- Quality regressions must be monitored; the source suggests escalating tiers on poor results
Security check
B- Allowed to use Write, Edit without limitsIn
SKILL.md
Checked automatically: skills/.curated/openrouter-model-routing/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
Allowed tools: ReadWriteEditGrepBash(python3:*)
Alternatives to openrouter-model-routing
All alternatives →Aligns a Qwen Code feature with a Codex or Claude Code reference agent. It runs both under the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.
Searches, views, creates, updates, and deletes the user's Google Contacts from an AI assistant. It is for people who want to manage their address book through conversation. A one-time Google connect is required before it returns data.
Guides an AI assistant on error handling choices. It covers when to use Result, Option, ? propagation, unwrap, expect and panic, plus anyhow and thiserror.
Caveman is an agent skill that makes an AI assistant reply in a terse style. It cuts filler and keeps technical facts, code, commands and errors exact. It is built for users who want shorter, cheaper replies.
docs-sync audits or updates English SDK documentation against the requested implementation scope. It is for maintainers who want docs to match main branch features, configuration options, and defaults.
Guides an AI assistant through setting up and running monorepos with pnpm workspaces, Turborepo and Nx. Aimed at developers who need faster builds, shared code and managed dependencies across multiple packages.
Compare with agent-reproduce-align, google_contacts or m06-error-handling
openrouter-model-routing: common questions
What does the complexity-based router look at?
It counts words and checks for code, reasoning keywords such as explain or compare, and math keywords such as calculate or proof. Those signals choose a tier from premium down to budget.
How does it keep costs under control?
The source recommends setting max_tokens on every request and daily budget caps. It also suggests logging each routing decision to tune the routing table.
Does it handle model outages?
It suggests adding a fallback chain per tier. OpenRouter's fallback route option tries a list of models in order until one succeeds.
How do I install openrouter-model-routing?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is openrouter-model-routing free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is openrouter-model-routing safe to use?
It scores 76 of 100. Grades: maintenance A, licence A, quality A. Security check: grade B (allowed to use write, edit without limits). Review the code before you install. How grades work.
What are alternatives to openrouter-model-routing?
Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.
