cost-xray CLI
Shows what Claude Code and Codex actually send to the API: it captures local traffic and splits tokens and cost by source
- 4,696 ★ on the repository
- Last commit
- MIT
Broad access
Why this level
- Intercepts all of the agent's API traffic, including prompts and file contents
- Runs as a background service with autostart
- Installing by an internet script runs someone else's code
Install
- Works in
Manual install
curl -fsSL https://raw.githubusercontent.com/tigerless-labs/cost-xray/master/install.sh | bashA script from the internet: read it before running. Then open a new terminal and run claude or codex as usual.
Access and checks
How we reviewBroad accessThe tool can change data, run commands or handle secrets.
- Intercepts all of the agent's API traffic, including prompts and file contents
- Runs as a background service with autostart
- Installing by an internet script runs someone else's code
This is third-party code. Review the repository files before installing.
What it does
cost-xray captures the agent's local API traffic through mitmproxy and splits tokens and cost by source inside a request: system prompts, tool schemas, MCP blocks and tool results. You view the result in the `cx` panel. No API keys or account are needed, and the agent's settings do not change: capture runs as a transparent local proxy. It runs as a background service with autostart on macOS and Linux. Only new sessions are captured: already running ones are not visible.
Who it is for. For people who pay for Claude Code or Codex and want to understand where tokens go: into extra tool schemas, long system prompts or command results.
Good fit when
- The agent bill grew and you need to find which part of a request costs the most
- You need to check how many tokens the connected MCP servers eat
- You need to compare the cost of different sessions by source
Not a fit when
- You cannot route the agent's traffic through a local proxy: the utility sees the whole request
- You work on Windows: the README names macOS and Linux
Example request
Show which part of the latest Claude Code request went to MCP server schemas and calculate what that costs per dayLimitations
The utility intercepts all of the agent's API traffic, including prompts and file contents that go into requests. Per the README the data is stored locally, but check this yourself. Installing with `curl ... | bash` runs a script from the internet: read it before running. The script asks which agents to capture, and you can answer in advance with the `COST_XRAY_AGENTS` variable (claude, codex or all). After installation open a new terminal and run the agent as usual. Claude Code or Codex and macOS or Linux are required.
How to disable. Stop the cost-xray background service, remove autostart and the utility files per the README instructions, then open a new terminal.
FAQ
What does cost-xray do?
It captures the local API traffic of Claude Code and Codex and splits tokens and cost by source inside a request.
Are keys or an account needed?
No, API keys and an account are not needed and the agent's settings do not change.
Does the utility see my prompts?
Yes, it intercepts all of the agent's traffic. Per the README the data is stored locally, but check this yourself.
Are already running sessions captured?
No, only new ones: open a new terminal after installation.
Discussion
No questions or reviews yet.
Related
CLI toolsTokscale
tokscale
A CLI with an interactive TUI that tracks token usage and cost across AI coding agents: Claude Code, Codex, Copilot, Cursor and more
A self-hosted control center for coding agents: Claude Code, Codex, Copilot, OpenCode and Pi from your phone, desktop and terminal
Token Optimizer
token-optimizer
A plugin for Claude Code and Codex: trims wasted tokens, keeps work alive across sessions and compactions and shows cost. The license is noncommercial
A native macOS terminal built on Ghostty with vertical tabs and notifications when an agent needs your input
Token Monitor
token-monitor
A desktop widget for tracking tokens, cost and limits across 43 or more tools: Claude Code, Codex, Cursor, OpenRouter and others, for Windows and macOS
OpenTelemetry-based CLI tracing for Claude Code, Cursor and Codex sessions, showing what the agent actually did and what it cost
Comparison with similar tools
Entries that share the main search query, and how they differ.
| Entry | Official | Repository stars | Main difference |
|---|---|---|---|
| cost-xray (this entry) | no | 4,696 | |
| Token Optimizer | no | 2,541 | a plugin that trims wasted tokens and keeps work across sessions |
| Token Monitor | no | 2,949 | a desktop widget tracking tokens, cost and limits for many tools |
| Claude Usage | no | 2,266 | a local dashboard over Claude Code logs: tokens, models, sessions and projects |
README in short
The README describes a utility that captures the local API traffic of Claude Code and Codex through mitmproxy and shows a token and cost breakdown in the cx panel. Installation by script, run as a service, macOS and Linux only. MIT license.