GUIDE

Track Your OpenAI Codex Usage and Cost (Codex CLI)

The OpenAI Codex CLI logs every token it spends on your own machine. This guide shows where those logs live, what they record, why the numbers look so big, and three ways to turn them into a clear picture of your usage and cost — all offline, without touching your code.

Last updated 15 July 2026

Short version: the Codex CLI keeps a local log of every session at ~/.codex/sessions/**/rollout-*.jsonl. Each turn records how many input, output, cached, and reasoning tokens it used, plus the model and a timestamp — never your source code. You can read those logs by hand, with a script, or with a visual desktop dashboard.

Which "Codex" this is

There are two things called Codex, and the confusion matters for what you are tracking. The original Codex was an OpenAI API model from 2021, now deprecated. Today's Codex is the Codex CLI — OpenAI's terminal coding agent, powered by the current GPT models. This guide is about the CLI: the tool you install and run in your terminal, which writes a usage log for every session. If you are watching your spend on the coding agent, that log is the source of truth.

Where the Codex CLI stores your usage logs

Codex writes one log file per session automatically — you don't have to enable anything:

PlatformLocation
macOS / Linux~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl
Windows%USERPROFILE%\.codex\sessions\YYYY\MM\DD\

Sessions are grouped into dated folders, one rollout-*.jsonl file per session. For comparison, Claude Code keeps the same kind of log at ~/.claude/projects/**/*.jsonl — which is why a single tool can total both.

What the logs record — and what they don't

Each line is one event. The events that matter for usage are the periodic token-count events, which carry the running token totals for the turn. From them you can read:

  • Token counts, split into input, output, cached input, and reasoning tokens
  • The GPT model that answered the turn
  • Timestamps and a session id
  • But not your source-code files, and not the meaning of your prompts

The raw files do contain message text, because they are a full session transcript. But to total your spend you only need the token and model fields — and a good tracker reads only those. Token Forest, for example, takes just the counts, the model name, and the timestamp; it never copies your prompts or code into its own data, and never uploads anything.

Why Codex token counts look huge

Two classes inflate the raw number without inflating the bill by the same amount. Cached input tokens are context the model re-reads across a session; they are billed far below full input rate. Reasoning tokens are the model's internal thinking. Both can dwarf the visible input and output, so a raw total is easy to be alarmed by.

Judge your spend by estimated cost, not by the raw token total. A number in the billions is normal and does not mean a bill in the same order of magnitude — most of it is cached context re-read at a fraction of the price.

Three ways to see your Codex cost

1. Read the logs by hand

  1. Open ~/.codex/sessions/ and pick a dated folder, then a rollout-*.jsonl file.
  2. Open it in a text editor. Every line is one JSON event; look for the token-count events that hold the running totals.
  3. Multiply the token counts by your model's per-token rates to estimate the cost. Tedious, but it works with zero extra tools.

2. Use a command-line tool

A CLI can parse the logs and print a total. This is fast and scriptable, but it lives in the terminal, shows a snapshot rather than something always-on, and you still map tokens to prices yourself unless the tool bundles a price table.

3. Use an offline desktop dashboard

Token Forest reads the same Codex logs (and Claude Code's) and turns them into an always-on picture: growth over time, per-model usage, a multi-week heatmap, and an offline cost estimate with a bundled, updatable price table. It runs on Windows and macOS, works fully offline, and reads only the token counts and metadata described above — never your code.

Track Codex and Claude Code side by side

If you use both agents, you don't want two separate tallies. Token Forest counts Codex and Claude Code together into one total, and colours the live token bubbles by source — Claude Code in orange, Codex in blue-purple — so you can see at a glance where the spend is going. It is an independent tool, not a front-end for any single CLI, and it shares no code with them.

Frequently asked questions

Is the Codex CLI the same as the old OpenAI Codex model?

No. The 2021 Codex API model is deprecated. Today's Codex is the Codex CLI, OpenAI's terminal coding agent running on current GPT models. This guide, and Token Forest, are about the CLI's usage.

Where does the Codex CLI store its usage logs?

At ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl (on Windows, under %USERPROFILE%\.codex\sessions\). One file per session, grouped into dated folders.

How much does the Codex CLI cost?

It depends on the model and how many tokens each turn spends. The logs record the token counts; multiply them by the model's rates for an estimate. Note that cached and reasoning tokens inflate the raw count well beyond the actual bill, so judge cost by the estimate, not the raw total.

Does a usage tracker read my code when it tracks Codex?

It doesn't have to. The token totals live in metadata fields, so a tracker only needs those. Token Forest reads only the counts, the model name, and the timestamp; it never copies your prompts or code, and never uploads anything.

Can I track Codex and Claude Code in one place?

Yes. Token Forest reads both logs and combines them into a single running total and dashboard, with the live token bubbles colour-coded by source so you can tell the two apart.

See your Codex usage grow into a tree

Token Forest turns the Codex and Claude Code tokens you spend into a living pixel tree, with an offline cost dashboard behind it. Free, local-first, Windows and macOS.