Use an AI service

Predict a bill, keep a key private and handle limits.

  1. Why is my AI app bill higher than I expected?

    AI services bill every token sent and every token written back, and each chat turn sends the whole chat again, so a bill grows faster than the chat does.

    5 min+12 min deeper

  2. What is prompt caching, and when does it save money?

    Prompt caching reuses the work done on the start of a recent request. It saves money only when the same long start returns soon, with changing text last.

    6 min+18 min deeper

  3. Why an AI API key must never go in a web page or app

    Anyone can read a key in a web page or app. Keep it on your own server, add limits there, and know what to do if it leaks.

    6 min+12 min deeper

  4. What 'too many requests' means, and what your app should do

    A service caps how fast you may call it. When it says too many requests, wait longer each time, with a random part, so retries do not land together.

    5 min+12 min deeper

  5. How to stop one user running up your AI bill

    A request limit does not cap cost. Give each signed-in user a money budget, set aside the most a call can cost before it runs, then charge the real cost.

    5 min+13 min deeper