I spent about three months last year throwing API calls at various AI models without the faintest idea how many tokens I was actually burning through. I knew roughly what my monthly bill looked like — the credit card statement is hard to miss — but I had zero visibility into which conversations, which tools, which coding sessions were eating up the budget. Was it the lengthy code reviews? The multi-file refactors? The one time I asked Claude to explain the entire Linux kernel memory manager from scratch?
I honestly couldn’t tell you.
That kind of blind spot is surprisingly common. Most developers I know treat their AI API spend like a black box — you put money in, you get intelligence out, and you only look at the bill when it hurts. But if you’re using AI coding tools seriously — whether it’s Claude Code, Cursor, Copilot, or plain SDK calls — understanding your token usage isn’t just about budgeting. It’s about efficiency, prompt design, tool selection, and sometimes even security.
That’s where Rekon comes in. It’s an open-source transparent proxy for the Anthropic and OpenAI APIs that records every request’s token usage and shows you exactly where your tokens are going — per conversation, per tool, per session. And the best part? You can start using it in about ten seconds.
What Is Rekon?
Rekon — also called the Token Profiler — is a lightweight proxy that sits between your AI client and the API provider. Every request passes through it untouched, and on the way back, it records the token counts, reconstructs the conversation session, estimates the cost, and attributes it to specific tools.
It’s built on Cloudflare Workers and D1 (their serverless SQLite database), with a React dashboard for the frontend. The code is fully open source under Apache 2.0, and there’s a hosted instance running at tryrekon.com if you just want to try it out.
The key design decisions are worth highlighting because they tell you a lot about what this tool is built for:
- Zero added latency. The proxy streams the response straight through to your client and records usage off the critical path using Cloudflare’s
ctx.waitUntil(). You don’t feel the profiling at all. - Your API keys never touch the server. Auth headers are forwarded as-is, never stored. Your usage is always billed to your own key or subscription.
- Session trees, not flat logs. The chat APIs are stateless — no conversation ID comes back from the provider. Rekon reconstructs each conversation from client signals, including forks and side conversations.
- Tool-level attribution. You can see exactly which tools within a conversation burned the most tokens.

