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