1 / 14

Run AI agents
cheap, local, verified.

The open-source layer that meters every model call, routes the cheap/local model first, and escalates only when a real check requires it.

Sardor Razikov · Apache-2.0 · runs offline

frugal-cost-router.netlify.app  ·  github.com/SRKRZ23/frugal

The problem

Agents burn frontier tokens on trivial work.

Every token has a price, and agentic workloads send the bill soaring. Most calls don't need the biggest model — but nothing decides that for you, and nothing proves the cheap answer was good enough.

The solution

Meter → route → verify → cache.

Meter

Know the exact $/token of every call. Thread-safe hard budget cap.

Route

Cheap/local model first; escalate only when confidence is low.

Verify

Offline eval asserts + an LLM judge gate quality in CI.

Cache

A repeat or near-repeat prompt costs $0 — the second lever.

How it works

Escalate only when the cheap answer isn't trustworthy.

cheap / local confidence check escalate (only if needed)

Confidence is pluggable — a near-free logprob signal, a one-call verifier, or self-consistency. And Frugal warns you when a pair is too close in price to bother.

Measured, not asserted

A 3B model matched a 14B on most tasks.

83%
of hard tasks the 3B matched the 14B (100% of easy)
4.7–11×
faster on the cheap tier (CPU → GPU)
~17%
of hard prompts escalate — what routing catches

LLM-judged, on a rented node. Reproduce with one command.

Real prices · July 2026

What it saves.

Cheap → frontierConfidenceSaved
GPT-4o-mini → GPT-4o (16×)logprob (free)90.6%
Local ($0) → GPT-4oany88–97%
Claude Haiku → Sonnet (3×)self-consistency−7%

Live on a rented node: vs a plain proxy (all→strong), Frugal made half the strong-model calls — −53.9% cost, −32.5% latency on the same prompts.

~75–97% typical — the −7% row is honest: it can lose money.

For the enterprise · 2026

The token-tax is real money now.

Who's burning itThe 2026 fact
MetaAI capex $125–145B; ~$25B/qtr on inference silicon
Amazon~$200B AI capex; Bedrock hosts Anthropic + Grok
GoogleGemini serves 1.3 quadrillion tokens / month
MicrosoftGitHub Copilot → token-metered billing ("meter shock")
xAIAnthropic pays $1.25B/mo for Colossus; >1M calls/day
PalantirCEO: token pricing "broken" → air-gapped, no hosted API
SalesforceAgentforce moved to resolution-based pricing
UberBurned its whole 2026 AI-coding budget by April
KlarnaAI assistant: 2.3M conversations / month
Fortune-500 firm$500M on Claude in a single month, no caps
IndustryInference = 85% of the AI budget; spend still doubling

Token prices fell ~280× in two years, yet total spend rose ~320% — agentic volume exploded. Cheaper tokens don't save you; routing what doesn't need the big model does.

What Frugal saves, by spend

From $100k to $50M/mo — and the cases it's built for.

Monthly inference spendFrugal saves / year
$100,000$0.6–0.9M
$1,000,000$6–9M
$10,000,000$60–90M
$50,000,000 (F-500 tier)$300–450M
Uber pattern

Hard budget cap + reserve() → budget can't be blown silently; routing stretches it 2–4×.

Palantir / air-gapped

Local-first routing keeps private work on your GPUs (0 leaks); escalate only when truly needed.

Klarna-scale support

2.3M chats/mo → cheap tier for simple turns; ~$210k/yr modeled saving on that volume alone.

Modeled at published 2026 API prices and a conservative routable share; your mix determines the result. Reproduce: python benchmarks/cost_model.py. Not affiliated with any company named.

Where it does not pay off

The tool tells you when to say no.

Cascade + a re-sampling check loses money when the cheap tier isn't much cheaper. The rule: cascade only at a ≥ ~10× price gap, or use a free logprob signal, or a local tier. Frugal computes this and warns you — we publish where it doesn't work, not just where it does.

Who benefits

If you pay for tokens, this is for you.

Indie & startups

Cut 75–97% of inference spend; hard budget caps per tenant.

Enterprises

Private prompts stay on-prem (0 leaks); audit every $/token.

Agent builders

Agents that self-throttle: trivial steps cheap, hard ones escalate.

Researchers

Reproducible model-vs-model evals with an LLM judge on your cluster.

Platform / DevOps

OpenAI-compatible budget gateway + MCP cost telemetry.

Vibecoders

One command, no keys, cheap by default.

One package · nine parts

Everything reads one shared cost meter.

frugal.meter

cost, budget, zero-overshoot reserve

frugal.route

cascade + logprob/verifier confidence

frugal.cache

$0 on repeat prompts

frugal.local

local↔cloud, 0 private leaks

frugal.eval

asserts, drift, LLM judge

frugal.rag

retrieval / faithfulness checks

frugal.mcp

agent reads its own spend

frugal.gateway

OpenAI-compatible, streaming

frugal.economics

won't-save warning

Stress-tested, not just shipped

Boring where infra should be boring.

56
tests · stress + deep + property-fuzz + FastAPI-concurrency suites
7 bugs
found & fixed by our own tests (thread-safety, O(n²) meter, unicode, broken HTTP layer)
2 µs
routing + metering overhead per call · 0 runtime deps
Roadmap

Honest about what's next.

Shipped

logprob confidence · response cache · streaming gateway · economics guard · zero-overshoot budget.

Next

broader human-graded evals · live LiteLLM/Portkey bake-off · more provider adapters · a persistent metrics store.

Get involved

Use it. Back it. Build on it.

Frugal and REPOMIND are one on-prem, cost-efficient-inference thesis, built in the open. I'm open to the backing that scales it:

Angel investment

Fund compute, evals, and full-time work on the stack.

Non-refundable grants

Research / OSS / hardware grants — no equity, no repayment.

Hardware sponsorship

GPU / accelerator access (AMD ROCm-first) for public benchmarks.

Acquisition / acquihire

Team + IP — the Wang / Suleyman / Shazeer pattern. I'd bring Frugal + REPOMIND.

Sardor Razikov — independent AI/ML engineer, Tashkent
← → to navigate