What your Codex use would cost on the API

One command adds up the tokens in your Codex CLI session logs and prices them at OpenAI's API list prices: today, the last 7 and 30 days, all time, and by model.

Run this in a terminal

macOS and Linux

curl -fsSLo codex-spend.mjs https://github.com/shurikenharness/codex-spend/releases/download/v1.0.1/codex-spend.mjs && openssl dgst -sha256 -r codex-spend.mjs | grep -q ^6426084dbef25502b909e014672b5f4ecc13eab2e53d87be0d6cd10fddb5a8b1 && node codex-spend.mjs

It downloads codex-spend.mjs v1.0.1 from GitHub and runs it with Node.js 18 or later, only if its SHA-256 matches.

Read it first

Download the file, check that its SHA-256 is the one in the command above, read it, then run it:

curl -fsSLo codex-spend.mjs https://github.com/shurikenharness/codex-spend/releases/download/v1.0.1/codex-spend.mjs
openssl dgst -sha256 -r codex-spend.mjs
less codex-spend.mjs
node codex-spend.mjs

Windows

irm "https://github.com/shurikenharness/codex-spend/releases/download/v1.0.1/codex-spend.mjs" -OutFile codex-spend.mjs; if ((Get-FileHash codex-spend.mjs).Hash -eq '6426084dbef25502b909e014672b5f4ecc13eab2e53d87be0d6cd10fddb5a8b1') { node codex-spend.mjs } else { 'codex-spend.mjs does not match its SHA-256, so it was not run.' }

It downloads codex-spend.mjs v1.0.1 from GitHub and runs it with Node.js 18 or later, only if its SHA-256 matches.

Read it first

Download the file, check that its SHA-256 is the one in the command above, read it, then run it:

irm "https://github.com/shurikenharness/codex-spend/releases/download/v1.0.1/codex-spend.mjs" -OutFile codex-spend.mjs
Get-FileHash codex-spend.mjs
notepad codex-spend.mjs
node codex-spend.mjs

Or with npx (no checksum step):

npx github:shurikenharness/codex-spend#v1.0.1

codex-spend.mjs v1.0.1 · SHA-256 6426084dbef25502b909e014672b5f4ecc13eab2e53d87be0d6cd10fddb5a8b1

Read the source on GitHub · Release v1.0.1

Nothing leaves your computer

It reads the session logs Codex keeps in ~/.codex/sessions, prints the totals and exits. It makes no network calls, uploads nothing and writes no files.

Several accounts? Shuriken tracks them all. See how

What it reads

  • The model of each turn
  • Token counts: input, cached input, output
  • The time of each request

What it never shows

  • Your prompts or the replies
  • File paths, folder names or project names
  • Tool calls, code or command output
  • Your sign-in, API keys or settings

What it prints

Made-up numbers. Yours come from your own logs.

Codex spend on this computer (API-equivalent estimate)

                      Cost    Tokens     Calls
Today               $10.21       22M       125
Last 7 days         $79.12      174M       968
Last 30 days       $219.50      482M     2,686
All time           $255.23      560M     3,123

By model, all time                    Cost   Input  Output  Cached    Calls
gpt-6.1-sol                        $188.40   41.0M    2.9M  220.4M    2,310
gpt-5.5                             $64.75    6.2M  780.0K   48.1M      612
gpt-5.4-mini                         $2.08    1.1M  190.0K    9.4M      201

Several accounts? Shuriken tracks them all → shuriken.sh

Questions

Is this what I paid?

No. It is what the same tokens would cost at the API list prices. A ChatGPT plan has a fixed monthly price, so the number shows how much work went through it, priced as if you had paid per token.

What does it read?

The session logs the Codex CLI writes to ~/.codex/sessions and ~/.codex/archived_sessions (or CODEX_HOME, or the folder you name with --dir). From each request it keeps the model name, the token counts and the time. It never prints a prompt, a reply or a file path.

What does it send?

Nothing. It reads the files on your computer, prints the totals and exits. It makes no network calls, uploads nothing and writes no files; the tests check its source for all three.

Which prices does it use?

OpenAI's Standard-tier API list prices on the date printed under the totals, with cached input priced apart and long-context prices for requests over 272,000 input tokens. A Codex model the price page no longer lists is priced as the listed model it was sold at, and the output says so.

I use several accounts. Does it count them all?

It reads the logs on this computer, which belong to the account you use here. Shuriken tracks the usage and limits of all your accounts and API keys in one place.

Provided by Shuriken