RepoOps
Open the app
06 / Cost

Check a bill against your own token counts

Billing Guard recomputes what each day of AI work should have cost from the token counts captured on this machine, compares that with what the provider billed, and reports each day as matching your records, not matching, or not checked. It detects and reconciles; it never caps, blocks or throttles spend.

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 invoice arrives as one total.
  2. 0:02 Nobody recomputes what it should have been.
  3. 0:06 RepoOps prices your own token counts against the rate card.
  4. 0:10 Then it compares, day by day.
  5. 0:13 Ten detectors name what they found, with both numbers.
  6. 0:17 A day it cannot check reads not checked, never clean.
  7. 0:23 Export the evidence, or draft the dispute.
  8. 0:26 Billing Guard detects; it never caps spend.

Synthetic example. Read the guide

1

How to

Claude Code telemetry on this machine for the days you want to check.

For a real reconciliation, an organization Admin key: an Anthropic Admin key (from Create Admin Key in the Anthropic Console) or an OpenAI admin key. Without one, every day reads not checked and the page shows your own side only.

  1. Open Budgets and caps on the Cost page.

    On the desktop: Cost in the sidebar, then the Budgets and caps tab. Billing Guard is the section there with Provider accounts, Reconciliation, Cases with a cost, Provider bill and Billing sources.

  2. Connect a provider account.

    Under Provider accounts on the Cost page's Budgets and caps tab, paste the Admin key and press Connect Anthropic account or Connect OpenAI account. RepoOps checks the shape, then checks the key with that vendor before storing it. The key stays on this machine in the operating system keychain, never in plain text (where no keychain is available, Connect refuses and says why), is never returned to the browser, and every response carries only whether it is configured, where it came from and a masked hint. A key set in the environment always wins over a stored one. AWS Bedrock and Azure OpenAI reconcile through their environment variables only.

  3. Read the measured baseline, then set the tolerance band.

    The band starts at 2 percent: the width inside which a billed day counts as matching. The Measured baseline line beside it reports your drift over fully checked days (median, ninetieth percentile, worst) and, once three checked days exist, suggests a band: the ninetieth percentile plus 25 percent, rounded up to the next half point, never below 1 percent. RepoOps never applies the suggestion for you.

  4. Read the day chips, then the findings table, then the coverage.

    Each billed day reads matches your records, doesn't match, or not checked. A finding row names the day, the model, what we expected, what you were billed, the difference and the detector that fired. Under the coverage summary, one disclosure lists the days that could not be checked with a reason each, and another lists blind spots the engine can see but cannot cross-check.

  5. Act on a finding.

    Draft dispute opens your mail client with the numbers and the raw token counts; it sends nothing. Export evidence bundle downloads the same JSON the command line writes.

  6. Decide whether the daily pages stay on.

    A sweep in the 02:00 pass reconciles the last seven days against every configured provider and pages only on cold-start-spend, delta-alarm and contradiction, each deduped for seven days. Set REPOOPS_BILLING_GUARD_ALERTS_OFF=1 to stop the pages; the tab and the command line are untouched.

  7. Or run the same audit without the app.

    In a terminal: npx repoops-billing-audit --window 30. The first run signs you in once with a verified email, downloads the engine and checks its checksum; later runs use the cached engine and work offline. With ANTHROPIC_ADMIN_KEY set it reconciles; without a key it prints the expected-cost ledger and reconciles nothing. Exit code 0 means everything reconciles, 1 means findings, 2 a configuration error.

2

Use cases

A billed day that does not match your records

Situation
The Anthropic account is connected, the band is the default 2 percent, and the tab reads the last 30 days.
You do
Read the day chips and the findings table, press Draft dispute on the row you want to argue, and Export evidence bundle for the attachment.
You see
A dispute with arithmetic attached: the day, the model, expected, billed, the difference and the detector. If that detector is scope sensitive, rule out the coverage gap first; the page names which detectors that applies to.

Spend that restarts after a quiet spell

Situation
A credential was set and metered billing resumed: yesterday billed nothing, today bills real money, so a day-over-day ratio has nothing to divide by.
You do
Leave the daily sweep on.
You see
cold-start-spend fires when a day after a zero-billed day bills at least the floor, 10 dollars by default, and pages once per seven days for that provider, day, model and signature. A quiet page is not a clean bill: the sweep does nothing when no provider is configured.
3

Expected outcome

WorkedA chip per billed day and four tiles: Days of your records, Days you were billed, Mismatches found and Days not checked.
WorkedAn empty findings table that says every day it could check matches your own records, or one row per finding naming its detector.
WorkedA day the machine captured nothing for reads not checked, with its reason, and is never counted as a problem.
Did not workEvery day reads not checked.

Next step: No provider is connected, or this machine captured no telemetry for those days. Connect an account, or read the reason on each day.

Did not workA pasted key is refused before anything is stored.

Next step: An Anthropic key must be an Admin key from Create Admin Key; an OpenAI admin key starts sk-admin-, and a project key cannot read organization usage.

Did not workAn amber panel says a provider could not be reached.

Next step: That provider's pull failed for this window. Read the error and treat the result below it as incomplete; other providers are unaffected.

Did not workThe table has findings but nothing paged.

Next step: Only cold-start-spend, delta-alarm and contradiction page. Check the alerts flag and that the app ran at 02:00.

Did not workThe hosted page says no desktop is reporting yet.

Next step: No connected desktop has synced a sweep. The Admin key stays on the machine, so connect a desktop.

4

What else to consider

The ten detectors

