Share

Keeping the monthly API bill under control in an AI feature

Open · 5 views · asked by amara_v · edited

We run on grant money, so a surprise bill is a real problem. Step 1 is non-negotiable: without a log per call you are guessing which feature costs what, and you will guess wrong.

Workflow
Not copied yet
1. Log every call: model, input tokens, output tokens, cents, user. One row per call.
2. Cap the input. Truncate user text to a length you have tested, and never send a whole document by default.
3. Start on the small model. Move one feature to the big model only when the small one measurably fails.
4. Cache on a hash of the input. Repeat questions are most of the bill.
5. Add a per-user daily cap and a hard monthly cap that switches the feature off rather than billing on.
6. Read the log weekly. There is always one feature that is half the spend.
Comment

Activity