API key billing spike alerts and spend caps on Google Cloud, OpenAI and Anthropic

Budget alerts don't stop a runaway API bill. Which controls on Google Cloud, Gemini, OpenAI and Anthropic cap spend, and how to set them up.

· 6 min read

  • billing
  • spend caps
  • google cloud
  • gemini
  • openai
  • anthropic
On this page

Setting a budget feels like setting a limit. It isn't. A Google Cloud budget sends an email, and it works from billing data that can be hours old. By the time it fires, the money is spent.

What stops a runaway bill is a control that rejects requests: a spend cap, a quota or a credit balance that runs out. This guide lists which controls on each provider do that, how late each one reacts, and how to set them up.

Alerts, caps and how late they are

Control Stops requests? How late it reacts
Google Cloud budget No, it sends alerts Billing data is usually there within a day, sometimes later
Gemini spend cap in AI Studio Yes, pauses the project Can overrun by about 10 minutes
Cloud Billing spend cap budget Yes, pauses one API in one project "Isn't instantaneous"
Google Cloud API quota Yes, rejects requests over the quota Some lag
Request count alert in Cloud Monitoring No, it sends alerts Up to 30 minutes
OpenAI spend limit Yes, returns errors "Not instantaneous"
Anthropic spend limit Yes, returns errors Not stated
Prepaid credits without auto reload Yes, when the balance runs out Not stated

Use at least one control from the "Yes" rows on every provider you pay, and an alert that's faster than billing on top.

Google Cloud and Gemini

Budget alerts

In the Google Cloud console, open Billing > Budgets & alerts > Create budget.

  1. Scope it to the project, and to the services you care about if you want a separate budget for, say, the Gemini API.
  2. Set the amount to a bit above a normal month.
  3. Add thresholds. Use actual spend at 50%, 90% and 100%, plus forecasted spend at 100%, which warns you while there's still time.
  4. Pick who gets the emails. By default that's the billing account's administrators and users. You can add Cloud Monitoring channels or a Pub/Sub topic.

Google is clear about what this doesn't do: "Setting an alerts-only budget doesn't automatically cap Google Cloud or Google Maps Platform usage or spending" (budgets). It also runs on billing data, which Google says is "typically" available within a day and can take longer (billing reports). Spend from a stolen key at $28 a minute, the rate in one 2026 case, adds up to about $40,000 in a day.

Spend caps for Gemini

Gemini now has real caps, added in 2026.

  • AI Studio project spend cap. In AI Studio, open the Spend page, then Monthly spend cap > Edit spend cap. Project owners, editors and admins can set it. Google marks it experimental and says you "are subject to overages for around a 10 minute latency period". Batch jobs can also run past it (Gemini billing).
  • Cloud Billing spend cap budget. A budget for one project, one service and one month. When costs pass 100%, Google pauses that service for the rest of the month. Nothing is deleted. It covers the Gemini API, Vertex AI and Cloud Run (spend cap budgets).
  • Tier caps. Every Gemini billing account has a monthly cap set by its tier: $250 on Tier 1 and $2,000 on Tier 2. Reaching it pauses every project on the billing account until the next month. That's a backstop. Set your own caps lower, so one bad key doesn't stop your other projects too.

If you set caps in both AI Studio and Cloud Billing, whichever triggers first wins.

Quotas for every other API

Most Google Cloud APIs have no spend cap, but each has quotas. Open APIs & Services, pick the API, open the Quotas tab, select the requests-per-day or requests-per-minute quota and choose Edit quotas (capping API usage).

Set it a little above your real peak. Requests over the quota fail with a "limit exceeded" error. Quotas apply to the whole project, not to one key, and Google notes enforcement has some lag, so leave a margin.

For Maps keys in public web pages, quotas on the Maps APIs are the cap that matters most.

A faster alert: requests per key

Billing is the slowest signal. Request counts arrive much sooner. In Monitoring > Alerting, create a policy on the Consumed API resource and the Request count metric, grouped by credential_id, so each key is checked on its own. Google says this metric can take up to 30 minutes to show up (metric details), which is still hours ahead of a budget.

How to automatically revoke an abused API key walks through that policy step by step, and shows how to have it switch off the key instead of only emailing you.

OpenAI

OpenAI has hard spend limits for the organization and for each project (spend limits).

  • Organization limit. Settings > Organization > Limits, then under Spend, Edit spend limit.
  • Project limit. Open the project's settings, then Limits > Spend > Edit spend limit.

Once a limit is reached, requests fail with a 429 error and the code organization_spend_limit_exceeded or project_spend_limit_exceeded. OpenAI says enforcement isn't instantaneous, so spend can go slightly over. Limits reset each month.

Spend alerts, set in the same place, only send notifications. They don't stop traffic.

Give each app its own project and its own limit. Then a stolen key from one app stops at that app's limit, and the others keep running.

If you pay with prepaid credits, auto recharge decides whether the balance can act as a cap. With it off, requests stop when the credits run out. With it on, the balance refills and requests keep going, so rely on the spend limit.

Anthropic

Anthropic has limits at three levels (rate limits and tiers, workspaces).

  • Organization spend limit. In the Claude Console, Billing > Spend limits > Set limit. Requests over it fail with a 400 error whose message starts "You have reached your specified API usage limits".
  • Workspace spend limits. Settings > Workspaces, pick the workspace, then Spend limits. You can cap a workspace's monthly spend and get emails when it reaches thresholds you set. A workspace limit can't be higher than the organization's, and the Default Workspace can't have one.
  • Tier caps. Each usage tier has a monthly ceiling. When you hit it, requests fail until the 1st of the next month.

As with OpenAI, one workspace per app makes the limit a per-app cap.

The API is prepaid. Under Billing, auto-reload tops up your credit balance when it drops to an amount you set. Without auto-reload, "If you run out of credits, you can no longer call the API" (Anthropic billing).

Picking the numbers

  • Caps: about one and a half to two times a normal month. Low enough that a theft hits it on day one, high enough that a good month doesn't.
  • Alerts: on rate, not totals. "This key is at eight times its usual hourly peak" fires in the first hour of an attack. "This month's spend passed $500" fires after the money is gone.
  • One key, one app, one environment. Then a cap or a revoke affects only the thing that's broken, and per-key numbers tell you which thing that is.
  • Test the cap. Set a tiny limit on a test project, run a few requests through it and check they fail the way you expect.

If a spike has already happened, the first hour after a key leaks covers what to do now, and unexpected Gemini API bill covers finding the cause and asking for an adjustment.

How Keyll handles this

Caps limit the damage. Keyll aims to stop it sooner, and only for the key that's being abused. It watches each key's usage every minute against up to four weeks of that key's own history, and alerts by email and Slack when a key reaches eight times its usual peak or calls a model it never used. If the abuse keeps going, it warns you, then blocks that one key, so your cap never has to switch off the whole project. Keyll hasn't launched yet. Join the waitlist to get one email when it does.

All guides