--- title: Cost description: Token and spend analytics across every runtime and model — breakdowns, trends, cache efficiency, attribution, anomaly detection and the optimizer. keywords: LLM cost tracking, agent token usage, AI spend analytics, Claude Code cost, cache hit rate eyebrow: Dashboard --- # Cost Where the money is going, at every level of detail you might need it. ## The breakdowns **By runtime.** The first cut, and usually the surprising one. Which of your agents is actually expensive. **By model.** Per-model daily token and cost rollup. This is where you find out you have been running a frontier model on a task a cheap one handles. **By session.** Every session with its totals, sortable. The tail of this list — a handful of sessions that cost more than the rest combined — is where the value is. **By skill and by tool.** Where a runtime attributes work to a named skill or tool, cost follows the attribution. **By team.** Team mappings let you roll individual keys or agents up to a group, which is what makes an internal chargeback conversation possible. ## Trends and windows Daily, weekly and monthly totals with the trend. One thing worth knowing: a "cost window" has exactly one definition in ClawMetry, applied everywhere. The number on Home, the number on this page and the number in `clawmetry status` are the same query against the same rollups — if they ever disagreed, that would be a bug rather than a subtlety. ## Cache efficiency Prompt caching is the single largest lever on agent cost, and it is nearly invisible without instrumentation. - **Cache hit rate** over time - **Cache trends** — is your caching getting better or worse as prompts drift? - **Cache risk** — sessions where a small change would invalidate a large cached prefix ```bash curl -s localhost:8900/api/efficiency/cache-hit-rate | jq curl -s localhost:8900/api/usage/cache-trends | jq curl -s localhost:8900/api/usage/cache-risk | jq ``` ## Anomalies Spend that does not look like your normal pattern gets flagged. This is a statistical comparison against your own history, not a fixed threshold — a $40 session is unremarkable on one fleet and an emergency on another. ```bash curl -s localhost:8900/api/usage | jq '.anomalies' curl -s localhost:8900/api/token-velocity | jq ``` → [Anomaly detection](/docs/cost/anomalies/) ## Optimization recommendations The routing advisor looks at what your sessions actually do and suggests where a cheaper model would have produced the same result, plus where caching is being left on the table. ```bash curl -s localhost:8900/api/usage/optimization-recommendations | jq curl -s localhost:8900/api/efficiency/routing-advisor | jq curl -s localhost:8900/api/cost-optimizer | jq ``` → [Reducing spend](/docs/cost/optimization/) ## Where the numbers come from Cost is derived **at ingest**, once, from the token split and the model, using a multi-provider pricing table. Deriving at read time would mean a change to the pricing table silently rewriting history. Where a runtime records real dollars — Cline, opencode, Pi, Copilot, Exo, Goose for paid providers — those are used instead of an estimate, and the session is marked `exact`. Where neither is available the session says `unavailable` and shows no dollar figure at all. The per-runtime detail is in [What each runtime exposes](/docs/runtimes/coverage/); the full model is in [How cost is computed](/docs/cost/model/). :::warning Do not compare against a tool that estimates Cost tools that reconstruct spend from transcripts without cache accounting can overstate by several times, because a cache read is priced very differently from a fresh input token. If ClawMetry's number disagrees with another tool's, check whether the other one is accounting for cache reads and writes separately. ::: ## The API ```bash curl -s 'localhost:8900/api/usage' | jq curl -s 'localhost:8900/api/local/models?since=2026-08-01' | jq '.rows' curl -s 'localhost:8900/api/local/runtimes' | jq '.rows' curl -s 'localhost:8900/api/local/aggregates' | jq '.rows[-14:]' ```