codeburn icon indicating copy to clipboard operation
codeburn copied to clipboard

[Feature] Local model cost saving reports

Open camggould opened this issue 6 months ago • 3 comments

While codeburn currently offers an excellent user experience for monitoring token expenditure through online models and their API rates, its current approach is only half of the story for cost optimization.

The other half is to support local model cost saving analysis. I currently do this by having my local model map to the model I would usually use in place of it (e.g., Qwen 3 Coder mapping to GPT 5.3 codex). While this gets the job done by showing the hypothetical money saved, it is still being reported as "spend" rather than savings.

Key abilities:

  1. Map local models as "savings" rather than costs
  2. Provide toggles that allow users to map their local models to the pricing of different models easily, to estimate the savings based on which model they're hypothetically replacing. This is useful for reporting on how much a user saved by using a local model in place of other models.
  3. Forecasting of savings over time based on increased or decreased percentage of overall LLM usage going toward local models versus paid models.

camggould avatar Jun 01 '26 02:06 camggould

This is something I've ran into myself, I want to work on it, since it's one of the few open-soruce projects I actually use. After looking a bit through the repo, here's what I planned to implement for this:

  1. Add a separate config field, e.g. localModelSavings, mapping local model names to baseline paid models. Example:
{
  "localModelSavings": {
    "qwen2.5-coder:14b": "claude-sonnet-4-20250514"
  }
}
  1. Keep modelAliases unchanged. modelAliases should continue meaning “treat this model as that model for actual spend.” The new savings mapping should mean “this local model cost $0, but would have cost X if run on the baseline model.”

  2. Add pricing helpers in src/models.ts. These would compute savingsUSD using the baseline model and the same token counts, while leaving local costUSD at 0.

  3. Extend parsed call types with optional savings metadata. The fields:

savingsUSD?: number;
savingsBaselineModel?: string;
isLocalSavings?: boolean;

  1. Normalize savings centrally in src/parser.ts. This should cover Claude JSONL calls, provider calls, and cached calls without editing every provider parser.

  2. Add a CLI config command. I’d use a dedicated command rather than overloading aliases: codeburn model-savings codeburn model-savings --list codeburn model-savings --remove

  3. Add savings to reports.

  • report --format json: overview, daily, projects, models
  • models --format table/json/csv/markdown: add Saved / savingsUSD
  • status --format json, status --format menubar-json, daily cache, + in Menubar GUI

justingheorghe avatar Jun 01 '26 06:06 justingheorghe

Implemented in #423. Abilities (1) and (2) are in: codeburn model-savings <local> <baseline> tracks avoided spend separately from costUSD across the dashboard, JSON/CSV exports, menubar payload, macOS menubar, and GNOME extension. Historical savings are recomputed automatically when the baseline mapping changes (daily-cache hash invalidation).

Forecasting (ability 3) is intentionally out of scope for this PR per the original plan — it requires an additional model layer and a longer-history read path, and can be added on top of the historical savingsUSD totals this PR exposes without re-touching the core accounting.

Closing this; happy to follow up with forecasting in a separate issue if you want it.

justingheorghe avatar Jun 01 '26 08:06 justingheorghe

Shipped on main (via #454, building on @justingheorghe's #423). Abilities 1 and 2 from your request are in: local models are tracked as savings, not spend, and you choose which paid model each one is priced against.

How to use it:

codeburn model-savings <local-model> <baseline-model>

For example, to credit a local Qwen against the GPT-5.3 Codex you would otherwise have used:

codeburn model-savings "qwen2.5-coder:14b" "gpt-5.3-codex"

Then run codeburn (or codeburn report). That local model's actual cost stays $0, and the amount you avoided shows up as a green "Saved" figure, priced against the baseline. Historical savings recompute automatically if you change the mapping. List mappings with codeburn model-savings, remove one with codeburn model-savings --remove <local-model>.

Forecasting (ability 3, projecting savings over time) was intentionally left out of this first pass and can be a follow-up. Thanks for the well-framed request.

iamtoruk avatar Jun 06 '26 20:06 iamtoruk