Getting Started: The Ten-Second Setup
The quickest way to see Rekon in action is through the hosted instance. No signup required, no installation, nothing to download.
- Open tryrekon.com in your browser.
- The landing page gives you a generated proxy URL that looks like
https://tryrekon.com/s/a1b2c3d4-.... That URL is your personal ingest endpoint. - Set one environment variable:
export ANTHROPIC_BASE_URL=https://tryrekon.com/s/your-system-id(orOPENAI_BASE_URLwith the/openai/v1suffix). - Run
claudeor your AI client as usual. - Open the dashboard and watch usage appear in real time.
That’s genuinely it. No config files, no credentials to manage, no proxies to start and stop. The system ID in the URL doubles as an ingest key — unknown IDs are rejected, so your deployment isn’t accidentally an open relay.
# For Claude Code or any Anthropic SDK client
export ANTHROPIC_BASE_URL=https://tryrekon.com/s/8c911b77-3327-45a0-b9d1-ff399f40592b
claude
# For OpenAI clients
export OPENAI_BASE_URL=https://tryrekon.com/s/8c911b77-3327-45a0-b9d1-ff399f40592b/openai/v1
If you want to see what the dashboard looks like without sending any real traffic, the landing page also has a link to load a sample profiled coding session — real data from a real session, anonymized.
What the Dashboard Shows You
Once you’ve pointed a client at your proxy URL and made a few requests, the dashboard gives you a high-level overview and drill-downs:
- Total tokens — input, output, cache reads, and cache writes broken out separately
- Estimated cost — computed from list prices in the open-source pricing table
- Session count — how many distinct conversations were captured
- Per-request breakdown — every API call listed with its token counts, model, and tool attribution
- Session trees — visual representation of how conversations branched and forked
- Tool-level attribution — which functions, editors, or custom tools consumed the most tokens
One detail I appreciated: tokens are stored as disjoint buckets. Input tokens exclude cache reads and writes, so the formula promptSize = input + cacheCreation + cacheRead always holds. For Anthropic, the API reports them separately already. For OpenAI, the proxy subtracts cached tokens from the prompt total so that the same formula works everywhere.
How Session Reconstruction Works (And Why It’s Hard)
The most technically interesting part of Rekon is how it rebuilds conversations from stateless API calls. Both Anthropic and OpenAI’s APIs are fundamentally stateless — you send a list of messages, you get a response, and that’s it. There’s no conversation ID in the response that would let you link requests together.
Rekon solves this with two signals, tried in order:
- Client key — an exact per-conversation identifier the client sends in metadata. Claude Code embeds its session UUID in
metadata.user_id, for example. This is the most reliable signal because it survives history rewrites and conversation compaction. - Chain key — a SHA-256 hash of the last assistant turn in the request, matched against the response key recorded when that response passed through. This links a request to its parent even when no explicit session ID is available.
Both signals are scoped to the requesting system’s ID, so you never get cross-tenant contamination — your sessions stay yours.
The result is a session tree, not a flat list. If you fork a conversation — say you ask a follow-up question that branches off from turn five of a previous conversation — Rekon captures that as a fork with a parent-child relationship. This is genuinely useful for understanding how your usage patterns actually work, not just how they appear in a linear log.
Tool-Level Attribution: Where the Tokens Actually Go
This was the feature that sold me. When you’re running an AI coding agent that can execute tools — read files, write code, run tests, search the web — the token split between the conversation itself and the tool results is non-trivial. A single tool result with a large file can burn more tokens than the prompt that triggered it.
Rekon records tool calls in two phases: when the response emitting a tool_use passes through, it inserts a row with the function name and input. When a later request replays the matching tool_result, it fills in the output. This means you can see exactly what each tool cost you — and which tools are worth optimizing.
Tool result tokens are character-estimated (roughly four characters per token, with a flat estimate for images since base64 length wildly overstates vision tokens), then scaled proportionally to the actual newInputTokens delta. It’s an estimate, not a precise count, but it’s close enough to be actionable.
Self-Hosting: Deploy Your Own Instance
The hosted version at tryrekon.com is convenient, but if you’d rather keep all your usage data on infrastructure you control — and honestly, after reading the coverage on how companies are feeding data to future competitors through API usage, that’s a reasonable concern — self-hosting is straightforward.
git clone https://github.com/TryRekon/Rekon.git
cd Rekon
npm install
cp .dev.vars.example .dev.vars
# Set SESSION_SECRET and at least one OAuth provider (Google or GitHub)
npm run typegen
npm run db:migrate:local
npm run dev
The local dev server runs on port 5173 with the Worker inside workerd on the same origin. For production deployment, you need a Cloudflare account:
- Create a D1 database:
wrangler d1 create token-profiler-db - Paste the database ID into
wrangler.jsonc - Set secrets with
wrangler secret put(SESSION_SECRET, OAuth client ID/secret, optional PostHog key) - Run
npm run db:migrate:remote - Run
npm run deploy
One important note: the deploy command does not run migrations — you have to do that as a separate step. The README is explicit about this, but it’s the kind of detail that’s easy to miss when you’re rushing through setup.
Practical Use Cases
After running Rekon for a few days, here’s what I found genuinely useful:
- Per-project cost tracking. Create one system per project or team, point different clients at different proxy URLs, and see exactly which project is burning through the budget. Great for justifying tool spend to your manager or finance team.
- Prompt optimization feedback. When you see that a particular tool or conversation pattern is consuming way more output tokens than expected, you can adjust your prompts. Shorter instructions, more specific context, tighter constraints — the dashboard gives you the data to make those calls.
- Cache effectiveness measurement. With the breakdown of input vs cache reads vs cache writes, you can tell whether your prompt caching strategy is actually working. If your cache hit ratio is low, you’re paying full price for every request when you could be saving 90%.
- Agent behavior auditing. If you’re running autonomous AI agents — and auditing what your AI coding tools actually do is becoming table stakes — tool-level attribution shows you exactly which actions the agent took and how much each cost in tokens.
Where It Falls Short
I want to be upfront about the limitations because I think honest assessments are more useful than hype.
Cost estimates, not actuals. The dollar figures come from list prices in an open-source pricing table. If you have enterprise discounts, committed-use deals, or custom pricing, the dashboard will overestimate your costs. Unknown models show no cost at all.
OpenAI streaming limitations. Streamed OpenAI usage is only recorded when the client sends stream_options.include_usage. Without it, the request is still logged — you’ll see it in the session list — but with null token counts.
Cloudflare dependency for self-hosting. The self-hosted version requires Cloudflare Workers and D1. If your organization doesn’t use Cloudflare or has restrictions on serverless Workers, that’s a barrier. There are alternatives like tokmon (a local Go proxy with a terminal dashboard) if you need something that runs entirely on your machine.
No budget enforcement. Rekon is purely observational — it records and displays, but it doesn’t stop requests when you hit a limit. If you need hard budget caps, you’d pair it with something like LiteLLM or a custom rate-limiting proxy. If you want to block dangerous agent actions before they execute, Destructive Command Guard (dcg) is a complementary tool that prevents AI agents from running destructive shell commands.
How It Compares to Other Options
Rekon isn’t the only token-tracking tool out there. Here’s a quick comparison based on what I tested:
- tokmon — A local Go proxy that runs on your machine and shows a real-time terminal dashboard. If you are exploring the AI developer tooling ecosystem, my FastMCP tutorial covers another piece of the puzzle from the protocol side. Great for individual developers who want zero infrastructure. No session trees, no web UI, but zero Cloudflare dependency.
- llm-token-proxy — More of a full-featured proxy with caching, rate limiting, and multi-provider routing. Token tracking is one feature among many. Heavier setup.
- Token Monitor — A desktop widget that reads token usage from local AI tool data files (Claude Code transcripts, Codex sessions, etc.). No proxy required, but only works with tools that write local usage data.
Rekon’s sweet spot is the combination of zero-latency proxying, session trees, tool-level attribution, and the hosted option that takes ten seconds to start. It’s not the most feature-rich option, but it’s the easiest to try.
So Where Does That Leave Us?
Understanding your AI API token usage is one of those things that feels optional until the moment it becomes urgent — your monthly bill doubles, a project exceeds budget, or a manager asks you to justify the spend. By then, you’re scrambling for data that should have been collected from day one.
Rekon solves that with a remarkably simple insight: if every API call passes through a logging proxy, you get a complete picture of your AI usage with no client-side changes and zero latency overhead. The fact that it’s open source, self-hostable, and respects your API key privacy makes it a solid choice for both individual developers and small teams.
I’ve been running it for a week now across three projects, and the biggest surprise wasn’t the total spend — it was how uneven the distribution was. Two conversations accounted for nearly 40% of my token consumption. One was a debugging session where I kept sending the full project context with every follow-up. The other was a refactoring task where the AI agent kept reading and re-reading the same large files as tool output.
I wouldn’t have caught either pattern without the per-session breakdown. And honestly, that alone made the setup worth it.
If you’re already thinking about whether to keep renting AI or start self-hosting, having hard data on your current usage pattern is the first step. Rekon gives you that data for free — both in the monetary sense and in the “minimal effort to set up” sense.