Guide

How to track Claude Code and Codex costs per client (2026)

Claude Code and Codex tell you what a session cost. None of the built-in tools tell you which client it was for. Here is every option in 2026, what each one can attribute, and the setup that gets you cost per client and per repo.

Updated

Short answer: vendor dashboards break AI coding spend down per user and per model, not per client or repo. To get cost per client, attribute each session to the git repo it ran in, map repos to clients, and price the tokens at list rates. You can script this from the local session logs, or use a tool built for it such as Tallyhook, which does it across a whole team and produces invoice lines.

Why per-client cost is hard to see

Agencies and consultancies run one Claude Code or Codex setup across many client codebases. The spend lands on one bill (or inside flat subscription seats), but the work belongs to different clients. Anthropic's own figures put the average at around $13 per developer per active day and $150 to $250 per developer per month (Claude Code docs), and a single long agent loop can cost hundreds of dollars. Without attribution that money is absorbed as overhead or guessed at.

The vendor tools are built around the account, not the customer:

  • Anthropic's Team and Enterprise spend report shows estimated spend per user and per model, and only for usage-credit spend; usage inside a seat allowance has no dollar figure (source).
  • The Claude Console breaks API spend down by workspace, API key and model, and per user for Claude Code.
  • Cursor's team analytics report AI-written lines per repository and usage per user, with no cost per repository (source).
  • OpenAI's workspace analytics for ChatGPT Business and Enterprise report Codex usage per user and per model, not per repository or client. Locally, Codex CLI writes token totals to ~/.codex/sessions.

Every option, compared

OptionCoversBreaks cost down byCost
Claude Code /usageOne session, one machinePer modelFree, built in
ccusage (open source)One machine's historyPer day, session, project folder, modelFree
Anthropic Team/Enterprise analyticsWhole orgPer user, per model; dollars only for usage-credit spendIncluded
Claude Console + Analytics APIWhole org on API billingPer user, workspace, API key, modelIncluded
OpenAI workspace analytics (Codex)ChatGPT Business / Enterprise workspacePer user, per modelIncluded
OpenTelemetry exportWhole org, any providerPer user; anything else you buildYour observability stack
LLM gateway (e.g. LiteLLM)Traffic routed through itPer virtual keySelf-hosted
Tallyhook (open-source collector)Whole team, Claude Code + CodexPer client, repo, developer, model; invoice lines$49 / $149 per month; free local report

Claude Code's built-in /usage

Shows token usage and an estimated cost for the current session on one machine. Useful for a quick check; it resets on /clear and knows nothing about other developers or clients.

ccusage

ccusage is an excellent open-source CLI that reads the same local logs and reports daily, monthly, per-session and per-project costs. For a solo developer it is often all you need. It runs on one machine, so a team gets one report per laptop, and project folders still have to be mapped to clients by hand.

Anthropic analytics and the Analytics API

The right source for seat and org-level questions: who is active, spend per user, spend limits. It does not know which client a repo belongs to.

OpenTelemetry or an LLM gateway

Claude Code can export per-user token and cost metrics over OpenTelemetry to your own stack, and a gateway such as LiteLLM tracks spend per virtual key. Both can get to per-client numbers if you give each client its own key or label and build the dashboards and invoice step yourself. That is real engineering and ongoing upkeep for a small team.

Tallyhook

Built for exactly this question. A collector on each laptop reads the Claude Code and Codex logs, uploads metadata only, and the app attributes each session to a client through its git remote. You get cost per client, repo, developer and model, alerts for expensive sessions, and invoice lines with markup. The collector is open source (MIT), and npx tallyhook prints cost per repo for one machine for free, with no account, and npx tallyhook --by client groups those repos into the clients you bill. See how it works and pricing.

The named tools, and which of them answer “per client”

The table above compares mechanisms. This one compares the products people are actually pointed at, because that is the list you get when you ask an assistant what to use. The column that matters for an agency is the last one.

