tigerless-labs /cost-xray

See what Claude Code and Codex actually send to the API — and what each part costs.

★ 5,807⑂ 377👁 214⑃ 52● 11▤ 0
PythonMITCreated 2026-06-06
More from this author
+1
Daily
5,807
stars
377
forks
214
watchers
52
prs
11
issues
0
releases

README

cost-xray

See what your AI coding agent actually sends to the API — and what each part costs.


     


Most usage tools read local logs. That shows the total cost of a call or session, but it misses the request-time context assembled before the model is invoked: system prompts, tool schemas, MCP blocks, tool results, cache reads/writes, and previous thinking blocks.

cost-xray captures the actual local API traffic for Claude Code and Codex, then attributes tokens and dollars back to the sources inside the request. It shows not just how much a turn cost, but why it cost that much.



Home — every session by agent · project · session, with token and dollar totals

Drill a session — context-window occupancy (top) and per-source cost, down to each MCP server (bottom)




 Requirements

- A supported coding agent — Claude Code or Codex
- macOS or Linux
- No API keys, no account, no config changes to your agent — capture is a transparent local hop

 Install

bash
curl -fsSL https://raw.githubusercontent.com/tigerless-labs/cost-xray/master/install.sh | bash


The installer asks which agent(s) to capture — Claude Code, Codex, or both — and prompts even under curl … | bash.

- Skip the prompt (e.g. CI): set COST_XRAY_AGENTS=claude|codex|all.
- Already cloned the repo? Run ./install.sh.

Then open a new terminal and run claude / codex exactly as before — capture is automatic, no flags and no base-URL change. It's forward-only: runs started in that new shell are captured, not past history. Open the live TUI from anywhere:

bash
cx


Capture runs as a background service (auto-start on boot, self-healing, port-adaptive) and doesn't change what your agent does, its results, or its cost — pause anytime with cx stop. See docs/install.md for systemd details, GUI agents (Cursor base-URL setup), manual (no-systemd) mode, and troubleshooting.

 Usage

bash
cx                   open the live cost-xray TUI (from any directory)
cx status            services' state, live ports, sessions captured
cx stop              stop monitoring — proxies down; agents run direct (uncaptured)
cx start             resume monitoring
cx restart           restart the proxies (after a config change)
cx install           (re)install — authoritative: installs the chosen agents, removes the rest
cx uninstall         remove services + shell wrappers (keeps captured data)


cx is the whole CLI and works from any directory. Change port/upstream by editing ~/.cost-xray/env, then cx restart. (./run.sh  from the repo still works too — cx just calls it for you from anywhere.)

In the TUI, drill from the top down: agent → project → session → category → MCP server → tool → per-turn call → the real output. Every cell carries its cache split (read / write / fresh / output $).

 Supported Agents

| Agent | Status | Capture |
|-------|--------|---------|
| Claude Code | Supported | reverse proxy (base-URL override) — no certificate |
| Codex | Supported | forward proxy + scoped local CA (self-healing wr

Top issues

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON