What an AI cost audit finds in your code
A free AI cost audit lists every AI call in your code, its model, estimated cost and common waste. It runs on your machine and uploads nothing.
Updated
Part of: Cut your AI bill
An AI cost audit is a review of every AI call in a codebase. It lists each call, the model it targets, an estimated cost, and the checks that catch common waste. The free audit from Own Weights maps your AI spend by task, so you can see which task is worth moving first.
What the audit reads in your code
The audit tool reads your repository as text on your own machine. It makes no network calls while it reads, and it uploads nothing. It finds each place your code calls an AI API, the model that call targets, and the estimated cost of running it. The result is a PDF report.
The tool is open source under the MIT license at https://github.com/ayaangazali/ownweights-audit, so your engineers can read every line before they run it. Run it from inside the repository you want checked. For the arithmetic behind the numbers, see how to estimate LLM costs before you ship.
The nine checks and what each one costs you
Most checks concern how the code calls the API, not which model it uses:
- Retired models: calls that target a model the provider has shut off or is about to. Treat this one as a deadline.
- Missing prompt caching: the same long instructions sent again on every request. The waste grows with traffic, not with answer length.
- No output limit: calls that let the model write far more than the task needs. A classifier that returns one label should not return an essay.
- API keys in code: secrets written into source files instead of environment variables. This is a security issue before it is a cost issue.
- No timeout: requests that can hang a worker with no upper bound. A stuck worker holds capacity, and retries can pile up behind it.
- Calls inside loops: one request per item, where one batched request might do. Per-request overhead, including repeated instructions, is paid once per item.
- JSON parsing without structured output: code that breaks when the model changes its formatting.
- No fallback provider: one outage at one vendor stops the feature. This check is about continuity more than price.
- No evals: AI calls with no test that checks whether the answer is still right. Without one, none of the cheaper changes below can be verified safely.
A finding is a prompt to look, not a verdict. Read each one against what the call actually does, since a missing timeout matters far more on a request a user waits for.
Reading the cost estimate
The cost figure is an estimate from the code, not a bill. The code does not show how often each path runs in production, which rates your contract sets, or how long your real inputs are. You can test volume and length in the LLM cost calculator.
Ranking matters more than the exact dollar value. Take two calls. One runs once a day to build a report. The other runs once for every incoming support ticket and resends the same long instruction block each time. The second deserves attention first, because its volume is far higher and the caching finding on it is probably the one that pays. Costs that never appear on the API line covers what the estimate misses.
Common mistakes when reading the report:
- Treating the estimate as the invoice, then cutting a call the bill shows is small.
- Fixing the largest per-call estimate on a path that runs rarely.
- Dismissing a finding because the call looks harmless in isolation. Check how often it runs.
- Changing the model before the configuration fixes are in. Those fixes move the baseline, so measure again afterward.
From finding to cheaper inference
Some findings are configuration fixes: set a timeout, add an output limit, move keys into environment variables, and turn on prompt caching where your provider supports it. These take little work and leave the model unchanged. How to cut your LLM API bill walks through them in order.
Each one has a trade-off. Batch processing is usually cheaper than real-time calls, but the answer arrives later, so it only fits work nobody waits on. An output limit set too tight cuts answers short, so test it on real examples. Caching depends on the start of the prompt staying identical, so an instruction block that changes on every request gets no benefit.
Other findings point to a single high-volume task that a frontier model handles today. That is where a trained model can help. Own Weights fine-tunes an open-weight model for that one task, tests it against the model you use now on data from your own business, and serves it in your cloud account or on-prem. You own the weights, and the trained model must beat the current one on that test before it goes live.
When you act on a report, work in this order:
- Fix the configuration findings on the calls that run most often.
- Re-run the audit and compare the new estimates with the old.
- Check the top three or four estimates against invoices and call logs.
- Mark any large, high-volume task that is still expensive as a candidate for a test.
What happens after the audit
The audit is the first of four steps:
- Audit: free. We map your AI spend by task from your code and invoices.
- Evaluate: we build a test from your real data and score the current model first, so there is a baseline to beat.
- Train: we fine-tune an open-weight model for that task. It must beat the current model on the test before it is deployed.
- Serve: the model runs in your cloud account or in your building, tuned for throughput.
Nothing moves to production on a promise. The test decides, and if the trained model does not beat the current one, you keep the report and your existing setup. The audit shows where to look. Only a test on your data shows whether a trained model can take over a task. For how our approach scored on a public legal extraction benchmark, see the full results.
If the audit shows one task that makes up most of your AI spend, book a free audit call with the button on this page. Bring the report and a few examples of the inputs and outputs for that task. We will tell you plainly whether a trained model is worth testing. Learn more on the Own Weights home page.
Questions
What does an AI cost audit check?
It checks for retired models, missing prompt caching, no output limit, API keys in code, calls with no timeout, calls inside loops, JSON parsing without structured output, no fallback provider and no evals. Each check that fires is listed in a PDF report. You decide which findings matter for your budget.
Does an AI cost audit send my code anywhere?
The tool reads your repository as text on your own machine. It makes no network calls while it reads and uploads nothing. The code is open source under the MIT license, so your engineers can read it before they run it.
How accurate is the cost estimate from an AI cost audit?
It is an estimate from the code, not an invoice. It cannot see production traffic, the rates in your contract or how often each path runs. Check the largest estimates against your invoices and call logs before you act on them.