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
- The answer first: the tokens sent now and after the fixes, and the biggest fixes, ranked by the money they save.
- The path: Step 0 (the agent's setup, sent with every call), then every turn as a tile on one path. Tap a turn to see its calls as tiles of their own, and a call to see what it sent (setup, earlier conversation, new) and what it wrote. Every set of parts adds up to the number above it.
- Charts: how each kind of token is priced, how the memory sent grows call by call and how much of it was cheap re-reading from the cache, where each fix helps (tokens, money, time), and what the agent spent its tokens on.
- What to fix: the fixes that apply to this chat, each with the tokens it would cut, the money that saves, and a line to paste into your agent's instruction file.
The earlier report design is still there: sessioncost --design classic.
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
/sessioncostdoes nothing: restart the agent after installing.- Two
/sessioncostin Claude Code (the plugin and the one-line install): runsessioncost setupagain; 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, thenpython -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 one exception is opt-in: if you point it at a
fix engine with --engine-url, the report offers a button that sends a summary of the session, numbers and tool
names only, never your messages, code or file names, and only when you press it.) 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.
- 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.
- 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.
- 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.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sessioncost-0.4.1.tar.gz | 135.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sessioncost-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 278.5 kB
Release files / sessioncost-0.4.1.tar.gz
| Download URL | sessioncost-0.4.1.tar.gz |
|---|---|
| Size | 135.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7698b9b581e3a6188ae9caa7892ac0c3f0e0a83f35c65bbd62876669ed53c00
|
|
BLAKE2b-256 checksum How to use checksums |
463f00f2a750efb97d4e3d0a8c14267ed082cdb328d8767fbe01acb61a1243b5
|
| 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.4.1-py3-none-any.whl
| Download URL | sessioncost-0.4.1-py3-none-any.whl |
|---|---|
| Size | 143.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6eaf669de4808461286743c893de29ac40dab937930ad12d4c7ef6eaa84ae43c
|
|
BLAKE2b-256 checksum How to use checksums |
23473b512eac8d2b713bd7bbc3fd289fe336e660c82b5d7bdc3da5bddfa8c958
|
| 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.4.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.