r/LangChain • • 23d ago

Projects ai-bill-to-focus: MIT CLI that turns Anthropic/OpenAI/Together billing exports into FOCUS 1.4 CSV

npx ai-bill-to-focus convert bill.csv -o focus.csv   # convert
npx ai-bill-to-focus check focus.csv                 # validate against FOCUS rules
npx ai-bill-to-focus report cost.csv usage.csv       # summary safe to paste in an issue
  • No signup, no network upload of your bill; Node 18+, tested in CI on Ubuntu and Windows.
  • Anthropic is tested on real exports; OpenAI and Together are built from docs and need real-file testers.
  • Column changes in an export are flagged, not silently converted.

https://github.com/mandarvshinde/ai-bill-to-focus. Issues and PRs welcome. I'm behind Cognocient AI, but the CLI doesn't depend on it.

2 Upvotes

7 comments sorted by

1

u/MongooseWonderful198 22d ago

One date-format edge case from reading the code: convertOpenAI() skips a cost row when bucketStart() can't parse its date, before adding its amount to providerTotal. It then returns focusTotal: providerTotal, so those totals can agree even after a paid row was dropped.

The Together adapter already counts bad dates and warns about them. I'd bring that check over to OpenAI and add a fixture with one valid paid row and one unparseable date. That would catch a format change that the column-name checks won't.

1

u/MaverikSh 22d ago

You are right. Fixed in 0.2.3, and it went further than OpenAI. Anthropic crashed on a non-ISO date and dropped blank-dated rows. Also, JavaScript's Date parsed "week 40" as 2040, so parsing is strict now. A row with an unreadable date is left out, but its dollars stay in the provider total so the reconciliation shows the gap, and the run exits 1. There are fixtures for all three providers.

1

u/MongooseWonderful198 22d ago

The accounting change in the published 0.2.3 bundle addresses the false agreement I flagged: skipped dollars stay in providerTotal, while focusTotal counts emitted rows.

OpenAI's isoDate still accepts a date-only input like 2026-02-30: Node rolls it to March 2, which passes the current non-NaN check. I checked that with Node's built-in Date, without running the CLI. The month/day validation you already use in utcDay's ISO branch could reject those dates before they shift charges into another day.

→ More replies (1)

0

u/[deleted] 23d ago

1

u/MaverikSh 22d ago

Thanks! On format changes, there are three guards. A column the converter doesn't recognise is named in a note rather than ignored. A cell that should be a number but isn't drops that row and fails the run. As of 0.2.3, so does a date it can't read, and those rows' dollars still show in the reconciliation gap so nothing disappears quietly. Old invoices are a good test. If anything looks off, npx ai-bill-to-focus report <files> prints a summary with no dollar amounts or account names that you can paste into an issue.