Documentation

Track AI usage from anything.

MyTokenTracker is free. Get your API token from Settings, send usage from any platform, and see cost by provider, model, platform, and use-case. This page covers every way to integrate.

Quickstart

  1. Create a free account and copy your API token from Settings. It looks like mtt_ followed by 40 characters.
  2. Install with one line (Claude Code) or add a wrapper (any API). See Install by platform.
  3. That is it. Usage is captured automatically and shows up on your dashboard.

Tell your AI agent

Using Claude Code, Cursor, or another coding agent? Paste this and it will wire up reporting for you. Replace YOUR_TOKEN with your token from Settings.

Add MyTokenTracker to this project so our LLM usage and cost is tracked.
Download https://mytokentracker.io/mtt.py (Python) or https://mytokentracker.io/mtt.mjs (Node),
set the environment variable MTT_TOKEN=YOUR_TOKEN, and wrap our OpenAI and Anthropic
calls with track_openai / track_anthropic (Python) or trackOpenAI / trackAnthropic (Node).
Keep it non-blocking and fail-safe, and do not change the responses we return.
It reports to POST https://mytokentracker.io/api/v1/events. Docs: https://mytokentracker.io/docs

Install by platform

Claude Code (macOS / Linux)

curl -fsSL "https://mytokentracker.io/install.sh?token=YOUR_TOKEN" | bash

Claude Code (Windows PowerShell)

irm "https://mytokentracker.io/install.ps1?token=YOUR_TOKEN" | iex

Both add a Stop hook to ~/.claude/settings.json, capture session usage automatically, and verify your token before finishing. Re-running is safe.

Any other app or provider

Use the SDK wrappers or post directly to the events API.

Logged in? Your real token is pre-filled on the install page.

Concepts

provider
Who runs the model: anthropic, openai, google, mistral, xai, deepseek, cohere, and more.
model
The model id, for example gpt-4o or claude-sonnet-4-6.
platform
The tool or SDK that produced the usage: claude-code, cursor, openai-api, your app name.
use_case
What the call was for: coding, chat, agent, rag, batch.
actual vs estimated cost
Send total_cost if you know the real amount and it is stored as actual. Omit it and we estimate from our price catalog and label it estimated.

Events API

Token-authenticated. Send a single event or a batch of up to 500.

POST https://mytokentracker.io/api/v1/events

Authorization: Bearer YOUR_TOKEN

Content-Type: application/json

Fields

FieldTypeRequiredNotes
provider string yes anthropic, openai, google, ...
model string yes e.g. gpt-4o
input_tokens int yes prompt tokens
output_tokens int yes completion tokens
cache_read_tokens int no cached/read tokens
cache_write_tokens int no cache-creation tokens
reasoning_tokens int no reasoning / thinking tokens
total_cost number no real cost; stored as actual. Omit to estimate
latency_ms int no response time in ms (speed comparisons)
success bool no did it succeed (cost-per-success)
quality_score number no your eval/score scale (value-for-money)
status string no ok / error / timeout
currency string no default USD
platform string no tool/SDK, e.g. cursor
use_case string no coding, chat, agent, ...
session_id string no group events
project string no your project name
occurred_at datetime no ISO 8601; default now
metadata object no any extras you want to keep

Example (curl)

curl -X POST https://mytokentracker.io/api/v1/events \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"provider":"openai","model":"gpt-4o","input_tokens":1200,"output_tokens":350,"platform":"my-app","use_case":"chat"}'

Response: {"success":true,"created":1,"total_cost":0.0045}. Batch: send {"events":[ ... ]}. Full machine-readable spec at /openapi.json.

SDK wrappers

Drop-in helpers that read MTT_TOKEN from the environment, report usage in the background, and return the original SDK response untouched. They never throw into your code.

Python

curl -O https://mytokentracker.io/mtt.py
export MTT_TOKEN=YOUR_TOKEN

from openai import OpenAI
from mtt import track_openai
r = track_openai(OpenAI().chat.completions.create(model="gpt-4o", messages=[...]),
                 use_case="chat", project="my-app")

Node

curl -O https://mytokentracker.io/mtt.mjs
export MTT_TOKEN=YOUR_TOKEN

import OpenAI from "openai";
import { trackOpenAI } from "./mtt.mjs";
const r = trackOpenAI(await new OpenAI().chat.completions.create({ model: "gpt-4o", messages: [...] }),
                      { use_case: "agent" });

Subscriptions & budgets

MyTokenTracker itself is free, with no subscription. The "subscription" features track your provider plan, so you can see how close you are to your limits.

  • In Settings, pick your provider plan (for example Claude Pro or Max) and set a session and weekly budget.
  • The dashboard shows your usage against those budgets, with a rolling session window and a weekly reset.
  • Calibration: paste your provider-reported usage percentage and MyTokenTracker tunes its estimate to match, so the numbers track your real limits over time.
  • API providers that bill per token do not have a fixed window. For those, send total_cost when you know it and the dashboard shows exact spend.

Community & privacy

The community dashboard shares, anonymized and in aggregate, what AI is costing everyone. It only ever shows combined totals, and it hides any provider, model, platform, or use-case shared by fewer than three contributors, so no individual can be identified.

Contribution is on by default and you can turn it off anytime in Settings. We never publish your name, your projects, your directories, or your own numbers.

Export & delete

Your data is yours. From Settings you can export everything as CSV or JSON, or permanently delete all of your usage data. Exports include provider, platform, model, use-case, tokens, cost, and cost type.

For machines

  • /llms.txt: a concise, machine-readable integration guide for LLMs and agents.
  • /openapi.json: an OpenAPI 3.1 spec for the events API. Generate a client, or hand it to a tool or agent.

FAQ

Is it really free?+

Yes. Free, forever. No paid plans and no credit card.

Do I need to change my code?+

For Claude Code, no: the one-line installer adds a hook and captures automatically. For other apps, add a wrapper or post to the events API.

What providers and models are supported?+

Any provider and any model. We price around 2,300 models and accept any provider/model string on the events API.

Will it slow down my app?+

No. The wrappers report in the background, swallow every error, and return the original response untouched.

How is cost calculated?+

If you send total_cost we store it as actual. Otherwise we compute it from our daily-synced price catalog and label it estimated.

Can an LLM set this up for me?+

Yes. Paste the prompt in Tell your AI agent, or point your agent at /llms.txt and /openapi.json.