RepoOps
Open the app
06 / Cost

Price your app's LLM calls against the bill

App LLM calls reads the per-call cost stream your application writes into its own repository, slices it by tier, surface, model, day, repository, team, user, tenant and prompt, and keeps apart the saving a rule forecasts and the saving the cost stream later measured.

Last updated

Watch it

30.0 s, captions on. Narration: Microsoft Zira Desktop (provisional voice; an approved narration source is pending).Transcript
Read the narration
  1. 0:00 The model bill rose.
  2. 0:01 Nothing on it says which call did it.
  3. 0:06 A forecast is not a saving.
  4. 0:08 RepoOps measures cost per call before and after.
  5. 0:13 Seven days each side, five calls minimum.
  6. 0:16 A change that cost more is marked regressed, and the tab says so.
  7. 0:23 Then check your estimate against the Anthropic bill.
  8. 0:26 Decide on the measured number.

Synthetic example. Read the guide

1

How to

An application that writes one JSON line per model call to .claude/brain/ai-calls/YYYY-MM-DD.jsonl in its repository, as docs/llm-routing-convention.md describes.

That repository tracked by the desktop app.

  1. Have the application write the convention.

    Each line carries ts, surface, tier, model, the tokens block, cost_usd and a request_id, plus a 120-character prompt_preview. Keep the folder in .gitignore: RepoOps reads the working tree, not a commit. Without tier and surface the totals still add up, but the per-tier and per-surface views have nothing to group by.

  2. If the calls happen in production, point RepoOps at the deploy.

    Serve GET /api/ai-calls/log/export behind a bearer token on the deploy, then give the repository a telemetryExport block in repos.config.json with the url and the token as ${env:AI_CALLS_EXPORT_TOKEN}. The puller asks every 5 minutes for new rows, 5,000 a page up to 50 pages, and appends them to their day files.

  3. Find the App LLM calls card on Cost's Overview.

    Cost in the sidebar, then the Overview tab, where App LLM calls follows Claude Code usage. Its picker starts on All repositories, over a trailing 90 days.

  4. Read By surface first, then Routing recommendations.

    By surface, the costliest 25, is already ranked. Routing recommendations above it are forward estimates and say so: a heavy-tier surface averaging under 800 output tokens over at least 5 calls, a cache hit rate under 30 percent over 50 calls, a repeated prompt, a session spending five times the median, a fallback model whose answers come back shorter or fail more, and ten failures on one surface inside a minute, sorted into rate-limited (429), overloaded (529) and other.

  5. Select one repository before reading Realized savings.

    It joins that repository's routing decisions to its own cost stream: the cost per call in the 7 days before a change and the 7 days after. A change that cost more is marked regressed; one with fewer than 5 calls after it says measuring and how many more days it needs.

  6. Check the estimate against the bill.

    Connect an Anthropic Admin key on Billing Guard, or set ANTHROPIC_ADMIN_KEY. The Anthropic bill then sets the card's own 30-day estimate beside the 30-day bill for the same scope.

  7. Tune a rule only when it fires wrongly.

    Open the Rules tab, edit the rule's fields and press Save params; the values persist to config/rules/<id>.json over the defaults.

2

Use cases

One surface is carrying the bill

Situation
Spend is up, several repositories are tracked, and the application tags each call with a surface and a tier.
You do
Leave the picker on All repositories, read By surface from the top, then the recommendations above it.
You see
The surface, its calls and its share of the window. A heavy-tier surface with short answers raises a downgrade recommendation naming the tier pair, labelled a projection: nothing has been saved yet.

Did last month's routing change pay?

Situation
A tier mapping changed in one repository weeks ago, and the recommendation behind it predicted a saving per call.
You do
Pick that repository in the picker and read Realized savings.
You see
The before and after windows, the calls and cost in each, the cost per call in each and the realized delta, or regressed in red, or measuring with the days it still needs. None of it is the forecast that opened the change.
3

Expected outcome

WorkedSummary cards for calls, estimated cost, tokens and cache, then By tier, By surface, By model, Model upgrades, By day, By repository, By team, By user, By tenant and Costliest prompts.
WorkedEvery bucket table repeats calls, input, output, averages, cache read and cost, so a row's share reads without arithmetic.
WorkedRealized savings rows that are measured, measuring or regressed, apart from the forecasts above them.
Did not workThe tab says no app LLM call telemetry has been captured yet.

Next step: No tracked repository has ai-calls rows in the window. Write the convention or add a telemetryExport block.

Did not workA repository shows calls but $0.00 and zero output tokens.

Next step: Its files carry Claude Code session events, not app calls. The card names this case; pick another repository.

Did not workBy team is one row called untagged.

Next step: Set teamId on each repository in repos.config.json, or write team on each row.

Did not workActual billing reads $0.00 while the estimate is real.

Next step: The Admin key belongs to another organization than the API key the application calls with. Use an Admin key from that organization.

Did not workPrice against the gateway reports not measured.

Next step: OPENROUTER_API_KEY is unset, or the gateway gave no usable cost. The savings stay modeled.

4

What else to consider

It prices what your application logged

A call the application does not log is invisible, and cost_usd is computed by the application at write time, so the card calls its figure an estimate until you read it against the bill. Costliest prompts ranks single calls: a cheap prompt run a thousand times shows in the duplicate-prompt recommendation instead. Claude Code session spend lives on Claude Code usage, and spend across providers on Provider spend.

What loaded MCP servers and skills cost

The fold of that name prices each MCP server and skill Claude Code loads, over the same recent sessions as Tool-step cost: the skill's text carried on every turn at each model's cache-read rate, a server's tool output re-read on later turns, and the turns run inside a skill. A server's own schemas are not collected, so that part reads not priced, never $0, and its total is marked as a floor. Turn off removes a server or skill from your user config (~/.claude.json, ~/.claude/mcp.json or ~/.claude/skills) and writes an undo record first, so Undo puts it back. One in a repository's .mcp.json or .claude/skills keeps its button off, because that change goes through a pull request.

Turning a recommendation into a change

A recommendation that names a tier pair can become a routing pull request from Spend efficiency or LLM routing control. RepoOps never merges it, and it does not revert a landed change: revert it in git.

The hosted page

On a bound device the ai-calls files are published with ten prose keys dropped and the secret redactor run, capped at 1 MiB a file, 5 MiB in all and 500 files. The 120-character prompt_preview is not one of the dropped keys, so it is in the published file. No hosted page draws the published files: repoops.ai/team/app-llm-calls opens the Overview tab of the Cost page, which reads the provider bills and agent spend instead.

Cost and egress

Reading and aggregating is local file work. The Anthropic Admin read goes to api.anthropic.com and is reused for five minutes (REPOOPS_BILLING_TTL_MS). Price against the gateway sends one short request per model through OpenRouter on your key, the only paid call here. No route deletes a captured call; removing a day file removes it from every local view.