Quick answer
To get cost per project, group sessions by working directory, sum the tokens for each group, apply the rates for the models used, and divide by completed tasks in that project. Do not divide a monthly bill across every repository you touched, and keep plan fees separate from usage cost.
The formula
project_cost = sum(tokens_by_model * rate_by_model)
cost_per_task = project_cost / completed_tasksRun it per week, not per month, so a single heavy refactor does not hide inside an average. Weekly figures also make plan changes visible.
Attribute honestly
| Session type | Bucket | Why |
|---|---|---|
| Feature work in one repo | That project | Direct |
| Cross-repo refactor | Split or platform | Shared cost |
| Tooling and setup | Platform | Not product work |
| Abandoned sessions | Separate | Process metric |
| Chat with no repository | Unallocated | No target |
The unallocated bucket matters. If it is large, your local logs are not recording a working directory, and the per-project number is guesswork.
Get the data
UsageAtlas groups local sessions by project and shows 7, 30, or 90-day totals per provider, which is enough to run the formula without exporting transcripts. The Codex method and Claude method show the field-level detail.
For the team view, see AI coding team usage.
Agree the attribution rules first
Project cost depends on a rule you choose, not a fact the tool discovers. Sessions belong to the directory they ran in, so decide how to treat shared libraries, refactors that touch three repositories, and work done in a scratch folder. Pick one rule, write it down, and apply it every month.
The most defensible default is the repository at the session root, with a separate line for unassigned work. That leaves a visible bucket instead of hiding ambiguity inside a project, and it keeps month-over-month comparisons honest. See cost per developer for the same logic applied to people.
Questions, answered
How do I calculate AI cost per project?
Group sessions by working directory, sum tokens per model, apply current rates, then divide by completed tasks in that project.
Should plan fees be included?
Keep them separate. A plan fee is fixed regardless of project, while usage cost follows the work. Mixing them makes neither comparable.
Why is some usage unallocated?
Sessions without a recorded working directory cannot be attributed. Chat, setup work, and some tool modes fall into that bucket.