Dear Past Me: Never Start a Free AI Stack Without a Token Audit
说明与用途
文章说明了在免费 AI 堆栈中缺乏令牌计数会导致资源浪费和效率低下。建议添加请求日志到 CSV 并使用预算守护程序来防止超支和无声失败。
问题
Using free AI tiers without token accounting leads to wasted tokens, silent failures, and runaway costs.
结果
Token usage became transparent, silent failures were detected, and budget overruns were prevented, saving productive time and avoiding unexpected costs.
工作流
- Wrap every LLM call in a logger that records prompt/completion tokens, errors, elapsed time, and timestamp.
- Store each log entry as a CSV row in usage.csv.
- Before starting expensive work, read usage.csv to calculate spent tokens.
- If spent tokens exceed the allowance minus a buffer, abort or reduce workload to stay within budget.
- Use the budget guard in retry loops to avoid infinite retries.
- Monitor usage.csv regularly to maintain visibility into token consumption.
证据
Wrap every API call in a usage logger before any loop starts.
Add a budget guard that reads the CSV before starting expensive work.
- 记录日期: 2026-09-07T13:22:55.307Z