General information, not a security guarantee. Apps that handle payments or health data should get a professional review.
The short version
An AI feature costs you money every time someone uses it. Your app sends each question to an AI provider, such as Anthropic or OpenAI, and the provider bills you for every answer. So a bill spikes when something uses your AI feature far more than you expected. Four common traps cause it:
- An AI key in the browser. A stranger copies it and runs their own work on your bill.
- An AI feature anyone can call, as often as they like. A bot (a program that visits sites by itself) can call it all night.
- No size limit. One visitor sends a huge question, or the AI writes a very long answer, and you pay for all of it.
- A retry that never stops. If the AI call fails, the app tries again and again, from a single click.
Put a cap in three places, before you share your link.
What goes wrong without it
Say you add an “ask the cook” box. A function is a small piece of your app that runs on a server, not in the visitor’s browser. Your function sends each question to the AI provider. If anyone can call that function without signing in, a bot can call it thousands of times. If it has no size limit, each of those calls can be large. Only a spending limit stops it then.
Set a spending limit first
Set the monthly limits first. They are your last line if the other two caps fail. A limit that stops requests is different from an alert that only warns you.
We didn’t open these dashboards. The menu names come from each company’s page, checked on 20 November 2026. As of that date, they say:
- Anthropic (maker of Claude). In the Claude Console, Anthropic’s account website, open the Spend limits page. Next to Monthly spend limit, choose Set limit or Adjust limit. When you reach your limit, requests fail with an error until the date the message gives, or until you raise or remove the limit. The page describes no spending alert. Anthropic’s page
- OpenAI. Open Organization limits. In Spend, choose Edit spend limit, enter a Monthly spend limit and turn on Enforce a hard limit, which makes requests fail at the limit. A project has the same under Project settings, then Limits. OpenAI also has spend alerts, which send a notification but don’t stop anything. Its page says the limit isn’t enforced at once, so spending can go slightly over. OpenAI’s page
- Supabase, if your database is on it. The Spend Cap is on the Pro plan only; Supabase’s page says you aren’t charged on the Free plan. Find it in the Cost Control section of your organization’s billing page. When it is on, use of a covered item past your plan’s amount stops until the next billing period. Only some items are covered. When it is off, your project keeps running and you pay for the extra. The page says the Spend Cap sends no notifications, and points to your organization’s usage page. Supabase’s page
- Your host, the service that puts your site online. Look in its billing settings for a “spend” or “budget” setting. On its own help page, check four things: where the setting is, whether it only warns or really stops, which plan has it, and what visitors see when it stops.
Where a company sends no alert, put a date in your calendar each month to open its usage page and look.
Find the traps with Claude Code
Claude Code is Anthropic’s coding assistant. Run it in the folder that holds your app’s code. It can find all four traps in your code. It can’t see your provider or host settings, so the limits above are still yours to set.
- Paste the prompt below. It asks Claude not to change anything. In our test, Claude was only allowed to read files.
- Read the answer. Each problem should say where it is, what could happen and the fix. Things that already have their guard come under “Looks right”.
- Ask Claude to fix one problem at a time, and read what it plans to change first. We did not test this step.
- Run the prompt again. It should say “0 problems found”.
I am about to share the link to this app. Check what could run up my AI bill. Read only: change nothing. Never show a whole key. Write no dollar amounts.
Report a problem only if it is one of these four:
1. An AI call made from the browser with a key.
2. An AI function that anyone can call without signing in, or with no limit on how often a person can call it.
3. An AI call with no cap on the length of the reply, or on what the visitor sends.
4. A retry or loop that can call the AI again and again with no cap.
For each problem say where it is, what could happen, and the fix, in plain words. If a function already has the guard, list it under "Looks right". If there are none of the four, say "0 problems found". Smaller worries go under "Smaller notes", not under problems.
Then list the spending limits I should set with my AI providers and my host, and say what you could not check from the code.In our test on Claude Code 2.1.329, a small made-up recipe app had three planted traps: an OpenAI key used from the browser, an “ask” function anyone could call with no limit and no size cap, and a retry that never stopped. In both runs Claude found all three, and it didn’t flag the parts that already had their guard. On a fixed copy, which we made ourselves rather than by following step 3, both runs said “0 problems found”. With an earlier prompt that didn’t say “report a problem only if” or where smaller worries go, Claude reported seven problems on that same fixed copy, so paste the prompt whole.
Claude’s answer ends with spending limits to set. In every run it named alerts that the companies’ pages above don’t describe, so follow the steps above, not that list.
How to check it worked
- Run the prompt again after your fixes. It should say “0 problems found”.
- Open each provider and host page you set up and look for the limit you saved. If you can’t see it there, it isn’t set.
- Sign out of your app and try the AI feature. It should ask you to sign in. We did not test this step.
If an AI key turned up in the browser, cancel it first: Where are my API keys, and who can see them? shows how. The login required check skill checks in Claude Code whether people who aren’t signed in can reach your app’s server functions.
Before you launch, check
- A monthly spending limit that stops requests, at every AI provider you use
- Your host's spending setting found, and you know whether it warns or stops
- Every AI feature needs a sign-in and has a limit per person
- Every AI call has a cap on the reply length and on what the visitor sends
- No retry or loop can call the AI without a cap
- A monthly date in your calendar to read your usage