#3636th of 48 in Gateways and observability
cost-xray
Per-source token and cost breakdown of Claude Code and Codex API requests
- Stars
- 5.8k
- License
- MIT
- Last commit
- Nov 2026
- Language
- Python
0 on 2 Jun 20265,805 on 10 Nov 2026
From GitHub's daily star counts.
Checked on GitHub.
Overview
cost-xray captures the real API traffic from Claude Code and Codex through a local mitmproxy hop. It attributes tokens and dollars to system prompts, tool schemas, MCP servers and individual tool calls, split by cache read, write, fresh and output. Results are browsed in a terminal UI opened with `cx`, and raw traffic is redacted and deduplicated under ~/.cost-xray/.
Who it is for: Developers tracking what Claude Code and Codex send and what it costs
Strengths
- Reads raw requests, so system prompt and tool schemas are visible, unlike log-based usage tools
- Prices individual tool calls with cache read/write/fresh split and flags unused MCP servers
- Local only: binds to 127.0.0.1, no telemetry, secrets redacted before writing to disk
- Wrapper falls back to running the agent directly if the proxy is down
Weaknesses
- Only Claude Code and Codex supported; other agents need a new adapter module
- Claude per-source split is estimated via tiktoken calibration; only the total is exact
- Forward-only: past sessions are not captured, only runs started after install
- Codex capture needs a scoped local CA; installer runs via curl-pipe-bash, macOS/Linux only
What it needs
- no GPU
- Needs mitmproxy, Claude Code or Codex, systemd (optional, Linux)
- Models: Claude Code (Anthropic wire), Codex (OpenAI Responses wire)
Quick answers
Is cost-xray open source?
Yes. Its code is on GitHub under the MIT license.
Does cost-xray need a GPU?
No, it runs without one.
Also in Gateways and observability
See all 48| Rank | Project | Score |
|---|---|---|
| 1 | OmniRouteLLM gateway routing one OpenAI-compatible endpoint across 372 providers | 96 out of 100 |
| 2 | headroomCompresses tool outputs, logs and history before they reach the LLM | 92 out of 100 |
| 3 | new-apiGateway that unifies LLM providers behind OpenAI, Anthropic and Gemini APIs | 91 out of 100 |
| #4 | MLflowTracing, evaluation and prompt registry for LLM apps, plus ML tracking | 90 out of 100 |
| #5 | LiteLLMOpenAI-format gateway and Python SDK for calling 100+ LLM providers | 87 out of 100 |