tigerless-labs/cost-xray
Local proxy for tracing coding-agent context, cache usage, and API cost
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
cost-xray sits between a coding agent and its model API. Claude Code uses a reverse proxy via a base-URL override and needs no local CA. Codex uses a forward proxy with a local CA scoped to the wrapped command rather than installed in the system trust store. Thin per-agent adapters handle the Anthropic and OpenAI Responses wire formats; capture and analysis share the rest of the pipeline.
The Python stack uses mitmproxy (>=10) for capture, tiktoken (>=0.7) for token estimation, and Rich (>=13) for terminal rendering. The proxy binds to 127.0.0.1, redacts traffic before writing to ~/.cost-xray/sessions/, and leaves tokenization and pricing to a separate materializer. Captured records are the source for rebuilding views: repeated blocks are stored once and per-turn deltas reconstruct the redacted exchanges.
Key Capabilities & Differentiators
The terminal UI drills from agent, project, and session into source category, MCP server, tool, individual invocation, and captured result. It separates fresh input, cache reads, cache writes, and output costs while also showing context occupancy. That distinction matters: a cached schema can be cheap to read yet still consume a large share of the window. The tool flags schemas injected into the prefix whose tools were never called in the observed session.
For Claude, tiktoken provides initial sizes, with targeted corrections for thinking blocks and tool schemas. Those corrections use count_tokens when authenticated and fixed ratios otherwise; the estimates are reconciled to provider-reported usage. Pricing uses LiteLLM data. Provider counts anchor the request total, but the allocation among sources remains approximate. Full count_tokens differencing is planned, not a current feature.
Trade-offs & Limitations
Compared with ccusage or codeburn, cost-xray trades transcript-only setup and historical coverage for visibility into fields assembled at request time. It can expose system prompts, injected schemas, and cache behavior that transcripts miss, but it cannot backfill uncaptured sessions. The wrapper attempts to recover a failed proxy and falls back to a direct connection when it cannot: the agent keeps working, but the capture can have gaps.
Loopback binding, pre-write redaction, and no telemetry reduce exposure without making captured content harmless. Prompts and tool results can still contain source code or sensitive text, and cx uninstall retains the archive. For team use, define access and retention for local captures. Keeping analysis off the relay path also does not eliminate the proxy hop or capture writes, and calibrated Claude source splits are diagnostic estimates rather than invoice line items.
Hardware & Deployment Guide
Run it self-hosted on macOS or Linux with Python 3.10+ and an existing Claude Code or Codex installation. A checkout includes install.sh; the installer can select either agent or both, with COST_XRAY_AGENTS=claude|codex|all for unattended selection. Open a new terminal after setup, launch the agent normally, then use cx for the live TUI. The observer needs no separate account or API key; the agent still uses its normal upstream credentials and connection.
Use cx status to check service state, ports, and session counts; cx stop pauses capture, and cx start resumes it. Edit ~/.cost-xray/env and run cx restart to change port or upstream settings. Linux setup covers systemd and a manual path. No GPU is needed; size CPU and disk for tokenization and retained captures. Package metadata lists version 0.1.0 as beta, with no tagged release listed.
Claude Code or Codex users tuning MCP configuration, investigating context pressure, or tracing costs to a particular schema or tool result.
You only need historical spend rollups, cannot retain request content or use Codex's scoped CA, or require exact per-source Claude billing.
Quick Start & Installation
curl -fsSL https://raw.githubusercontent.com/tigerless-labs/cost-xray/master/install.sh | bash
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| cost-xray ★ | 5.4k | +209 | Python | MIT | Local proxy for tracing coding-agent context, cache usage, and API cost |
| cc-switch | 159.1k | +1.7k | Rust | MIT | Tauri desktop manager for AI coding providers, local routing, and MCP config |
| herdr | 54.1k | +871 | Rust | Apache-2.0 | Rust terminal multiplexer for persistent, multi-machine coding-agent workspaces |
| claude-code-router | 38.5k | +101 | TypeScript | MIT | Local model gateway for routing coding agents across providers |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/tigerless-labs/cost-xray.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about cost-xray
How does cost-xray integrate with Claude Code and Codex?
Does it need a GPU, and what drives local resource usage?
Can a company self-host it, and what data controls are still needed?
When is cost-xray a better fit than ccusage or codeburn?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy