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

@certaworks/agent-cost-router

v0.1.0

Published

Routes LLM calls to the cheapest model capable of handling the task. Saves money automatically.

Downloads

92

Readme

Agent Cost Router

Type: CLI / MCP Server / Local HTTP Dashboard

Value: Routes each agent subtask to the cheapest capable model tier while respecting quality needs and budget caps.

Current Status

Complete as a local CLI / MCP / HTTP dashboard slice. It supports deterministic routing from the built-in catalog, optional OpenRouter model sync, local history, and budget summaries.

Implemented Local Slice

  • Task complexity scorer
  • Routing policy for low, medium, and high complexity work
  • Budget cap and per-run cost estimate
  • CLI dry-run and run commands
  • MCP tools for route, run, list models, sync models, estimate cost, route history, and budget summary
  • Local HTTP API and dashboard
  • Persistent routing history, budget ledger, and savings audit log
  • Static model catalog with optional OpenRouter model sync

Commands

npm install
npm run build
npm test
agent-cost-router route --prompt "Summarize this briefly"
agent-cost-router run --prompt "Summarize this briefly" --provider openrouter
agent-cost-router models list
agent-cost-router models sync
agent-cost-router history list --project demo
agent-cost-router budget summary --project demo --budget-id may
agent-cost-router serve --port 4317

The dashboard is available at http://127.0.0.1:4317/dashboard after agent-cost-router serve.

Local API

The HTTP server binds to 127.0.0.1 by default.

  • GET /health or GET /api/status
  • GET /api/models?tier=&provider=&free_only=
  • POST /api/route
  • POST /api/estimate
  • POST /api/models/sync
  • GET /api/history?project=&budget_id=&limit=
  • GET /api/budget?project=&budget_id=

POST /api/route accepts prompt, provider, budget_mode, max_cost_usd, requires_tools, requires_vision, min_context_window, force_model, force_tier, allow_free, project, budget_id, and record_history.

History Store

Route and run decisions are persisted to ~/.agent-cost-router-history.json by default. Override with AGENT_COST_ROUTER_HISTORY_PATH or AGENT_COST_ROUTER_HISTORY_STORE.

The store records sanitized prompt previews and SHA-256 prompt hashes, not full prompts. It also records source, project, budget id, model, provider, tier, complexity, estimated cost, actual cost when known, savings, and alternatives considered.

Current Guardrails

  • Hard provider, budget, allowed-model, context-window, and forced-model constraints fail closed when no capable model matches.
  • allowFree: false excludes free models instead of only changing sort order.
  • Dry-run and run paths share the same merged static/live model catalog.
  • models list works with the built-in catalog even without OPENROUTER_API_KEY.
  • MCP JSON-RPC envelopes and tool calls are validated. Bad envelopes return -32600; bad tool params return -32602.
  • History stores prompt hashes and truncated previews instead of full prompts.

Current Limits

  • This is a local product, not a hosted multi-user SaaS service.
  • No public npm publication, hosted account system, billing, team workspace, or live checkout is included.
  • Model pricing is only as fresh as the static catalog or the last OpenRouter sync.
  • Actual provider execution requires the relevant API key.
  • The dashboard can route and report history/budgets locally; provider-backed execution still happens through CLI/MCP/SDK.

Verification

Fresh suite verification on 2026-05-28:

  • npm test passed, 28/28 tests.
  • npm run build passed.