Skip to main content

SessionCost

See how many tokens each turn of your coding-agent chat sends, why, and what to cut.

Every message you send makes the agent send the whole conversation again, plus its setup, plus whatever it read. Type /sessioncost in a chat and see, for each of your messages, how many tokens went out and what they were, the heaviest turn, and the fixes that would have sent fewer, measured from that chat. Fewer tokens is what makes an agent cheaper and faster, so the cost is shown too, as the result. It works in Claude Code, Codex, Cursor and Antigravity, runs on your computer, and sends nothing anywhere.

Get it

Works with Claude Code, Codex, Cursor and Antigravity. You don't need Python or Git: the installer brings what it needs.

1. Open a terminal

  • Windows: press the Windows key, type powershell, press Enter.
  • Mac: press Cmd + Space, type terminal, press Enter.

2. Paste this line and press Enter

Your computer Paste this
Windows irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 | iex
Mac or Linux curl -fsSL https://raw.githubusercontent.com/kish21/sessioncost/main/install.sh | sh

Wait about a minute. It ends with a line like Claude Code /sessioncost added for each agent it found.

3. Restart your agent, and type /sessioncost in any chat

To update later, paste the same line again.

Already have Git and Python? Install it as a Claude Code plugin instead

In a Claude Code chat:

/plugin marketplace add kish21/sessioncost
/plugin install sessioncost@sessioncost

(Or Manage Plugins → Marketplaces, add kish21/sessioncost, then install sessioncost from the Plugins tab.) Claude Code downloads plugins with Git, so this needs Git, and SessionCost needs Python 3.10 or newer. If the plugin says "git not found", use the line above instead.

What you get

A short summary in the chat:

SessionCost: Add a CSV export to the reports page
1.9M tokens sent, 24k written · 5 turns · 31 calls · 22 min working, 6.0 min waiting for you
Heaviest turn: #3 “now add tests” · 910k tokens sent (48%) · $1.12
Top fix: Turn off tools this session never used · 420k fewer tokens sent · saves $0.214 (measured from this session)
Cost: $2.31 exact (API prices 2026-10-08)
Report: ~/.sessioncost/reports/<session-id>.html

(The numbers above are an example.) Say yes when it offers to open the report: a page in your browser with

  • Turn by turn: one row per thing you asked, with the tokens it sent and wrote, its calls and minutes, and its cost. Click a turn to see its calls, and a call to see what it sent (fixed setup, carried history, new input) and what it wrote. Every set of parts adds up to the number above it.
  • Replay: step or play through the chat call by call and watch the context grow.
  • Where the tokens went: by kind of step (reading, running commands, writing files, helpers...) and by kind of token.
  • What to fix: the fixes that apply to this chat, each with the tokens it would cut and the money that saves.
  • Sent with every call: the agent's fixed setup, and which tools were never used.

Asking costs almost nothing: the agent runs the tool and shows its summary, and never reads the log or the report into the chat.

Updating

How you installed it How to update
The one line above Paste the same line again, then restart your agent.
Claude Code plugin /plugin → Marketplaces → sessioncost → Update (or type /plugin marketplace update sessioncost, then /plugin update sessioncost@sessioncost), then restart Claude Code. You can also turn on auto-update for this marketplace there.
pip pip install -U sessioncost, then sessioncost setup.

Old reports

Each chat keeps one report in ~/.sessioncost/reports/ (a few hundred KB each). When more than 10 older ones pile up, the summary says so. Type /sessioncost clean in a chat, or sessioncost clean in a terminal, to delete all of them except the latest. Nothing is ever deleted unless you ask.

If something goes wrong

  • /sessioncost does nothing: restart the agent after installing.
  • Two /sessioncost in Claude Code (the plugin and the one-line install): run sessioncost setup again; with the plugin installed it removes the extra copy.
  • "git not found" when adding the plugin: use the one-line install instead; it needs neither Git nor Python.
  • "Python is not found" with the Claude Code plugin: paste the one line for your computer from above.
  • Windows says running scripts is disabled: run the line as powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 | iex".
  • Already have Python and prefer pip: pip install sessioncost, then python -m sessioncost setup.

Which agents, and how exact

Agent Where its log is Tokens
Claude Code ~/.claude/projects/<project>/<session>.jsonl exact, from the log
Codex (CLI, IDE, app) ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl exact, from the log
Antigravity ~/.gemini/antigravity-ide/conversations/<id>.db exact, from the log
Cursor Cursor's User/globalStorage/state.vscdb estimated from text size; exact with your usage export

