# Codex cost per project: how to measure it

> Source: <https://usageatlas.com/guides/codex-cost-per-project>
> Published: 2026-11-07 00:00:00+00:00

## Quick answer

Codex session files record the working directory, so cost per project is a two-step calculation: total tokens for that directory, then multiply by the rate for each token type. On a subscription the marginal cost is zero until you hit a limit, so value the tokens at API rates if you want a comparable number.

## Attribute sessions to a project

1. Open the session file and read the recorded working directory.
2. Group sessions by that path, not by the repository name; monorepos and worktrees share a name.
3. Total input, cached input, output, and reasoning separately.
4. Exclude sessions that only read a file from the project while working elsewhere.

Directory attribution is imperfect. A session that starts in one repo and edits another still belongs to the first. Note that when a project looks unusually expensive.

## Convert tokens to money

```
cost = input_tokens * input_rate
     + cached_tokens * cached_rate
     + output_tokens * output_rate
```

| Token type | Why it has its own rate | Common mistake | 
|---|---|---|
| Input | Fresh context sent to the model | Using output rate for everything | 
| Cached input | Discounted reuse of a stable prefix | Counting it as full input | 
| Output | Generated text | Forgetting reasoning tokens | 
| Reasoning | Billed with output, often shown apart | Double counting | 

Read the rates from the provider's current pricing page. Do not hard-code a rate you saw in a comparison post.

## Compare projects fairly

- Normalise by merged pull requests or shipped features, not by hours.
- Separate exploration from implementation on the first pass.
- Track the same project for a full week before ranking it.
- Record the model used; a model switch can double a line without any behaviour change.

[UsageAtlas](https://usageatlas.com/#download) keeps the directory and model fields together, which is enough to produce this table without a spreadsheet.

## Attribute sessions before you divide

Per-project cost only works if each session is attributed to one repository. Codex records the working directory per session, so the attribution is available; the mistake is dividing a monthly total by the number of projects you touched.

- Group sessions by working directory.
- Exclude sessions with no completed work.
- Keep shared setup work in its own bucket.
- Separate model cost from plan cost.

[UsageAtlas](https://usageatlas.com/#download) groups local sessions by project and shows the 30 or 90-day total, which is the number to divide. The formula is in [AI coding cost per project](https://usageatlas.com/guides/ai-coding-cost-per-project).

## Questions, answered

### Does Codex store the project name?

It stores the working directory. The project name is derived from that path, and a monorepo will collapse several projects into one.

### Is cost per project meaningful on a subscription?

Only as a shadow price. You do not pay per token until you exceed the allowance, but valuing usage at API rates shows which projects would be expensive if you did.

### Should I include cached tokens in project cost?

Yes, at the cached rate. They are still billed, just cheaper, and ignoring them understates the total.
