Cost-xray: Seeing What My AI Coding Agent Actually Sends to the API
Description and use
cost-xray gives developers insight into which parts of AI coding agent requests consume tokens and cost money, enabling detailed analysis and optimization.
Problem
Developers lack visibility into the detailed cost drivers of AI coding agents, seeing only total session cost without knowing which parts of the request consume tokens and money.
Outcome
cost-xray provides fine-grained visibility into AI coding agent request traffic, enabling developers to pinpoint cost drivers, optimize prompts and tool usage, and reduce unnecessary token consumption.
Workflow
- Install cost-xray via one-line installer
- Select target agent (Claude Code, Codex, or both) during setup
- Run your coding agent normally (e.g., codex or claude)
- After coding, launch the dashboard with
cx - Navigate the dashboard: agent → project → session → category → MCP server → tool → per-turn call
- Review detailed views to see context-window occupancy and per-source cost
- Use insights to optimize agent configuration (remove unused schemas, adjust caching, limit tool outputs)
Evidence
cost-xray is a local tool for inspecting AI coding-agent requests.
The capture layer uses mitmproxy as a local hop. It records redacted request and response data under ~/.cost-xray/.
After that, open a new terminal and use your agent normally: codex or claude, then open the dashboard: cx
- Record date: 2026-09-05T14:20:35.736Z