Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

openrouter-routing-rules

Skill by jeremylongshore

Defines configurable routing rules for choosing OpenRouter models per request. It suits developers who need model selection based on user tier, task type, budget, or availability.

  • Score 76
  • 3k stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install openrouter-routing-rules

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-routing-rules ~/.claude/skills/openrouter-routing-rules

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install openrouter-routing-rules in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

The openrouter-routing-rules skill helps Claude Code build a rules engine for selecting OpenRouter models. Rules can consider user tier, task type, remaining budget, tool and vision needs, and latency SLA. Each rule has a priority, and the first matching rule by ascending priority wins. A priority 99 default rule acts as a catch-all.

Rules can be written as Python conditions or as JSON that is matched with a config helper, so they can be hot-reloaded. A routed_completion helper applies the winning rule's model, fallback chain, and max_tokens, and returns the rule name for auditing. An A/B helper sends a share of traffic to a variant model. The skill is aimed at developers running production apps on OpenRouter. It requires an OpenRouter API key and Python 3.8+ with the OpenAI SDK.

Written from the project's SKILL.md and checked against it.

What it can do

  • RoutingContextModels per-request metadata such as user tier, task type, budget, and latency SLA.
  • evaluate_rulesReturns the first matching routing rule, sorted by ascending priority.
  • routed_completionRuns a chat completion using the winning rule's model, fallbacks, and max_tokens.
  • match_config_ruleMatches a request context against JSON-defined rule conditions.
  • ab_test_routingSends a configurable share of traffic to a variant model for comparison.

What you need

  • OpenRouter API key exported as OPENROUTER_API_KEY
  • Python 3.8+
  • OpenAI Python SDK
  • Budget tracking (openrouter-cost-controls) for budget-based rules

Try asking

  • Set up routing rules so free users get the free Gemma model.
  • Add an A/B test that sends 10% of code requests to GPT-4o.
  • Show which rule and model handled each routed completion.

Good to know

  • Budget-based rules such as low-budget need budget tracking set up separately.
  • Example model names are hardcoded in the code samples.
  • The JSON config matcher only checks exact values and list membership.

Security check

B
  • Allowed to use Write, Edit without limitsIn SKILL.md

Checked automatically: skills/.curated/openrouter-routing-rules/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-routing-rules

All alternatives →

Compare with agent-reproduce-align, google_contacts or m06-error-handling

openrouter-routing-rules: common questions

Does it need budget tracking to work?

Only for budget-conditioned rules such as low-budget. The source points to the openrouter-cost-controls skill for budget tracking.

How does it handle model fallbacks?

routed_completion sends the rule's model and fallbacks as a models list with route set to fallback.

Can routing rules change without a redeploy?

The source says JSON rule configs can be hot-reloaded and suggests storing rules in a config file or database.

How do I install openrouter-routing-rules?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is openrouter-routing-rules free?

The code is published under the MIT licence. The service it connects to may have its own pricing.

Is openrouter-routing-rules 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-routing-rules?

Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.

openrouter-routing-rules Install

Add to stack

Loading.