Measure the Burn Rate: A Token Meter for Quota-Limited AI Coding Servers
说明与用途
令牌计量器为免费 AI 代码服务器用户提供每日令牌消耗可视化,计算燃烧速率并预测配额耗尽。
问题
Users of free AI coding servers cannot see token consumption until a request fails, making it hard to manage quotas.
结果
The token meter provides real‑time visibility into token consumption, enabling users to predict when their free quota will run out and adjust usage accordingly.
工作流
- 1. Create a SQLite table to store usage records.
- 2. Wrap the OpenAI client in a MeteredClient that logs prompt, completion, and total tokens per request.
- 3. Implement a burn_rate function to aggregate usage over the last N days and compute tokens per day.
- 4. Use a report function to display total tokens, requests, elapsed days, burn rate, and days left until quota exhaustion.
- 5. Integrate the MeteredClient into existing workflows (editor, scripts, CI).
证据
The meter has three components: a SQLite table for usage records, a wrapper around the OpenAI client, and a report function.
Without a meter, the first sign of trouble is a 429 or a quota‑exceeded error in the middle of a task.
- 记录日期: 2026-09-07T22:37:45.385Z