Back to home

How Tokeven works

A privacy-first AI cost optimization platform that tracks every instrumented call across Claude, ChatGPT, Gemini, and Grok - without ever receiving a provider key, and without prompt content ever reaching Tokeven on the tracking path. Here's exactly how it works, end to end.

The data flow

From API call to dashboard - four hops, no prompt content on the wire.

1 of 4

Your machine

The wrapper (or the sidecar) reads response.usage after each call: token counts, model, latency, modality, and a local character count. Prompt content never reaches Tokeven.

2 of 4

Batched push

Events flush to /ingest asynchronously (default: every 5s or 50 events). Authenticated by write-only ingest token.

3 of 4

Tokeven backend

Server recomputes cost_usd (cache-aware, authoritative). Idempotent on (org_id, event_id) - duplicates are silently dropped.

4 of 4

Spend, Save, Proof

Three views query usage_events and usage_summaries. Sub-2-second load. Export to CSV/JSON on the Team plan.

Step 1

Install the wrapper

Tokeven ships as a lightweight Python package. wrap() takes your existing Anthropic, OpenAI, Google or xAI client and returns an instrumented one - it dispatches on the client you hand it, so the same line works for all four. Grok has no SDK of its own: xAI serves the OpenAI protocol at api.x.ai, so it runs through the OpenAI SDK. No code changes to your prompts, no new dependencies in your hot path.

After each API call, the wrapper reads response.usage and captures: input/output tokens, cache read/write tokens, model name, latency, and a local character count of the prompt. It never sends the prompt content itself to Tokeven.

Cannot wrap the client - a different language, a tool you do not control? Run the self-hosted tokeven-proxy sidecar in your own environment and point the provider client at it instead. Those two paths - wrap() and the sidecar - are the only things that record usage. The MCP server is the pre-send advisor: it prices calls, it does not track them. Traffic that never passes through an instrumented path (the Workbench, a console, an un-instrumented app) will not appear in your dashboard. tokeven status tells you which paths are live on a machine.

What gets captured

  • Token counts (input, output, cache_read, cache_creation)
  • Provider and model name (e.g. claude-sonnet-4-6)
  • Modality, detected from block types - never from content
  • Latency in milliseconds
  • Local prompt_length (character count, not content)
  • session_id and project tags (optional)
  • tool_used (detected from tool_use blocks)

What the wrapper never sends to Tokeven

  • Prompt and completion content
  • Your Anthropic (Claude), OpenAI (ChatGPT), Google (Gemini) or xAI (Grok) API key
  • Any personally identifiable information
app.pytracks usage
1# Two lines - wrap your existing Anthropic client
2from anthropic import Anthropic
3from tokeven import TokevenAnthropic
4
5client = Anthropic()
6client = TokevenAnthropic(client, project="my-app")
7
8# That's it - all calls are now tracked
9response = client.messages.create(model="claude-sonnet-4-6", ...)

Captures usage: token counts, model, latency and cost. Prompt content and your provider key never reach Tokeven.

Your Weekly Spend Digest
· tokeven
Mon 9:00 AM
Biggest lever: caching - $104/mo left on the table
3 optimizations found, $183/mo total - 18% of your $1,003/mo run rate
Cache hit rate
34%
Total calls
2,263
Total cost
$234
Avg cost/call
$0.10
Enable cache_control on your repeated system prompt
$104/mo

The same 9,000-token system prompt is billed as fresh input on 755 Claude calls a week. Marking it cacheable bills the repeats at the 90%-off cache-read rate instead.

42% of your Opus calls could use Sonnet
$64/mo

155 of your 370 claude-opus-4-8 calls this week were single-turn lookups. On the identical prompt, claude-sonnet-4-6 prices 40% lower.

Trim re-sent context in 3 workflows
$15/mo

3 gemini-3.1-pro workflows re-send full conversation history every turn. Summarising prior turns would cut fresh input tokens by ~35%.

View full report in dashboard
Step 2

See the price and the alternatives before every call

Before you send, the advisor prices the call and scores cheaper alternatives across all four providers: what each would cost, and a confidence score for this kind of task. It runs entirely on your machine - as the MCP tool tokeven_estimate, as client.estimate(), or from the CLI. Then you choose. Tokeven never swaps a model on you and never downgrades a call silently; a suggestion you do not accept changes nothing about the request you make.

Prices behind those estimates are verified daily. Confidence scores are refreshed on a published schedule; the current refresh date is shown next to every score.

After the fact, the weekly digest is built from your actual usage patterns - specific optimizations with exact dollar amounts attached, drawn from calls your team already made (Team plan).

Efficiency quick wins (shipped with the wrapper)

  • Model-tier nudges: 'This task used Opus but Haiku handles it at 80% less'
  • Cache hints: 'Your 4,200-token system prompt repeats 8x/day - add cache_control'
  • Context trimming: 'This workflow re-sends full history -summarize prior turns to cut 60%'
  • Prompt-length flags: 'Reference files instead of pasting - 12K chars is expensive'
  • Auto-compaction: Summarize long conversations to cut input token growth
