← Back to Insights
ORIGINAL

ModelSpend — Route to the Cheapest Suitable LLM, Then Show the Receipt

We open-sourced ModelSpend: tag LLM spend by project and agent, hard budgets before the call, and model="auto" routing to the lowest-cost model expected to fit. Your keys. Apache-2.0. Beta.

ModelSpend cover: forest-green ledger background with a mint-to-amber cost bar and a tagged agent spend line

Agents are burning tokens you cannot attribute. One Cursor session, three models, two retries, an escalation you never asked for — and the invoice is still one line item with no project name on it.

We open-sourced ModelSpend for that.

Landing: /modelspend · Repo: github.com/rmencke2/modelspend · Release: v0.3.0b1

Two jobs

  1. Know where the money goes. Tag any call with project, agent, optional run_id, and up to eight labels — SDK args, CLI flags, env, or OpenAI-compatible headers (X-ModelSpend-Project, -Agent, -Run, -Labels). Report tokens by type (input, cached, output, reasoning), cost, and overhead from failed calls, retries, and escalations. Pin a model if you only want measurement.
  2. Spend less. Route each task to the lowest-cost model expected to fit, inside a USD or token budget. Hard budgets refuse before the provider call (HTTP 429). Soft budgets only warn.

Your keys for OpenAI, Anthropic, Google, and xAI. No prompts stored. Apache-2.0. Local OpenAI-compatible server — point the agent at model="auto".

Why this sits next to Influzer

Influzer is the MCP directory: search, handshake, paste, allowlist. That stack answers which tool server the agent may call.

ModelSpend answers the next bill: which model paid for the reasoning, under which project, and whether the next call is allowed to leave the machine. Same team. Different socket. Both refuse to pretend a demo is a control plane.

Drop it in front of any OpenAI client

from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8787/v1", api_key="unused-unless-token-set")
r = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Classify: refund me as billing|bug|other"}],
    extra_body={
        "modelspend": {
            "providers": ["anthropic", "openai"],
            "max_budget_usd": 0.01,
            "profile": "economy",
        }
    },
)
print(r.choices[0].message.content, r.model_extra["modelspend"]["explanation"])

Tag from the CLI the same way:

modelspend route "Classify: I was charged twice" \
  --providers anthropic --project billing --agent invoice-bot
modelspend report --by project,agent,model --since 7d
modelspend budget set --project shop --period monthly --usd 50

Five minutes with no keys

Clone, install editable, print the policy, preview on the synthetic catalog (no call, no spend):

git clone https://github.com/rmencke2/modelspend.git
cd modelspend
python3 -m venv .venv && source .venv/bin/activate
python -m pip install --upgrade pip && pip install -e .
modelspend policy
modelspend preview "Classify this ticket" --catalog synthetic --assume-keys

Full setup, pricing sync, and limitations live in the repo README and on /modelspend.

Honest status (beta)

ModelSpend does not guarantee the cheapest successful model. “Suitable” is an estimate from catalog tier priors and, as you run evaluations, measured evidence.

We would rather ship that disclaimer than a fake “always cheapest” badge.

Quick answers

Do I have to route to use it?

No. Pin a model (--model provider/id or a non-auto model on the server) and ModelSpend only measures.

Where do budgets apply?

Before every provider call — including retries, failovers, escalations, classifier/judge calls, and streams. Hard = refuse with 429. Soft = warn.

Is this an MCP server?

No. It is a local cost router and usage ledger in front of LLM providers. Influzer MCP Discovery stays the read-only catalog search path.

Windows / Gemini / xAI?

Open an issue. That feedback is the product right now.

Final thought

Directories tell you which tool server to allowlist. ModelSpend tells you which model paid for the turn — and whether the next turn is allowed to leave.

Tag the project. Cap the budget. Route model="auto". Star the repo if agents should know their bill.

Start at /modelspend. Clone github.com/rmencke2/modelspend. Keep writes — and spend — on a list you can name.

GET PRACTICAL AI PLAYBOOKS WEEKLY

One clear email each Thursday

Actionable frameworks on AI execution, agents, and MCP. Join 4,200+ builders.

✓ You're in — first briefing Thursday.

Leave a comment

Be the first to share your thoughts.

Related insights

2026-10-07
Search, Handshake, Paste — An Agent Skill for the Influzer MCP Catalog
Discovery can search. Probe can handshake. Snippets can paste. We shipped the SKILL.md that teaches agents that loop — and we still will not call it a safe-to-install badge.
2026-10-02
ACP vs MCP — The Editor Layer Is Not the Tool Layer
Agent Client Protocol is how Zed and JetBrains host a coding agent. MCP is how that agent reaches tools. They share JSON-RPC. They do not share an allowlist. Spell the words before you pick a winner.
2026-10-02
MCP Apps Are Not WebMCP
SEP-1865 puts a sandboxed widget inside Claude and ChatGPT. WebMCP puts tools on the live page. Classic MCP is still just JSON. Pick the surface before Toronto sells you all three as one demo.