Skip to main content
Back to plugins
W

ai-monitor

winterone-hub/ai-monitor

DeepSeek Harness plugin: query AI Monitor balance / usage from local SQLite — cost-aware agent, auto bookkeeping with the AI Monitor proxy.

Install

dsh plugin --profile web add github:winterone-hub/ai-monitor

README

AI Monitor

A lightweight desktop overlay that monitors AI platform account balances, token usage & spend in real time. 桌面灵动岛悬浮卡片:实时监控各 AI 平台账户余额、token 用量与消耗金额。

Platform Tech License

Built with Tauri 2~6MB installer, ~100MB RAM. Data stays 100% local.


📸 Demo

Demo


✨ Features / 功能特性

Feature说明
🎴Dynamic Island overlayFloating capsule; hover to expand (drawer animation), move away to collapse; draggable in both modes; snap to screen edge as a half-circle
💰Multi-platform balanceAuto query via official APIs: DeepSeek, Kimi (Moonshot), SiliconFlow, OpenRouter
🔢Token usage trackingBuilt-in local proxy records every call — minute-level events (OpenAI & Anthropic formats)
📊Composite trend chartBalance line + token line on one time axis; zoom by wheel/pinch/drag, ranges 1d/7d/30d/custom (start+end)
💵Accurate spendCost from balance diff (real billing) or token × model price (aggregators)
🌐i18nAuto-detects system language (中文 / English)
🚨AlertsLow-balance system notifications + Webhook (ServerChan / Feishu / DingTalk / Bark)
🔒PrivacyAPI keys encrypted in OS keychain; all data stays local

📦 Installation / 安装

Download from Releases:

  • macOS (Apple Silicon): AI.Monitor_*.dmg → open (right-click → Open if unsigned)
  • Windows 10/11: AI.Monitor_*.exe → run installer

Or build from source:

# Requirements: Node.js 18+, Rust (stable)
npm install
npm run tauri dev      # development
npm run tauri build    # production bundle

🚀 Quick Start / 快速开始

  1. Launch the app, open the Dashboard (click the island → expand → click ⤢)
  2. Go to Accounts tab → select a platform → paste your API Key → Add
  3. Platforms with official balance APIs will show balance automatically
  4. The island shows total balance / today's spend / today's tokens; hover to expand details per account

🔌 API Integration / API 接入

Which platforms can auto-query balance?

PlatformBalance APIUsage via proxyNotes
DeepSeek✅ officialAnthropic + OpenAI formats
Kimi (Moonshot)✅ official
SiliconFlow✅ official
OpenRouter✅ officialalso has usage API
Zhipu GLM⚠️ manualbalance API TBD
OpenAI⚠️ manualno public balance API
Anthropic⚠️ manual
Google Gemini⚠️ manualneeds GCP billing
Alibaba / Volcano / Baidu⚠️ manualcloud billing based

⚠️ = balance is registered manually via the "登记余额" button.

Proxy Mode: automatic token tracking / 代理模式:自动统计 token

DeepSeek (and most platforms) do not expose a public usage API. To get automatic token/spend tracking, route your API calls through the built-in local proxy:

Proxy base URL (本机代理地址):
  http://127.0.0.1:8899/v1               → DeepSeek (default)
  http://127.0.0.1:8899/moonshot/v1      → Kimi
  http://127.0.0.1:8899/siliconflow/v1   → SiliconFlow
  http://127.0.0.1:8899/openrouter/v1    → OpenRouter
  http://127.0.0.1:8899/openai/v1        → OpenAI

The proxy forwards every request to the real API, parses the response usage, and records it locally. Your API key stays the same — only the base URL changes.

OpenAI SDK example (Python)
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-real-key",                 # same key, unchanged
    base_url="http://127.0.0.1:8899/v1",        # ← point to AI Monitor proxy
)

resp = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
Anthropic SDK example (Python)
from anthropic import Anthropic