Step 3

Prove every dollar saved

Three views, in the order the questions actually arrive: where is the money going, what should we change, and did the change work. Each loads in under 2 seconds.

Spend

Where your budget goes, by model, team, and session. Tabs for Overview, Cost Drivers, Models, Tokens, and Activity.

Save

What to change next: recommendations, caching opportunities, and prompt efficiency - each with a dollar figure.

Proof

Every dollar saved, traced to the recommendation you accepted. Open book - this is the same math we bill from.

Around those three sit the pages you go to on purpose rather than daily: Team for per-person and per-team rollup, Weekly Analysis for the digest, Board Briefs for the monthly summary you forward, plus Export and API & Widgets.

The single biggest lever most teams have is caching: Save shows each engineer their own cache rate, what it is worth in dollars, and a weekly nudge to raise it - alongside per-call cost, model breakdowns, and team spend across all four providers.

tokeven.com/dashboard/cost
Cost Overview
7 days
30 days
90 days
Total Cost (7d)
$9,364
40 seats
Avg Cost / Call
$0.10
90,500 calls
Cache Hit Rate
34%
↑ from 28%
Daily Cost
MonTueWedThuFriSatSun
Cost by Model
claude-opus-4-8$3,577
gpt-5.6-sol$2,073
claude-sonnet-4-6$1,665
gemini-3.1-pro$773
gpt-5.5$712
gemini-3.5-flash$343
claude-haiku-4-5$221
Most Expensive Calls
claude-opus-4-8
$0.55
gpt-5.6-sol
$0.54
claude-sonnet-4-6
$0.44
gemini-3.1-pro
$0.31

What changes with Tokeven

See more comparisons across every model pair at /compare.

Cost awareness
Bill arrives at month end
Every call priced before it is sent
Model selection
Developers guess which model fits
Cost and confidence per model before each call, across Claude, GPT, Gemini and Grok
Prompt caching
Repeated system prompts billed at full price
Cacheable patterns flagged, 90% savings on repeats
Team visibility
Spend is one line on the invoice
Per-person cost, calls and savings, fully auditable
Savings proof
"We think we saved money"
Every dollar traced to a recommendation you accepted
Privacy
Prompts sit on vendor servers
Prompt content never reaches Tokeven, metadata only

Everything above ships today

There is no phase list to wait out. Tokeven is one release - capture, advisor, dashboard, widgets, teardown tool, MCP server and integrations all landed together. Here is the whole surface area.

Capture

Runs in your environment, pushes metrics only.
  • Drop-in Python wrappers for the Anthropic, OpenAI and Google SDKs
  • xAI/Grok via the OpenAI SDK against api.x.ai - same one-line wrap
  • Self-hosted sidecar (tokeven-proxy) for anything you would rather not wrap
  • Write-only ingest tokens, SHA-256 hashed and revocable - never a provider key
  • Cache-aware cost, recomputed server-side on ingest so it stays authoritative
  • Idempotent on your own event_id - retries and duplicates cost you nothing

Advise before you send

Entirely client-side. You always pick the model.
  • Pre-send estimate: what this call costs, plus cheaper cross-provider options
  • A confidence score per alternative, per task type - not a blind price sort
  • Three ways in: the MCP tool tokeven_estimate, client.estimate(), or the CLI
  • Efficiency quick wins: auto-compaction, model-tier picker, cache and max_tokens hints
  • Prices are verified daily; task rankings are a dated snapshot the advisor prints
  • Nothing is routed for you and nothing is downgraded behind your back

Analyze and prove

Three views, then the artifacts you forward upward.
  • Spend, Save and Proof - the three dashboard views, each under 2 seconds
  • Per-person and per-team cost rollup on the Team view
  • Weekly Analysis digest built from your own usage (Team plan)
  • Monthly Board Briefs for the budget conversation you have to win
  • Proof traces every saved dollar to the recommendation you accepted
  • Savings are per-call deltas priced at call time - no frozen baseline

Integrate

Get the numbers where your team already looks.
  • REST API into your existing BI tooling
  • Embeddable widgets and a live cost widget for your own surfaces
  • n8n, Zapier and outbound webhooks
  • Budget thresholds and spend alerts
  • CSV and JSON export (Team plan)
  • A free, no-login teardown tool for a first look before you sign up

What Tokeven will not do

Not gaps - commitments.
  • Route your models silently. The advisor shows the options and the cost; the choice stays yours.
  • Hold a provider key. Tokeven stores password hashes and hashed ingest tokens - that is the whole list.
  • Receive your prompts on the ingest path. Two opt-in tools (prompt revision and advisor.improve()) send text you paste, and both say so at the point of use.
  • Bill per seat. The fee is 10% of verified savings, so zero savings means zero fee.

Ready to see where your AI budget actually goes?

Free tier: one developer, the full dashboard, forever. Install in 2 minutes. Paid plans bill 10% of verified savings - if there is nothing to save, there is nothing to pay.

Start free