Skip to content

autumncry/tokenmanager

Repository files navigation

TokenManager

100% 本地的 AI API 余额、用量、额度与 Coding Plan 菜单栏工具。

项目侧无任何隐私风险:没有服务器保存数据,没有代理转发请求,没有云端同步账户。

All account data stays on your Mac. No project server, no proxy, no cloud sync.

CI macOS 14+ Swift 6.1 100% local data no project server MIT License

中文 · English

TokenManager dashboard screenshot

TokenManager menu bar quick view screenshot    TokenManager settings screenshot

中文

TokenManager 是一个原生 macOS 菜单栏应用,用于追踪主流 AI API 平台的账户余额、用量、额度窗口和 Coding Plan。它的核心设计目标是安全:所有数据均在用户本地处理,项目没有服务器,不代理请求,不做云同步,不收集账户数据,项目侧无任何隐私风险。

从 TokenManager 项目侧看,它没有隐私采集面:API Key 和访问令牌保存在 macOS 钥匙串,配置文件只保存钥匙串引用和本地偏好,刷新请求从你的 Mac 直接发往你启用的厂商 API。

为什么安全

  • 100% 本地数据路径:账户、配置、截图、刷新结果都保留在你的 Mac。
  • 没有项目服务器:TokenManager 不运行后端服务,不保存你的任何账户数据。
  • 不代理厂商请求:请求从本机直连 OpenAI、DeepSeek、火山方舟 / 豆包等厂商 API。
  • 凭据保存在 macOS 钥匙串:配置文件不会写入 API Key、access token 或密码。
  • 可审计:核心逻辑、解析器、打包脚本和本地配置路径都在仓库内公开。

功能亮点

  • 原生 SwiftUI 菜单栏应用,支持 MenuBarExtra、仪表盘窗口、设置页和紧凑 Quick View。
  • 设置页可直接选择厂商、粘贴 API Key、保存到 macOS 钥匙串,并立即测试刷新余额。
  • 支持中文和 English 界面,可在应用内随时切换。
  • 厂商目录覆盖 OpenAI、Codex、Claude、Gemini、OpenCode、Alibaba、Alibaba Token、DeepSeek、火山方舟 / 豆包、z.ai、MiniMax、Kimi、Kimi K2、Kilo、Kiro、OpenRouter、StepFun、SiliconFlow、xAI、Mistral、Groq、Together AI、Cohere、Azure OpenAI、AWS Bedrock、智谱 BigModel、百度千帆、腾讯混元、百川智能和 ModelScope。
  • 已支持 DeepSeek、MiniMax、Moonshot / Kimi API、SiliconFlow、OpenRouter 和 OpenAI organization costs 的实时刷新适配。
  • 已加入火山方舟 / 豆包 Coding Plan 解析器与演示数据路径,可展示字节系 coding quota window。
  • tokenmanagerctl CLI 可用于厂商查询、状态检查和脚本化本地密钥设置。
  • 静态项目主页源码位于 site/index.html,用于 GitHub Pages 或任意静态托管。
  • 支持通过 macOS app bundle、.pkg.dmg 和 npm source-build wrapper 安装。

安装

GitHub Releases 下载最新版:

  • tokenmanager-<version>.app.zip
  • tokenmanager-<version>.pkg
  • tokenmanager-<version>.dmg

源码构建:

git clone https://github.com/autumncry/tokenmanager.git
cd tokenmanager
./script/package_app.sh
open dist/TokenManager.app

npm 安装路径:

npm install -g tokenmanager
tokenmanager build
tokenmanager launch

CLI 配置:

tokenmanagerctl providers
printf '%s' "$DEEPSEEK_API_KEY" | tokenmanagerctl config set-api-key --provider deepseek --stdin
printf '%s' "$DEEPSEEK_API_KEY" | tokenmanagerctl balance --provider deepseek --stdin
printf '%s' "$MINIMAX_API_KEY" | tokenmanagerctl balance --provider minimax --stdin
tokenmanagerctl status

balance --stdin 会用本次输入的 API Key 直接查询余额,不把 key 写入配置文件;config set-api-key --stdin 才会保存到 macOS 钥匙串并启用菜单栏追踪。

本地构建安装包:

./script/make_pkg.sh
./script/make_dmg.sh
./script/make_app_zip.sh

厂商覆盖

厂商 指标 实时刷新 说明
OpenAI 花费、用量、余额 支持 Key 具备用量权限时读取 organization cost API。
DeepSeek 余额 支持 解析充值余额与赠送余额明细。
MiniMax Coding Plan、用量 支持 读取 CN token plan remains endpoint,并把剩余次数字段换算为已用/总额。
Kimi 余额、用量 支持 解析现金和券余额。
SiliconFlow 余额、用量 支持 解析账户身份与余额字段。
OpenRouter credits、用量 支持 根据总 credits 和 usage 计算剩余额度。
火山方舟 / 豆包 用量、额度、Coding Plan 目录支持 已包含控制台、文档、parser 和演示 quota window;公开剩余额度接口待确认。
Codex、Claude、Gemini、OpenCode、Alibaba、Alibaba Token、z.ai、Kimi K2、Kilo、Kiro、StepFun 用量、额度、Coding Plan 目录支持 每个供应商在 App 内可打开 GitHub 指南,说明凭据类型和当前适配状态。
智谱、百度、腾讯、百川、ModelScope 用量、额度、余额 目录支持 当前支持本地/手动追踪,实时适配器规划中。

