Skip to content

Tokens Costs and Analytics

nguyen.david edited this page Aug 13, 2026 · 1 revision

Tokens, Costs, and Analytics

CCAM's analytics help compare activity, find outliers, and explain spend. Treat cost as an estimate derived from recorded usage and configured pricing, not as a billing invoice.

Start with scope

Before comparing totals, align:

  • time range and timezone;
  • provider and model;
  • project and source filters;
  • whether cached/input/output token categories are included;
  • the pricing table effective for that model and period.

Two screens can be individually correct while showing different scopes.

Useful questions

  • Which sessions dominate token use this week?
  • Is cost concentrated in one model, project, or source?
  • Did a long session repeatedly reread context?
  • Are cached tokens changing the effective cost pattern?
  • Did a workflow retry or fan out across many subagents?

Use the analytics view for trends, then drill into a specific session for causality.

CLI checks

npx ccam cost
npx ccam analytics
npx ccam session <session-id>

The current CLI help documents available ranges, groupings, and structured output options.

Explaining a discrepancy

Check in this order:

  1. same session IDs and date boundaries;
  2. same provider/model identity;
  3. usage events are present and fully imported;
  4. pricing overrides match the intended rates;
  5. no duplicate remote/local collection of the same work;
  6. billing-system rounding or provider-specific categories.

Never “fix” a number by editing the database. Preserve the raw evidence and correct the importer, identity, or pricing configuration.

Cost guardrails

Alerts work best as early warnings, not hard accounting controls. Set thresholds high enough to avoid routine noise, route them to an owned channel, and include a link or session ID that makes the alert actionable.

For a focused procedure, use Recipe: Audit an Expensive Session. For alert setup, see Alerts and Webhook Recipes.

Clone this wiki locally