← blog
How to Measure the Real Cost of AI Coding Tools

How to Measure the Real Cost of AI Coding Tools

A practical way to turn Claude Code and Codex logs into a 30-day report, interpret API-equivalent cost and spot expensive workflow habits.

by Danila— views

Token totals look objective, which makes them easy to misunderstand. A dashboard can show millions of tokens and an impressive dollar figure without answering the question a developer actually cares about: what was paid, what work was completed, and which habits created waste?

The practical answer is to treat token data as a workload signal, not a receipt. Local agent logs can reveal trends, but their cost estimates need context.

Start with the logs the tools already write

ccusage is an open-source CLI that reads usage data from coding-agent tools and groups it into daily, monthly or session reports. Its source-specific JSON commands make a simple 30-day report possible:

npx -y ccusage@latest claude daily --json
npx -y ccusage@latest codex daily --json

A small scheduled script can merge the two files by date, fill missing dates with zeroes and keep only the latest 30 days. The published result does not need prompts or source code; a narrow record is enough:

{
  "date": "2026-07-21",
  "claude": { "tokens": 420000, "cost": 1.84 },
  "codex": { "tokens": 180000, "cost": 0.71 }
}

Those numbers are fictional sample data. They demonstrate the shape of a report, not typical usage or current pricing.

API-equivalent cost is not the amount charged

One total may combine fresh input, cached input, model output and reasoning output. Those categories can have different rates. Subscription usage is different again: it may draw from a shared allowance rather than create an invoice for each token.

That makes “API-equivalent cost” a more honest label for a local estimate. It answers: “What might this logged usage cost under mapped API rates?” It does not answer: “What left the bank account?”

The estimate has another limit. Log formats, model identifiers and price maps change. A parser can only use the fields it received and the price it can match. Unknown models or missing cache fields make older days incomplete. Rounding the result to two decimals does not remove that uncertainty.

A fictional report, read the right way

Suppose a developer sees this weekly pattern:

Day Total tokens Cached share API-equivalent cost
Monday 3.2M 78% $8.40
Tuesday 3.0M 81% $7.90
Wednesday 9.8M 22% $41.60

The useful question is not “How do we make Wednesday smaller?” First ask what happened. Perhaps Wednesday contained a successful migration across 200 files; then the spike may be good value. Perhaps an agent retried the same failing approach for two hours; then the expensive part is the missing stopping condition.

The cached share is a clue, not a grade. A low number may mean the reusable prefix kept changing, but it can also be normal for short, unrelated tasks.

Subscription and API spend answer different questions

Subscriptions make the monthly ceiling easier to understand for interactive work. API billing makes per-request accounting clearer for automation. Anthropic’s current guidance states the distinction directly: plan-based sign-in uses an included allowance, while an API key is pay-as-you-go; /cost reports session spend for API billing. Since models and limits change, check the current Claude Code usage documentation rather than copying a price table from an old guide.

This is also why a durable article should avoid declaring one model “the cheap option” forever. Link to the source of truth and explain how to compare, not just what today’s table says.

Signals worth watching

A useful dashboard highlights changes in behaviour:

Do not optimise for the smallest token number. A precise 500-word brief can prevent an unnecessary rewrite and be cheaper than a vague sentence.

Habits that reduce waste without reducing quality

Start a fresh session when the job changes. Ask for a plan before wide edits. Give the agent the exact check it must run and a condition for stopping. Use a capable model when the problem demands it, then switch to a cheaper or faster option for mechanical execution if the tool supports that workflow.

Review usage weekly rather than after every prompt. Trends are actionable; a single large session often is not. When a spike appears, connect it to the finished work before deciding whether it was waste.

The same principle applies to agent workflow more broadly: define the outcome and the evidence before execution. The companion article on a practical workflow for AI coding agents covers that loop.

What a trustworthy dashboard should say out loud

A good usage report labels its source, generation time, time zone, included tools and the meaning of “cost.” It should state whether values are actual charges, API-equivalent estimates or subscription usage. If model pricing was unavailable, show that gap instead of silently treating it as zero.

Token tracking becomes useful when it replaces a vague feeling with a better question. The goal is not to admire a giant number. It is to understand which work was valuable, which loop was wasteful and what to change next time.