新增厂商通常只需要新增一个 descriptor、一个 parser/fetcher、测试和文档。详见 docs/providers.md

隐私与本地存储

TokenManager 不运行、也不会联系 TokenManager 自有服务器。

  • 凭据保存在 macOS 钥匙串服务 app.tokenmanager.credentials
  • 设置保存在 ~/.config/tokenmanager/config.json
  • 刷新请求从你的 Mac 直接发往已启用的厂商 API。
  • 暂无实时适配器的厂商也可以启用为本地/手动追踪。
  • 项目侧没有数据库、没有遥测上报、没有用户账户系统。

完整存储模型见 docs/privacy.md

开发

环境要求:

  • macOS 14+
  • Xcode 26 或 Swift 6.1+
  • Node.js 18+,用于验证 npm 包装命令

运行测试:

swift test

从源码启动:

./script/build_and_run.sh

使用演示数据自动捕获 README 截图:

./script/capture_screenshots.sh

打包发布资产:

./script/package_app.sh
./script/make_pkg.sh
./script/make_dmg.sh
./script/make_app_zip.sh

项目结构

Sources/TokenManagerCore   厂商目录、解析器、配置、钥匙串、API client
Sources/TokenManagerApp    原生 macOS 菜单栏应用
Sources/TokenManagerCLI    tokenmanagerctl 命令行工具
Tests/TokenManagerCoreTests
script                     构建、运行、截图、pkg、dmg 脚本
npm                        npm 命令包装
docs                       隐私、厂商、打包和截图说明

设计

第一版 macOS UI 已沉淀到可编辑 Figma 设计文件:

TokenManager macOS v1 design

项目主页源码:site/index.html

路线图

  • 原生 macOS 菜单栏应用,包含仪表盘、设置页和 Quick View。
  • 100% 本地凭据与配置模型。
  • 覆盖国内外主流 AI 厂商的 provider catalog。
  • DeepSeek、MiniMax、Kimi、SiliconFlow、OpenRouter 和 OpenAI costs 实时适配。
  • 火山方舟 / 豆包 Coding Plan 模型列表连通性验证、解析器与演示快照路径。
  • npm、.app.pkg.dmg 安装路径。
  • 火山方舟、阿里百炼、智谱、百度千帆、腾讯混元、阶跃星辰、百川和 ModelScope 的签名实时适配器。
  • 可选的 Linux / Windows CLI-first 构建。
  • 官网与 notarized 分发流水线。

English

TokenManager is a native macOS menu bar app for tracking balances, usage, quota windows, and Coding Plans across mainstream AI API platforms. Its core product promise is safety: all account data stays local on your Mac. There is no TokenManager project server, no request proxy, no cloud sync, no account-data collection, and no project-side privacy risk.

From TokenManager's project side, there is no privacy-collection surface: API keys and access tokens stay in macOS Keychain, config files store only Keychain references and local preferences, and refresh requests go directly from your Mac to the provider APIs you enable.

Why It Is Safe

  • 100% local data path: accounts, settings, screenshots, and refresh results stay on your Mac.
  • No project server: TokenManager has no backend that can store your account data.
  • No provider proxy: requests go directly from this Mac to OpenAI, DeepSeek, Volcengine Ark / Doubao, and other enabled providers.
  • Credentials stay in macOS Keychain: config files do not contain API keys, access tokens, or passwords.
  • Auditable implementation: core logic, parsers, packaging scripts, and local storage paths are public in this repository.

Highlights

  • Native SwiftUI menu bar app with MenuBarExtra, dashboard window, Settings, and compact Quick View.
  • Settings lets you choose a provider, paste an API key, save it to macOS Keychain, and immediately test-refresh the balance.
  • Chinese and English UI with an in-app language switcher.
  • Provider catalog for OpenAI, Codex, Claude, Gemini, OpenCode, Alibaba, Alibaba Token, DeepSeek, Volcengine Ark / Doubao, z.ai, MiniMax, Kimi, Kimi K2, Kilo, Kiro, OpenRouter, StepFun, SiliconFlow, xAI, Mistral, Groq, Together AI, Cohere, Azure OpenAI, AWS Bedrock, Zhipu BigModel, Baidu Qianfan, Tencent Hunyuan, Baichuan, and ModelScope.
  • Live refresh adapters for DeepSeek, MiniMax, Kimi, SiliconFlow, OpenRouter, and OpenAI organization costs.
  • Volcengine Ark / Doubao Coding Plan parser and demo data path for ByteDance-style coding quota windows.
  • tokenmanagerctl CLI for provider discovery, status checks, and scripted local key setup.
  • Static product homepage source in site/index.html for GitHub Pages or any static host.
  • Installable as a macOS app bundle, .pkg, .dmg, or npm source-build wrapper.

