npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

model-selection-optimizer

v1.0.2

Published

Smart model routing extension for OpenClaw — dynamically selects the best AI model per conversation turn

Readme

Smart Model Router for OpenClaw

A plugin for OpenClaw that automatically picks the best AI model for each conversation turn. Instead of manually switching between models, the router analyzes your prompt and routes it to the right model based on what you're asking.

What it does

  • Coding questions go to Claude Sonnet 4.6 (strong at code generation and debugging)
  • Deep reasoning tasks go to Gemini 2.5 Pro (strong at analysis and multi-step logic)
  • Simple questions go to Gemini 2.5 Flash (fast, cheap, good enough for quick answers)
  • Creative writing goes to Claude Sonnet 4.6 (strong at prose, emails, blog posts)

The routing happens automatically on every turn. You can also force a specific route with slash commands like /coding, /reason, /simple, /creative, /action, /best, or /cheap.

How routing works

Every prompt goes through two possible paths:

  1. Fast path — A semantic classifier compares your prompt against known examples (coding questions, simple questions, reasoning tasks, etc.). If it's confident about the match, it routes directly to the model mapped to that class.

  2. Scoring path — If the classifier isn't confident, a scoring engine evaluates all available models using five strategies: capability match, complexity-tier fit, cost optimization, latency, and context window size. The highest-scoring model wins.

Both paths are config-driven. You control which models are available, which classes exist, and how the scoring weights work.

Quick start

git clone https://github.com/alexspin/Model-Selection-Optimizer.git
cd Model-Selection-Optimizer
npm install
npm run build

Then point your OpenClaw config at the plugin. See INSTALL.md for the full step-by-step setup including API keys, gateway config, and verification.

Slash commands

| Command | Routes to | Use for | |---------|-----------|---------| | /simple | Gemini 2.5 Flash | Quick facts, casual chat, follow-ups | | /cheap | Gemini 2.5 Flash | Alias for /simple | | /coding | Claude Sonnet 4.6 | Writing code, debugging, code review | | /creative | Claude Sonnet 4.6 | Blog posts, emails, translation | | /action | Claude Sonnet 4.6 | Tool calls, file operations | | /reason | Gemini 2.5 Pro | Deep analysis, architecture, trade-offs | | /best | Gemini 2.5 Pro | Alias for /reason |

Type a bare command (e.g., /best) to see help. Type with a message (e.g., /coding write a function to reverse a string) to route that message.

Project structure

src/
  plugin/           Plugin entry point, bridge, hooks
    index.ts         register() — commands, hooks, session state
    bridge.ts        SmartRouterBridge — classification, scoring, model resolution
  analyzers/         Prompt analysis (semantic classifier + regex fallback)
  scoring/           5-strategy scoring engine
  models/            Model registry (profiles, tiers, quality scores)
  config/            Routing config and example files
    routing.json     Commands → classes → models mapping
    examples/        Training examples for each class (coding.json, simple.json, etc.)
  types/             TypeScript type definitions

Configuration

All config lives in two places:

  • src/config/routing.json — Maps commands to classes and classes to models. This is where you change which model handles what.
  • src/models/registry.ts — Defines every model the router knows about: tier, capabilities, quality scores, pricing, latency.

To add a new model or change routing, see the "Adding a new model" section in INSTALL.md.

Plugin behavior (thresholds, logging, fallback model, strategy weights) is configured in your openclaw.json under plugins.entries.smart-router.config. See INSTALL.md for the full options table.

Requirements

  • Node.js 20+
  • OpenClaw 2026.3.x
  • At least one LLM provider API key (Anthropic and/or Google recommended)

License

MIT