--- 目录 - Tokpet 是什么? - 亮点 - 如何运作 - 支持的提供商 - 快速入门 - 管理服务 - 硬件 - 使用指南 - 文档 - 社区 - 合作伙伴 - 联系我们
--- 目录 - Tokpet 是什么? - 亮点 - 如何运作 - 支持的提供商 - 快速入门 - 管理服务 - 硬件 - 使用指南 - 文档 - 社区 - 合作伙伴 - 联系我们
/state contractMost AI tools hide your usage behind a dashboard you have to remember to open. Tokpet turns it into an ambient, glanceable thing.
It has two halves:
tokpet). It runs on your
machine, talks to each provider, normalizes wildly different billing models
into one shape, caches the result, and exposes a single GET /state JSON
endpoint plus a local web console.firmware/). It discovers the companion over your LAN, polls
/state, and renders the numbers as glowing rings around a cat whose mood
tracks your usage pressure.You don't need the hardware to use Tokpet — the browser console is a full client on its own. The device is the fun part.
/state contract.chill → alert → stress, so a
glance tells you where you stand without reading a single digit./state feed is
exposed to your LAN so the device can poll it._tokpet._tcp.local), so the device finds it without you typing an IP.flowchart LR
subgraph P["AI providers"]
direction TB
C1["Claude"]
C2["Codex"]
C3["DeepSeek"]
end
P -->|"each provider's
native API"| CO
CO[" Tokpet companion
(runs on your machine)
normalize · cache · aggregate"]
CO -->|"GET /state · LAN"| DEV[" Tokpet device
ESP32-S3 desk pet"]
CO -->|"http://localhost:4717"| WEB["️ Browser console"]
CO -->|"GET /state"| ANY[" Any client"]The companion polls each activated provider, maps its data onto a common
Usage shape, and serves the aggregate snapshot at GET /state. Clients never
talk to providers directly — they just read one endpoint. The only stability
guarantee Tokpet makes is the /state JSON schema, so any third-party hardware
or client can rely on it.
Providers are grouped by how the vendor exposes usage data:
| Mode | Data shape |
|---|---|
subscription/ |
Rolling-window quotas (e.g. 5 h / 7 d) with reset times |
api-key/ |
Cumulative spend or a prepaid balance |
relay/ |
Per-gateway custom billing (planned) |
Available today:
| Provider | Mode | What it reads | What you need |
|---|---|---|---|
| Claude | subscription |
5-hour + 7-day rolling usage | Your existing Claude Code login — no key |
| Codex | subscription |
5-hour + 7-day rolling rate limits | Your existing Codex CLI login — no key |
| DeepSeek | api-key |
Prepaid wallet balance | A DeepSeek API key |
Planned: more subscription providers (OpenAI Plus, Cursor, Windsurf…),
direct API-key billing (Anthropic API, OpenAI API, Gemini…), and relay gateways
(OpenRouter, Together…). Each new vendor is a self-contained directory under
src/providers/// — contributions welcome.
Requirements: Node.js ≥ 20 (Homebrew installs it for you). The companion runs anywhere Node.js does; the background-service helpers are macOS (launchd) only today.
Homebrew (macOS — recommended)
brew install grpcer/tokpet/tokpet
brew services start tokpet # runs in the background and restarts on loginnpm (cross-platform)
npm install -g tokpet
tokpet service install # background launchd service (macOS), restarts on login
# …or just run it in the foreground:
tokpetFrom source (for hacking — see Development)
git clone https://github.com/grpcer/tokpet.git
cd tokpet
npm install
npm run devThe first start opens the console automatically. To reopen it any time:
tokpet open…or just visit it in your browser:
That's the Tokpet console — a live dashboard plus the place you add providers. The raw, machine-readable feed lives one path over, at http://localhost:4717/state.
In the console, click Add provider, choose how the provider exposes usage
(subscription / API key), pick the provider, and hit Test. On success it
activates immediately and starts appearing in /state. Your choices are saved
to ~/.tokpet/config.json and restored on the next launch.
That's it — the cat is now watching your tokens.
| Homebrew | npm | |
|---|---|---|
| Start | brew services start tokpet |
tokpet service install |
| Stop | brew services stop tokpet |
tokpet service uninstall |
| Status | brew services info tokpet |
tokpet service status |
Full CLI:
tokpet [start] Run the companion service in the foreground
tokpet open Open the console in your browser
tokpet service install Install the background launchd service (npm users)
tokpet service uninstall Remove the background launchd service
tokpet service status Show the launchd service status
tokpet --version Print the version
tokpet --help Show helpThe service binds
0.0.0.0so devices on your LAN can readGET /state, but the setup and configuration routes are guarded to loopback callers only and are never reachable from the network.
The reference device is a round-screen ESP32-S3 desk pet built on the M5Stack StopWatch board:
It boots, finds the companion over mDNS, polls /state, and renders your usage
as concentric rings around a cat whose expression shifts from calm to panicked
as you burn through your quota.
The full firmware — board bring-up, the LVGL "halo cat" UI, the Wi-Fi
provisioning flow, and build/flash instructions — lives in
firmware/. It's a standard ESP-IDF project; flashing it is
idf.py flash.
/state contractGET /state is the one stable, versioned surface every client builds on. The
top-level shape:
{
"version": 1,
"fetchedAt": "2026-06-30T12:34:56.000Z",
"providers": [
{
"id": "claude",
"displayName": "Claude",
"mode": "subscription",
"result": {
/* normalized Usage — see src/protocol/usage.ts */
},
},
],
"primary": {
"providerId": "claude",
"windowId": "7d",
"usedPct": 33,
"mood": "chill",
},
}primary is the "hero" metric the device shows by default, and mood is
derived from usedPct (chill //, implement id/displayName/configSchema/isReady/fetch, register it in src/providers/registry.ts`, and add a test.
The full walkthrough and house rules are in
CONTRIBUTING.md.
Tokpet is young but already useful end-to-end.
/state contract.Device stuck on "open the console to add a provider", or not showing up after you moved it to a new network? Start with TROUBLESHOOTING.md — it walks through the LAN, mDNS, and re-provisioning checks step by step.
Issues and PRs are welcome. Please read CONTRIBUTING.md and our Code of Conduct first. Good first contributions: wire up a new provider, or improve a translation of this README.
Apache-2.0 © the Tokpet contributors. See NOTICE for attribution.
暂无开放 Issues,或尚未同步最近议题。