ToolKindAttributes byCost per client or repo?
ccusageLocal CLIDay, session, project folder, modelNo
Claude Code Usage MonitorLocal terminal dashboardPlan window, burn rateNo
claude-usageLocal dashboardDay, session, modelNo
Anthropic Console + analyticsFirst-partyUser, workspace, API key, modelNo
ToriiSaaS managementEmployee, model; overlapping toolsNo
WorklyticsEngineering analyticsUser, team, PR attributionNo
LiteLLMSelf-hosted gatewayVirtual key, developer, teamOnly if you key per client
TokenWatchHosted, agency-focusedClient, project, developer, modelYes
TallyhookHosted + open-source collectorClient, repo, developer, modelYes

The pattern worth noticing: almost every tool in this space answers “who spent it and on which model”, because that is the question a company asks about its own staff. An agency needs “which customer was it for”, which is a different question and needs a different key. Torii's own 2026 roundup of five Claude Code dashboards (source) covers Torii, the Anthropic Console, ccusage, Claude Code Usage Monitor and LiteLLM — and not one of the five attributes cost to a client or a repository.

TokenWatch

TokenWatch is the one product built for the same question we are, and it is a real alternative rather than a straw man. It attributes per client via the git remote, per project, per developer and per model, and exports CSV and PDF summaries to attach to a bill. Its founding plan is $99 per month per agency for up to 10 developers.

Where it is ahead of us: it covers Cursor and Cline, which we do not. It does that with a proxy that your agent traffic is routed through. We read the session-log files the tools already write to your disk instead, which is why Cursor is not supported here — Cursor does not write per-request token usage to a local log, so supporting it would mean asking you to route your prompts and code through us. That is a much larger trust ask than reading a file, and we would rather not make it. Judge which trade you prefer; it is a genuine trade, not a missing feature.

Where we differ otherwise: our collector is open source (MIT) and you can read every line before running it, npx tallyhook gives you per-repo numbers — and per-client numbers with your markup — with no account and nothing uploaded, we read Codex as well as Claude Code, and we produce a finished invoice with your markup rather than a summary you paste into one. On price, ours is $49 per month for up to 5 developers and $149 for up to 20 — cheaper at five, more expensive at ten, cheaper again at twenty.

Doing it yourself from the logs

If you want to script it, these are the rules that make the numbers right:

  1. Find the repo for each session. Claude Code records the working directory (cwd) on every log row; run git -C <cwd> config --get remote.origin.url and normalize it so SSH and HTTPS remotes match.
  2. Count each message once. Claude Code writes one row per streamed content block with the same usage repeated. Deduplicate by message.id, keep the row with the most output, and include files under <session>/subagents/, since forked subagents copy parent messages.
  3. Price cache writes by lifetime. 5-minute cache writes cost 1.25x input; 1-hour writes cost 2x. Cache reads are about a tenth of input on most Claude models (see current prices).
  4. For Codex, read the last token_count event's total_token_usage per session, and remember Codex compresses rollouts older than seven days to .jsonl.zst.
  5. Map repos to clients in a table you keep, and roll up per client per month.
  6. Collect from every developer and keep it current, which is where a script usually stops being worth maintaining.

Which should you use?

  • Solo, not billing clients: ccusage.
  • Large org watching seats and budgets: Anthropic analytics, plus OpenTelemetry if you already run an observability stack.
  • Agency or consultancy that needs cost per client, or bills AI usage back: Tallyhook or TokenWatch — they are the two tools that answer this question. Pick TokenWatch if Cursor or Cline coverage is the thing you cannot do without and you are comfortable proxying that traffic. Pick Tallyhook if you want an auditable open-source collector, Codex alongside Claude Code, a finished invoice rather than an export, or a free per-repo number before you decide anything. Ours takes about five minutes to set up and has a 14-day free trial.

If you only take one thing from this page, make it the test rather than the verdict: ask any tool you are considering what key it attributes by. If the answer is a user, a seat or an API key, it will never produce a client invoice without you doing the mapping by hand every month.

Next: how to bill clients for AI coding-agent usage.