AI cost control JavaScript

right-size-modelFind the cheapest LLM that is good enough for each task, with a statistical test

right-size-model runs your own test cases on several LLMs through any OpenAI-compatible API, grades the answers and uses a paired non-inferiority test to tell you which cheaper model you can switch to per task, with the monthly cost, energy and CO2 you save.

npx npx right-size-model run --config models.json --items eval.jsonl

Free · MIT license · runs on your machine · no signup npm ↗GitHub ↗

Why this matters now

Most teams send every request to their most expensive model because nobody has measured whether a cheaper one passes. That gap is usually the largest single saving in an AI bill.

How right-size-model works

Most AI features run on one big model because it was the safe choice on day one. A lot of that work, such as classifying reviews, routing support messages or pulling attributes out of product descriptions, can be done just as well by a model that costs a fraction and uses far less energy.

right-size-model runs your own examples through your current model and the cheaper ones you want to try, grades the answers automatically, and compares them item by item. For each task it tells you to switch, keep, or test more, with a proper confidence interval instead of a gut feeling, and shows the cost, energy and CO2 you would save each month.

Try it

npx right-size-model run --config models.json --items eval.jsonl --results results.jsonl --prices prices.json

Free and open source under the MIT license. Want your AI costs and footprint cut without losing quality? Book a call.

Agent skill included

Let your AI coding agent run right-size-model for you

The right-size-model skill works with Claude Code, Codex, Cursor, Gemini CLI and other agents that read SKILL.md files. It runs the tool, explains each finding in plain words and helps you fix it.

npx skills add MuhammadAhmadZia/right-size-model --skill right-size-model

Using the Claude or ChatGPT apps instead? Download the skill ZIP from the GitHub releases page and upload it under Skills.

See all 30 agent skills →

Questions about right-size-model

How is this different from a public leaderboard?

Leaderboards test general skills on someone else's questions. This tests your tasks, with your prompts and your expected answers, and tells you per feature whether a cheaper model is good enough.

How many examples do I need?

It depends on how often the models disagree. Around 100 to 600 per task is typical for a 5-point margin. The plan command works it out, and the report says when a result is still unsure.

Which models can I test?

Anything with an OpenAI-compatible API: OpenAI, Anthropic, Gemini, Mistral, OpenRouter, Groq, Together, DeepSeek, and local models through Ollama, vLLM or LM Studio.

What does good enough mean?

You choose the largest drop in pass rate you accept, for example 5 points. A model is good enough when the 95% confidence interval of its difference from your current model stays above that drop.

UN Sustainable Development Goals

How each tool maps to SDG targets →

Want this set up and tuned for your store?

The tools are free. If you would rather have the checks run, the findings fixed and the results measured for you, that is what I do for clients.