Four compare the bill with your local telemetry and are scope sensitive: variance-band (the day exceeds expected beyond the band), ghost-usage (usage billed on a day and model your telemetry logged zero), duplicate-burst (billed usage at least 2x logged) and cache-share-divergence (the cache-read share differs by more than 15 points). Four compare the provider's own surfaces or the rate card, so a coverage gap cannot produce them: rate-check, delta-alarm (the day grew 3x or more), cold-start-spend and contradiction (the usage report shows zero while the cost report bills money). Two read only the local request log: duplicate-request (one request id with different usage) and ghost-prompt (an api_error that still carries cost). Every finding carries the verdict verified-mismatch: both sides were present and disagreed.

The scope gap

Local telemetry covers one checkout; an organization Admin key bills the whole organization. The four scope-sensitive detectors read low whenever other people or projects share that key, and the tab says so when a Claude account is connected. Bedrock and Azure cost APIs carry no per-model token count, so their findings are day level only. Priority Tier costs and code execution are known Admin API blind spots, listed as annotations rather than mismatches.

Settings in the data directory's .env

REPOOPS_BILLING_GUARD_TOLERANCE_PCT sets the default band for the tab, the command line and the sweep; an explicit value still wins. REPOOPS_BILLING_COLD_START_FLOOR_USD sets the cold-start floor (10, and zero is refused). REPOOPS_ANTHROPIC_ADMIN_WORKSPACE_ID narrows Anthropic's reports to one workspace. REPOOPS_BILLING_TTL_MS sets how long a cost report is reused (300000). Bedrock needs AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION; Azure needs AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET and AZURE_SUBSCRIPTION_ID.

Spend by key and workspace

With an Anthropic or OpenAI Admin key connected, RepoOps also reads the provider's usage grouped by API key and workspace (Anthropic) or API key and project (OpenAI) and prices each row at the same rate card. It shows as By key / workspace on Provider spend. Name keys with keyLabels and workspaceLabels in the repository's costReconciliation block in repos.config.json.

The bill read from the provider

Provider bill, on Budgets and caps, reads the bill for the repository picked above it from the provider itself, for the period the repository's costReconciliation block in repos.config.json names. Anthropic and OpenAI have a reader, and each pulls the organization's cost report, read-only, with the Admin key connected under Provider accounts or set as ANTHROPIC_ADMIN_KEY or OPENAI_ADMIN_KEY. Two tiles sit side by side and are never summed: Measured, provider invoiced and Estimated, modeled and kept apart. Under them the card names the provider, the account and the period with its time zone, and when the bill was read, how many lines it has, the unit the amounts arrived in and a digest of the provider's answer. A bill that could not be read says why and reads unknown, never $0.00: an empty report is not a zero bill, and a missing, refused or wrong-organization key reads unavailable with the reason.

Show the bill's lines lists each line with its raw amount and unit. To record which bill paid for a case, type the case id under Attach this bill to case and press Attach: the case keeps the provider, the account, the period, the line ids, the net over them and the unit. The case's Cost section then shows a Provider bill row. Once the desktop sends the case to your team, repoops.ai shows the same row, and Billed and measured on its Cost page lists the bills desktops attached beside the measured receipts, never summed.

Transcript

The walkthrough is silent. These are its captions, in order. Every value it shows is illustrative.

  1. 0:00Provider bill reads the invoice itself, read-only, beside the estimate
  2. 0:06A bill it could not read says why and reads unknown, never $0.00
  3. 0:12Attach the bill to the case it paid for
  4. 0:18Billing sources map which account bills which repository
  5. 0:24On repoops.ai, attached bills sit beside measured receipts, never summed

Billing sources

Billing sources maps which provider account bills which repository, service and environment on this machine, and each source declares the least privilege its reader needs: a read-only cost report, nothing written. Anyone can fill in Provider, Provider account, Repository id, an optional Service, Environment and Who is asking, and press Request a mapping. Approve, Decline and Remove are operator moves, so a machine with an operator confirmation set asks for it. Every move is on the audit line under the table. Only an approved source is read: it supplies the provider and the account for that repository's bill, and the costReconciliation block's own provider and providerAccount are used only when nothing is mapped. repoops.ai keeps a mapping per team at /api/team/billing-sources, where any member may request one and an owner or admin decides, each move written to the team's audit log; no hosted page draws it yet. On repoops.ai the Provider bill and Billing sources cards say they are read on the desktop app, which holds the provider key.

The command line in full

Flags: --window (default 30), --tolerance (default the environment value, else 2), --measure-baseline (print your drift and a suggested band instead of findings), --claude-dir (default ~/.claude), --out (default billing-guard-report.json in the system temporary folder), --dispute n (draft a dispute email for finding n from the last bundle) and --json. Set REPOOPS_AUTH_TOKEN to skip the browser sign-in in CI. The command line runs every detector except duplicate-request and ghost-prompt, which read the request store only the app feeds. A daily per-user scheduled task (Windows Task Scheduler or a macOS LaunchAgent) needs no admin rights.

Inside Claude Desktop

On a machine that cannot run RepoOps, install the Billing Guard extension (a .mcpb file) from Settings, Extensions, Install from file. It needs Node 20 or newer and adds three tools: billing_guard_audit, billing_guard_report and billing_guard_status. Its Admin key field is stored in the operating system keychain. A background sweep reruns the audit every 6 hours (0 turns it off), and only while Claude Desktop is open. The download is served from repoops.ai once the operator publishes it; until then, anyone with repository access builds it with npm run pack:mcpb.

The hosted page, data and cost

A connected desktop syncs its sweep events to your team. No hosted page draws them as a rollup: repoops.ai/team/billing-guard opens Budgets and caps on the Cost page. Detection is deterministic code with no model call. The Admin key goes only to that vendor's read-only usage and cost endpoints; syncing the sweep events to your team is the only RepoOps egress. Disconnect removes a stored key; revoke the key itself where it was issued.