Skip to content

Repository files navigation

npm i -g @aiusage/cli

AIUsage tracks token usage and costs across all your AI tools and devices,
syncs to your own Cloudflare Worker, and visualizes everything on a public dashboard.

简体中文 | English

npm Cloudflare Workers Cloudflare D1 MIT License

Live Demo


What is AIUsage?

A self-hosted, privacy-first system for tracking how much you spend on AI coding tools — across every device you own.

Supported Tools

Claude Code Codex CLI Cursor Copilot CLI Copilot for VS Code Gemini CLI Antigravity Amp

Kimi Code Qwen Code Droid OpenCode Pi Trae

Why AIUsage?

  • Scans locally — reads token usage from session logs, never touches conversation content
  • Syncs across devices — every machine enrolls with its own secure token, data merges on your Worker
  • Visualizes costs — public dashboard with trends, model breakdowns, cost per session, and more
  • You own the data — deploys to your Cloudflare account (free tier is enough), no third-party services

Architecture

graph LR
  D1["<b>Device 01</b><br/>MacBook Pro"] -- sync --> W["<b>Cloudflare Worker</b><br/>+ D1 Database"]
  D2["<b>Device 02</b><br/>Mac Mini"] -- sync --> W
  D3["<b>Device 03</b><br/>Linux Server"] -- sync --> W
  W -- public API --> Dashboard["<b>Dashboard</b><br/>read-only web UI"]
Loading

Quickstart

Deploy with your AI agent

Copy this prompt, paste it into your AI coding agent (Claude Code, Codex, Copilot, Gemini, etc.):

Clone https://github.com/ennann/aiusage.git, read skills/aiusage-server/aiusage-server.md,
and help me deploy AIUsage to my Cloudflare account.
After the server is up, follow skills/aiusage-cli/aiusage-cli.md to connect this device.

Or deploy manually

git clone https://github.com/ennann/aiusage.git
cd aiusage && pnpm install
npx wrangler login
pnpm setup

Local reports (no server needed)

npm i -g @aiusage/cli
aiusage report --range 7d

Staying Up to Date

AIUsage uses a fork-based update model — fork this repo, connect your fork to Cloudflare Workers via Git integration, and updates flow automatically.

  1. Fork this repository to your GitHub account
  2. Connect your fork to Cloudflare Workers (Git integration)
  3. Sync upstream updates via GitHub's "Sync fork" button or git merge upstream/main
  4. Cloudflare auto-redeploys on every push to your fork

CLI updates are separate: npm update -g @aiusage/cli

See the Update Guide for detailed instructions, including fully automatic sync via GitHub Actions.

Docs

Document Description
Deployment Guide Full setup walkthrough, CLI reference, API docs
Update Guide Fork-based update mechanism and auto-deploy setup
CLI README CLI tool details and all commands

License

MIT

About

No description, website, or topics provided.

Resources

Stars

16 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages