{"slug": "codex-cost-per-project-how-to-measure-it", "title": "Codex cost per project: how to measure it", "summary": "Codex session files record each session's working directory, so per-project cost can be calculated by grouping sessions by that path and multiplying input, cached input, output and reasoning tokens by their respective API rates, according to a UsageAtlas guide. The guide warns that directory attribution is imperfect — a session that starts in one repository and edits another still belongs to the first — and that on a subscription the marginal cost is zero until a limit is hit, so API rates serve only as a shadow price. It recommends normalizing cost by merged pull requests or shipped features rather than hours, tracking a project for a full week before ranking it, and recording the model used, since a model switch can double a line without any behavior change.", "body_md": "## Quick answer\n\nCodex 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.\n\n## Attribute sessions to a project\n\n1. Open the session file and read the recorded working directory.\n2. Group sessions by that path, not by the repository name; monorepos and worktrees share a name.\n3. Total input, cached input, output, and reasoning separately.\n4. Exclude sessions that only read a file from the project while working elsewhere.\n\nDirectory 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.\n\n## Convert tokens to money\n\n```\ncost = input_tokens * input_rate\n     + cached_tokens * cached_rate\n     + output_tokens * output_rate\n```\n\n| Token type | Why it has its own rate | Common mistake | \n|---|---|---|\n| Input | Fresh context sent to the model | Using output rate for everything | \n| Cached input | Discounted reuse of a stable prefix | Counting it as full input | \n| Output | Generated text | Forgetting reasoning tokens | \n| Reasoning | Billed with output, often shown apart | Double counting | \n\nRead the rates from the provider's current pricing page. Do not hard-code a rate you saw in a comparison post.\n\n## Compare projects fairly\n\n- Normalise by merged pull requests or shipped features, not by hours.\n- Separate exploration from implementation on the first pass.\n- Track the same project for a full week before ranking it.\n- Record the model used; a model switch can double a line without any behaviour change.\n\n[UsageAtlas](https://usageatlas.com/#download) keeps the directory and model fields together, which is enough to produce this table without a spreadsheet.\n\n## Attribute sessions before you divide\n\nPer-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.\n\n- Group sessions by working directory.\n- Exclude sessions with no completed work.\n- Keep shared setup work in its own bucket.\n- Separate model cost from plan cost.\n\n[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).\n\n## Questions, answered\n\n### Does Codex store the project name?\n\nIt stores the working directory. The project name is derived from that path, and a monorepo will collapse several projects into one.\n\n### Is cost per project meaningful on a subscription?\n\nOnly 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.\n\n### Should I include cached tokens in project cost?\n\nYes, at the cached rate. They are still billed, just cheaper, and ignoring them understates the total.", "url": "https://wpnews.pro/news/codex-cost-per-project-how-to-measure-it", "canonical_source": "https://usageatlas.com/guides/codex-cost-per-project", "published_at": "2026-11-07 00:00:00+00:00", "updated_at": "2026-11-09 19:28:07.771402+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-products"], "entities": ["Codex", "UsageAtlas"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/codex-cost-per-project-how-to-measure-it", "markdown": "https://wpnews.pro/news/codex-cost-per-project-how-to-measure-it.md", "text": "https://wpnews.pro/news/codex-cost-per-project-how-to-measure-it.txt", "jsonld": "https://wpnews.pro/news/codex-cost-per-project-how-to-measure-it.jsonld"}}