client = Anthropic(
    api_key="sk-your-real-key",                 # same key, unchanged
    base_url="http://127.0.0.1:8899/v1",        # ← Anthropic format supported too
)

resp = client.messages.create(
    model="deepseek-chat",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.content[0].text)
curl example
curl http://127.0.0.1:8899/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-real-key" \
  -d '{"model":"deepseek-chat","messages":[{"role":"user","content":"hi"}],"stream":false}'
In other tools (e.g. Proma / 其他工具)

Find the Base URL / API address / 自定义接口 setting and change it to http://127.0.0.1:8899/v1. That's it — the app keeps working normally, and every call is recorded automatically.

💡 The proxy listens only on 127.0.0.1 (localhost). It does not expose your data to the network.


📊 How Usage is Calculated / 统计原理

Single-model platforms vs. aggregator platforms / 单模型平台 vs 聚合平台

The tracking strategy differs by platform type. 不同平台类型的统计方式不同:

Single-model platform(单模型平台)Aggregator platform(聚合平台)
ExampleDeepSeekSiliconFlow / OpenRouter(一余额多模型)
Balance sourceOfficial balance API, real-timeAPI balance is not real-time (coupon/recharge mismatch)
Spend methodBalance diff(余额差值 = 真实扣费)token × model price(按模型单价估算)
Balance displayAPI value directlyRecharge balance − accumulated estimated spend(动态推算)
Model pricesNot needed (balance diff)Auto-synced from official site(每日自动同步全部模型价格)

Details / 细节

  • Single-model platforms (e.g. DeepSeek): the official balance API reflects real-time billing, so spend = first balance snapshot of the day − last snapshot (most accurate). Balance is shown directly from the API.
  • Aggregator platforms (e.g. SiliconFlow): one recharge balance is shared across many models and the API value doesn't reflect real-time usage. So:
    • Spend = Σ (token × model price) — parsed from every proxied request, priced per model (87+ SiliconFlow models auto-synced daily from the official pricing page, manual sync available in Settings).
    • Displayed balance = recharge balance − accumulated estimated spend, so it decreases as you consume.
    • If a model has no configured price, its spend is not counted; add prices in Settings → 模型单价.
MetricMethodAccuracy
Spend (single-model)Balance diff✅ most accurate
Spend (aggregator)token × model price✅ good (model-level)
TokensParsed from every proxied response usage

Model prices can be customized in Settings → 模型单价 (¥ per million tokens). The estimated cost is stored separately; balance diff takes priority when available.

Data boundary / 数据边界(重要)

This app only tracks local activity — requests that go through the proxy running on the same machine (127.0.0.1:8899).

  • If you call the same API from another computer, another agent, or a direct connection, those calls are not counted here.
  • Balance is a platform-level metric: you can install the app on another machine, add the same key, and still see the balance — but per-device token/spend stats are independent.
  • All data is stored locally (SQLite) in your app data directory; no cloud sync.

⚙️ Settings / 设置

  • 采集间隔:how often balance is refreshed (default 30 min)
  • 低余额阈值:low-balance alert threshold
  • 统一代理:pick which account proxy usage is recorded to; view integration examples
  • 模型单价:edit model prices for estimated cost
  • 余额告警:Webhook channel (ServerChan / Feishu / DingTalk / Bark) + test send
  • 开机自启:launch at login

🛠 Development / 开发

npm install
npm run tauri dev      # run in dev mode
npm run tauri build    # bundle .dmg / .exe

Project layout:

src/
  core/        # db / collector / alerts / webhook / proxy client
  providers/   # platform adapters (add a platform = add one file)
  views/       # OverlayApp (island) + DashboardApp
  components/  # BalanceChart (ECharts)
src-tauri/
  src/proxy.rs # local HTTP proxy (axum) — forwards & records usage

🤝 Contributing / 贡献

Adding a new platform takes ~10 minutes — see CONTRIBUTING.md.


📄 License / 许可

MIT


Made with Proma

Related plugins