Cursor keeps no token counts on your computer. SessionCost rebuilds each call from the chat's messages, estimates its size from the text (characters / 4), and scales it so the last call matches the context size Cursor itself recorded. For exact numbers, download your usage export from the Cursor dashboard and pass it with --cursor-usage file.csv.

From a terminal

After the one-line install, sessioncost also works in a terminal, from your project folder, and costs zero tokens:

sessioncost                    # the newest chat of this folder's project (same as: sessioncost last)
sessioncost list               # recent chats: date, id, cost, turns, calls, first message
sessioncost 3f2a9c1e           # one chat, by the first characters of its id
sessioncost path/to/session.jsonl   # or an Antigravity .db
sessioncost 3f2a9c1e --cursor-usage usage-events.csv   # a Cursor chat, with exact tokens from your export
sessioncost setup              # add /sessioncost to your agents again
sessioncost clean              # delete all saved reports except the latest

Options: --project <dir> (another project folder), --no-open (write the report, do not open it), --json (print the full model as JSON), --prices <file>, --subscription (see below), --cursor-usage <file.csv>.

last and list look at every agent above for the project folder. last picks the chat whose last logged message is newest, not the newest file: reopening an old chat touches its file but does not make it the latest.

Privacy

Local only. SessionCost reads log files on your disk and writes one HTML file to ~/.sessioncost/reports/. It sends nothing anywhere, calls no AI model and needs no network. The report page loads a web font from Google Fonts when you are online and falls back to system fonts when you are not.

How money is labelled

Every token class is priced on its own: new input, input written to the cache (5-minute and 1-hour rates differ), input re-read from the cache, and output (the model's writing, hidden thinking included). Each model call is counted once, even though the log writes one reply as several rows.

  • exact (API prices as of ): every model in the session has a checked rate in the price table. The figure is what the same tokens cost on the public API on that date.
  • estimate: at least one model has no checked rate (the OpenAI and Gemini rates are from third-party price lists, not yet checked against the providers' own pages), or the tokens themselves are estimated (Cursor without its usage export).
  • API-equivalent: with --subscription, and always for Antigravity. On a plan that is not billed per token (Claude Pro or Max, a ChatGPT plan, Antigravity) the figure is what the same work would cost at API prices.

When the log carries the agent's own running total (Claude Code), or you give Cursor's usage export with its cost column, the report shows it as a cross-check.

Prices live in sessioncost/prices.json (USD per million tokens). Override any model in ~/.sessioncost/prices.json (merged over the built-in table) or pass --prices <file>.

Sizes the log does not give directly (how much of a call's input was the fixed setup, how much of its output was a file rather than a message) are estimated from the text (characters / 4) and scaled so the parts add up exactly to the token counts in the log. They are marked "~ estimated" on the page.

The built-in fixes

Three simple checks. Each one shows the tokens it would cut and what they cost, in this session.

  1. Tools never used, sent with every call. Tool definitions travel with every model call. The saving is what the unused ones cost across the session's calls.
  2. The same unchanged file read again. A read that returned exactly the same text as an earlier read in the same chat. The saving is what that copy cost when it came in, plus on every later call that carried it.
  3. A confirm-only stop. You typed only "yes", "ok", "save" or "go" (or picked such an answer on a question card), and the agent had stopped just to ask. The saving is the cost of re-sending the conversation to receive that answer.

Roadmap

  • Compare two sessions of the same task side by side.
  • An optional fix engine with more checks.

Status: early. MIT license.

Metadata

Release files for sessioncost 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sessioncost 0.3.1
File Size Uploaded Provenance
sessioncost-0.3.1.tar.gz 86.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sessioncost 0.3.1
File Interpreter ABI Platform
sessioncost-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 178.8 kB

Release files / sessioncost-0.3.1.tar.gz

Download URL sessioncost-0.3.1.tar.gz
Size 86.2 kB
Tags Source
SHA-256 checksum
How to use checksums
dd9665ae31144e7a227fccb6cf6ef5ec53825ed480081d432ec9793cb949c829
BLAKE2b-256 checksum
How to use checksums
fe33820ba2a3c28288e8d7e1e7c7b9234602f757e3b39987a88c44a231a553f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / sessioncost-0.3.1-py3-none-any.whl

Download URL sessioncost-0.3.1-py3-none-any.whl
Size 92.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8cd00a693a4ac774e1d88085388fa13b497f81b965530e58acabd5ad6c6bd29c
BLAKE2b-256 checksum
How to use checksums
7a4992d37c87e6b1c87aead1031e88135340c5a16e97cd13dd2d42d4177a6073
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for sessioncost 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page