Use an AI service
Predict a bill, keep a key private and handle limits.
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.
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.
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.
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.
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.