Measure Your Real AI Token Usage and Cost: Local Logs vs Platform Bills

Most people measure AI cost by multiplying a price table by a guess. That produces a unit price, not an invoice. What you were actually charged depends on cache hit rates, context growth, and models quietly re-routed behind the interface — none of which a price table can see. This guide gives you two routes that measure it for real.
Choose the route by data location and granularity
The dividing line is not “client versus platform”. The same unit of spend can be billed on a server while its detail sits on your disk, or leave no local trace at all. Ask two questions of every tool: where is the data stored, and how granular is it?
| Case | Tools | Where the data lives | Granularity | Route |
|---|---|---|---|---|
| Server-side billing, no local tokens | Qoder, CodeBuddy, TRAE, CloudCode | Provider servers | Bill only | ai-usage-report (only source) |
| Complete local session logs | Copilot, Codex, Claude Code, OpenCode | Local JSONL / SQLite | Per agent / model / session / day | ai-token-usage (offline detail) |
| Bill exists but is coarse | DeepSeek console + a local client | Charges on platform, detail local | Platform per day, local per session | Use both |
Three situations worth naming explicitly:
- IDE platforms only — no readable local records exist, so the platform bill is the only source.
- Local client with your own API key (BYOK — bring your own key) — the client vendor’s billing page has no record of you and the API vendor shows only daily totals, so local logs are the only way to attribute spend to an agent or a session.
- Coarse platform bills — the bill answers “what was I really charged”, the logs answer “where did it go”. You need both.
Route 1 — Parse local session logs (ai-token-usage)
This skill reads the logs your clients already write, unifies each vendor’s field names into input_tokens / output_tokens, and aggregates by agent, model, session and day. It also reports how much of the current session’s context window remains.
My August result: 1.4B tokens (1,378M input, 12M output), 14,700 turns, 204 sessions, roughly ¥813.16 estimated.

Pricing caveat: that figure is costed at standard token prices, not real incurred spend — free-tier usage is priced at the vendor’s official rate and counted in the total. deepseek-v4-flash is free on OpenCode, yet those tokens are still costed at DeepSeek’s official pricing inside the ¥813.16 figure. Read it as usage costed at list price: higher than what you were actually charged.

Cost here is an estimate, not an invoice. It prices the real input / output / cache-read split rather than a blended rate — important, because cache reads are orders of magnitude cheaper than output tokens. Cache reads use the cache rate while the price table stores standard list rates.
Hard limit: Qoder, CodeBuddy, TRAE and CloudCode write no parseable local token logs. This route reports zero for them — expected behaviour, not a bug.
Route 2 — Normalise platform bills (ai-usage-report)
This skill turns each platform’s bill into one record shape — date / model / cost / free / prompt / platform — and produces reports with charts plus a cross-platform overview. Data enters three ways: official exports, direct REST calls, or a real browser session that keeps you logged in.

Granularity follows the platform: CodeBuddy exports per request, DeepSeek only per day. Two guardrails protect the result — abort if scraping missed more than 50% of the requested days, and drop records an API returned outside the requested window so they cannot backfill gaps into the wrong month.
The unit trap: credits are not currency
Qoder and DeepSeek bill in RMB. TRAE and CodeBuddy bill in credits. Adding them raw produces a number that looks authoritative and means nothing. Convert credits to a common currency first using the configurable rates, then treat the converted total as a reference — promotions and bonus credits skew it. For genuine cross-platform comparison, use dimensionless metrics: request count, active days, model mix.
Delegating the measurement
Both are AI skills, so you describe what you want in plain English instead of memorising flags. A full audit across both skills took four requests, three minutes and 3.80 credits — about ¥0.09.

Here is what that run measured — a month of real daily spend, peaking at ¥26.80, with most days under ¥10:

Measuring cost two orders of magnitude less than the thing being measured. One caveat from that same bill: I had explicitly selected hy3-x, yet deepseek-v4-pro also appeared — the IDE routes some sub-steps to a different model. The model you think you are paying for is not always the model you are paying for.
Reproduction checklist
- For each tool, record three facts: are there readable local logs, where is the bill, and how granular is it?
- Run the log scan for per-agent and per-model splits; run the bill pull for actual charges; use both when the bill is coarse.
- Convert units before any cross-platform total, and treat converted totals as reference only.
- Repeat monthly and archive the output — usage is a trend, not a snapshot.
References
ai-token-usagemanual — install, options, report and data-store layoutai-usage-reportmanual — data paths, validation guardrails, unit conversion config- Source repository: https://github.com/KylinLabAI/kylinlab.tech.skills
Stop estimating. Measure once and you will never read a price table the same way again.