@hedvion/endpoint2cost
v0.9.4
Published
See how much you and your team spend on Claude Code — token usage + API-equivalent cost from local session logs. Local-first.
Readme
@hedvion/endpoint2cost
See how much you — and your team — spend on AI coding assistants.
endpoint2cost reads Claude Code and Codex CLI local session logs,
prices every turn at metered Anthropic / OpenAI rates, and shows token usage
and cost per model, per day, and per project. A paid team tier aggregates
each developer's usage into a shared hub, and a transparent Anthropic API
proxy captures usage from server-side bots and other apps that already
call api.anthropic.com directly.
Works on subscriptions too — Claude Code and Codex log token counts whether you're on a flat Max/Pro/Team plan or metered API keys. The cost shown is API-equivalent: what the same usage would bill at API prices. Volume is always real.
Install
npm i -g @hedvion/endpoint2cost
# or run without installing:
npx @hedvion/endpoint2cost usageThe binary is endpoint2cost. Requires Node 18+.
Free — your own usage
endpoint2cost usage # scan ~/.claude/projects + ~/.codex/sessions
endpoint2cost dashboard # open a local React dashboard for that reportFlags:
--no-claude/--no-codex— skip a provider-d <dir>/--codex-dir <dir>— override the log directory-m <id>— override the member identity (default: git email)
The dashboard shows total cost, a per-model breakdown, a daily-cost chart, and per-project usage. Everything runs locally — no data leaves your machine.
Paid — team usage hub
The admin provisions accounts; each account gets an API key (for the CLI) and a password (for the web dashboard).
# admin: create an account on the team server
export E2C_ADMIN_TOKEN=<token from <dataDir>/admin-token>
endpoint2cost admin add-account [email protected] --plan team
# → prints a one-time password + API key. Hand both to the user.
# member: activate the API key locally
endpoint2cost login <api-key>
# member: push usage (e.g. from a daily cron)
endpoint2cost usage --push
# anyone with a session: open the web dashboard
open https://<server>/ # email + password loginThe hub ranks members by cost and shows each one's share, turns, sessions,
and top model. Members are identified by their git email (override with
E2C_MEMBER).
Seats
A plan caps how many distinct members the hub aggregates: Team = 5, Enterprise = 100. A new member's push is rejected once the cap is reached; existing members can always re-push.
Roster (optional)
When a team prefers an explicit allowlist over open self-registration:
endpoint2cost team add [email protected]
endpoint2cost team list
endpoint2cost team remove [email protected]Once the roster is non-empty, only listed members may push.
Server-side bots — Anthropic proxy
Set ANTHROPIC_BASE_URL=https://<server>/anthropic/<tenant-id> in any bot's
.env. Both the official Python and TypeScript Anthropic SDKs honour this
env var automatically — no code changes needed. Each call is forwarded to
api.anthropic.com and the response's usage block is recorded against the
synthetic anthropic-api member of that tenant. Streaming requests
(stream: true) are rejected.
Run your own server
endpoint2cost serve --port 4400 --data ./e2c-dataOn first boot the server writes an admin bearer to ./e2c-data/admin-token
(mode 0600). Use it for endpoint2cost admin ... commands and keep it
secret — anyone with the token can create or revoke accounts.
Commands
| Command | Description |
| --- | --- |
| usage | Scan local logs → usage report |
| dashboard | Local dashboard for your usage report |
| dashboard --team <url> | Team usage hub from a server (paid) |
| usage --push | Upload your usage to the team server (paid) |
| serve | Run the team server |
| login / logout / license | Manage your API key locally |
| team list / add / remove | Manage the team roster (paid) |
| admin add-account / list-accounts / remove-account | Provision accounts (admin token) |
| admin set-plan / reset-password / rotate-api-key | Maintain an account (admin token) |
How cost is computed
Each assistant turn in the logs carries token counts (input, output, and
cache read / cache write). They are priced per model family — Anthropic
Opus / Sonnet / Haiku at their full cache-aware rates, OpenAI GPT-5 / GPT-4
/ o-series at the input + output + cached-input rates. Unknown models are
counted but priced at zero. Pricing defaults live in usage-cost.ts and
are easy to override.
Privacy
The free CLI is fully local. The team tier sends only the aggregated
usage report (token counts, model names, project folder names, timestamps)
to the server you run — never prompts, code, or message content. The
Anthropic proxy reads usage out of the response but does not store the
prompt or completion body.
