Repolode
tigerless-labs

tigerless-labs/cost-xray

Local proxy that captures the raw API traffic of Claude Code and Codex and attributes token cost to each source in the request.

Stars
5,809
Forks
376
Open issues
35
Last commit
2 days ago

What is it?

cost-xray shows what an AI coding agent actually sends to the model API and what each part costs. Log-based usage tools only see totals after the fact, while cost-xray runs as a local capture hop, so it can see request-time context such as system prompts, tool schemas, MCP server blocks, tool results, cache reads and writes, and earlier thinking blocks.

Captured traffic is decoded and attributed back to its sources, down to individual tool calls. Each row splits cost into fresh input, cache read, cache write and output. A live TUI groups sessions by agent, project and session, and it also reports context-window occupancy and MCP servers or tools that are injected into requests but never called.

Capture runs on macOS or Linux and binds to 127.0.0.1 without sending telemetry. Credentials and secret-looking fields are redacted before anything is written to ~/.cost-xray/. Claude Code is captured through a base-URL override, while Codex uses a forward proxy with a scoped local CA trusted only by the codex command.

Key features

  • 01Captures raw Claude Code and Codex API requests through a local proxy without API keys or agent config changes.
  • 02Splits cost into fresh input, cache read, cache write and output for each source.
  • 03Attributes cost down to individual tool calls and MCP servers.
  • 04Shows context-window occupancy by system prompt, tool schemas, MCP blocks and messages.
  • 05Flags MCP servers and tools that are injected into every request but never called.
  • 06Redacts credentials before data is stored locally.

Use cases

  • Finding out why a coding-agent session is unexpectedly expensive.
  • Checking whether unused MCP servers or large tool schemas are bloating every request.
  • Confirming that prompt caching is hitting the stable prefix and spotting unexpected cache rewrites.
  • Auditing what context a coding agent sends to the model API, locally.

Quick start

  1. 1

    Confirm you are on macOS or Linux with Claude Code or Codex installed

  2. 2

    Run the official install script from the README

  3. 3

    Open a new terminal and launch the live TUI

    cx

Things to know

  • Runs only on macOS or Linux.
  • For Claude Code, the split of tokens between sources in a request is approximate, though the total cost is exact.
  • Codex capture uses a local certificate authority that is trusted only by the codex command.

In collections

Topics

FAQ

What is cost-xray?
Local proxy that captures the raw API traffic of Claude Code and Codex and attributes token cost to each source in the request. cost-xray shows what an AI coding agent actually sends to the model API and what each part costs. Log-based usage tools only see totals after the fact, while cost-xray runs as a local capture hop, so it can see request-time context such as system prompts, tool schemas, MCP server blocks, tool results, cache reads and writes, and earlier thinking blocks.
Is cost-xray free to use? What license does it have?
cost-xray is open source under the MIT license. Check the license terms before using it in commercial products.
Is cost-xray still maintained?
Actively maintained. The last commit to cost-xray was on Nov 5, 2026.
What can I use cost-xray for?
Finding out why a coding-agent session is unexpectedly expensive. Checking whether unused MCP servers or large tool schemas are bloating every request. Confirming that prompt caching is hitting the stable prefix and spotting unexpected cache rewrites. Auditing what context a coding agent sends to the model API, locally.
How do I install cost-xray?
Confirm you are on macOS or Linux with Claude Code or Codex installed Run the official install script from the README Open a new terminal and launch the live TUI: cx
Where can I get cost-xray?
The source code and installation instructions are on GitHub: https://github.com/tigerless-labs/cost-xray

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects