cost-xray

Cost Xray shows what Claude Code and Codex send to the API, how much context each source uses, and what every part costs.

See the system prompt, tool schemas, MCP servers, messages, cache activity, tool results, and model output behind each request.

Token and dollar totals for every session, organized by agent and project.

cost-xray Home: every captured session grouped by agent, project, session

Drill a session

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

cost-xray Detail: context-window occupancy and cumulative per-source cost

Go beyond session totals

Most usage tools read local logs. They can show what a session cost, but not everything assembled before the API call.

SystemWhat it answers
Usage logsHow much did the session cost?
Agent transcriptsWhat happened during the session?
Cost XrayWhat did the model receive, and what made it expensive?

Cost Xray captures the actual local API traffic, then traces tokens and cost back to the source that caused them.

How it works

Cost Xray runs mitmproxy as a local capture hop and keeps all analysis off the request path: agent traffic passes through the local proxy on its way to the model API, redacted raw requests and responses land under ~/.cost-xray/sessions/, and a separate materializer turns them into the TUI and cost attribution.

Capture.

A transparent local hop — no API keys, no account, no config changes to your agent. The wrapper self-heals: if the proxy is down, the agent runs direct — capture never breaks your agent.

Local & private.

The proxy binds to 127.0.0.1 and sends no telemetry. Keys, cookies, and secret-looking fields are redacted before anything hits disk. Everything stays under \~/.cost-xray/.

Off the hot path.

The proxy only writes redacted bytes; a separate materializer tokenizes and prices later, so analysis never steals latency from live relay.

Get Started

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

Then open a new terminal and run claude / codex exactly as before — capture is automatic, no flags and no base-URL change.

Open the live TUI from anywhere:

cx

In the TUI, drill from the top down:

  1. agent
  2. project
  3. session
  4. category
  5. MCP server
  6. tool
  7. per-turn call
  8. the real output.

Pause anytime with cx stop.

More in the works — built in the open, shipped fast.

Explore Tigerless Labs