How do I stop an AI feature from running up a big bill?
Cap it in two places. With your AI service, buy small prepaid credits, keep auto-reload off and set a monthly spend limit. In your app, have your AI tool add sign-in, a limit on uses per person and short answers, so one person or a bot can’t drain your credits.
Find your situation
- If you use the Claude API
- In the Claude Console, open the Billing page. Under Spend limits, click Set limit and enter a monthly amount. Leave auto-reload off. Once you reach your limit, requests fail with a 400 error until you raise the limit or the month resets.
- If you use the OpenAI API
- Auto-reload starts on when you first buy credits, so turn it off. Then open Project settings, select Limits, then Edit spend limit, and turn on Enforce a hard limit. Add a spend alert at a lower amount to get a warning first. The hard limit can go slightly over before it stops requests.
- If you use Gemini on the paid tier
- In Google AI Studio, open the Spend page and click Edit spend cap under Monthly spend cap. Set it a little low, because billing can run about 10 minutes behind. An alerts-only budget in Google Cloud sends emails but doesn’t stop spending.
- If anyone can use your AI feature without signing in
- Then anyone, including a bot sending thousands of requests, spends your credits. Ask your AI tool to require sign-in before the AI runs, and to limit how many times each person can use it in an hour and a day.
Who does what
You
- Buy credits in small amounts and keep auto-reload off.
- Set the monthly spend limit or cap in your AI service’s billing settings.
- Decide whether people must sign in first, and how many uses each person gets.
- Check your AI service’s usage page often in the first weeks after you put it online.
Your AI tool
- Make the AI feature work only for signed-in people.
- Add a limit on how many times each person can use it in an hour and a day.
- Cap how long people’s input can be, and how long the AI’s answer can be.
- Compare a smaller, cheaper model and tell you what one use costs with each.
- Show a clear message when a rate limit, a spend limit or an empty balance stops a request.
- Check that the key is only in server code, and never in files a browser or phone downloads.
Hand this to your AI tool
I want to make sure my app’s AI feature can’t run up a big bill. Look at how my product calls the AI service. Then check that service’s current official docs on spend limits, rate limits and errors, and do this: - Tell me, step by step, how to set a monthly spending limit in its billing settings. I’ll do the clicking. Don’t change any account settings yourself. - Make the AI feature work only for people who are signed in. If my app has no sign-in yet, explain my options and what each costs, and wait for my choice. - Add a limit on how many times one person can use the feature in an hour and in a day. Ask me what the limits should be. - Cap how long a person’s input can be, and how long the answer can be. - Check whether a smaller, cheaper model would do the job, and tell me what one use costs with each. - Show a clear message when a limit is reached, when credits run out, or when the service is busy. This comes from https://buildladder.com/answers/ai-spending-limit. If you can open web pages, read https://buildladder.com/answers/ai-spending-limit.md for the current version. BuildLadder guide, tool, concept, answer and setup pages all work this way: add .md to the address. Ask me before you install anything, sign in to anything or spend money. Never ask me to paste a password or secret key into this chat.
Where to go next
- AI features
- Claude API
- OpenAI API
- Gemini API
- Why doesn’t my Claude or ChatGPT subscription pay for the API?
- Is Gemini’s free tier OK for my app?
- I shared a secret key by mistake. What do I do now?
- How much does it cost to build and run a small app?
- What is a rate limit?
- What is a spending limit?
- What are credits?
- What is auto-reload?
- What is authentication?
Updated Sources: Claude API spend and rate limits, Claude: paying for API usage, OpenAI spend limits and alerts, OpenAI: prepaid API billing, Gemini API billing and spend caps, Gemini API pricing, Google Cloud budgets and alerts.