Install

Download the latest release assets from GitHub Releases:

  • tokenmanager-<version>.app.zip
  • tokenmanager-<version>.pkg
  • tokenmanager-<version>.dmg

Source build:

git clone https://github.com/autumncry/tokenmanager.git
cd tokenmanager
./script/package_app.sh
open dist/TokenManager.app

npm wrapper:

npm install -g tokenmanager
tokenmanager build
tokenmanager launch

CLI setup:

tokenmanagerctl providers
printf '%s' "$DEEPSEEK_API_KEY" | tokenmanagerctl config set-api-key --provider deepseek --stdin
printf '%s' "$DEEPSEEK_API_KEY" | tokenmanagerctl balance --provider deepseek --stdin
printf '%s' "$MINIMAX_API_KEY" | tokenmanagerctl balance --provider minimax --stdin
tokenmanagerctl status

balance --stdin checks a balance with the API key you provide for that command and does not write the key to the config file. config set-api-key --stdin saves the key to macOS Keychain and enables menu bar tracking.

Build installer artifacts locally:

./script/make_pkg.sh
./script/make_dmg.sh
./script/make_app_zip.sh

Provider Coverage

Provider Metrics Live refresh Notes
OpenAI spend, usage, balance Yes Uses organization cost APIs when the key has usage permissions.
DeepSeek balance Yes Parses paid and granted balance breakdowns.
MiniMax Coding Plan, usage Yes Reads the CN token plan remains endpoint and converts remaining-count fields to used/limit windows.
Kimi balance, usage Yes Parses cash and voucher balances.
SiliconFlow balance, usage Yes Parses account identity and balance fields.
OpenRouter credits, usage Yes Calculates remaining credits from total credits and usage.
Volcengine Ark / Doubao usage, quota, Coding Plan Catalog Dashboard, docs, parser, and demo quota-window path included; public remaining-quota endpoint still pending.
Codex, Claude, Gemini, OpenCode, Alibaba, Alibaba Token, z.ai, Kimi K2, Kilo, Kiro, StepFun usage, quota, Coding Plan Catalog Each provider opens a GitHub guide from the app with credential type and adapter status.
Zhipu, Baidu, Tencent, Baichuan, ModelScope usage, quota, balance Catalog Local/manual tracking now, provider adapters planned.

Adding a provider usually means adding one descriptor, one parser/fetcher, tests, and documentation. See docs/providers.md.

Privacy And Local Storage

TokenManager does not run or contact a TokenManager-owned server.

  • Credentials stay in macOS Keychain under service app.tokenmanager.credentials.
  • Settings stay in ~/.config/tokenmanager/config.json.
  • Refresh calls go directly from your Mac to enabled provider APIs.
  • Unsupported providers can still be enabled for local/manual tracking while live adapters are added.
  • The project has no database, no telemetry upload, and no user-account system.

See docs/privacy.md for the full storage model.

Development

Requirements:

  • macOS 14+
  • Xcode 26 or Swift 6.1+
  • Node.js 18+ for npm wrapper validation

Run tests:

swift test

Launch from source:

./script/build_and_run.sh

Capture README screenshots from demo data:

./script/capture_screenshots.sh

Package release artifacts:

./script/package_app.sh
./script/make_pkg.sh
./script/make_dmg.sh
./script/make_app_zip.sh

Project Layout

Sources/TokenManagerCore   Provider catalog, parsers, config, Keychain, API client
Sources/TokenManagerApp    Native macOS menu bar app
Sources/TokenManagerCLI    tokenmanagerctl command-line helper
Tests/TokenManagerCoreTests
script                     Build, run, screenshot, pkg, dmg scripts
npm                        npm command wrappers
docs                       Privacy, provider, packaging, and screenshot notes

Design

The first macOS UI pass is documented in an editable Figma design file:

TokenManager macOS v1 design

Product homepage source: site/index.html.

Roadmap

  • Native macOS menu bar app with dashboard, Settings, and Quick View.
  • 100% local credential and config model.
  • Mainstream global and Chinese provider catalog.
  • Live adapters for DeepSeek, MiniMax, Kimi, SiliconFlow, OpenRouter, and OpenAI costs.
  • Volcengine Ark / Doubao Coding Plan model-list verification, parser, and demo snapshot path.
  • npm, .app, .pkg, and .dmg installation paths.
  • Signed live adapters for Volcengine Ark, Alibaba Bailian, Zhipu, Baidu Qianfan, Tencent Hunyuan, StepFun, Baichuan, and ModelScope.
  • Optional CLI-first Linux and Windows builds.
  • Public website and notarized distribution pipeline.

License

MIT. See LICENSE.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors