A Google Cloud budget alert does not stop anything. It sends an email, and the email is built from billing data that can arrive hours after the usage. A Vertex AI spend cap is different: it pauses new requests to the service once estimated spend passes your limit. This guide explains the gap between the two, shows how to set a spend cap in the console and through the Cloud Billing Budget API, and adds a small app-side cost guard for the minutes before any Google control reacts.
The trigger for this guide is a post that reached 602 points on Hacker News on December 4, 2026.
What happened in the C$76K Vertex AI story?
A user posted to r/googlecloud under the title "Google Sent Me to Collections". Everything in this section is the poster's own account. Google has not confirmed it publicly.
The poster says an overnight Gemini 2.5 Flash job on Vertex AI ran from September 28 into September 29. According to the post:
- Spending picked up around 10:00 PM Eastern.
- Around 5:00 AM, C$36,302 in startup credits ran out. Spend crossed a C$286 monthly budget at the same time, but the 50%, 80% and 100% budget emails never arrived.
- The first cost anomaly email arrived at 7:42 AM, which the poster calls "9 hours and 42 minutes late".
- The job stopped at 11:34 AM, when the poster's credit card declined an automatic C$8,600 charge.
- Billing support refused an adjustment. The account was suspended in November, and Google still wants C$63,896, now through its collections team.
The Hacker News thread did not take the post at face value. Several commenters said the text reads as AI-written, and one pointed out that spend caps reached general availability (GA) after the incident. Others defended Google: the user ran an unattended job and consumed the service.
The billing mechanics in the post do match Google's own documentation, which is why the story is useful even if parts of it are wrong. The rest of this guide sticks to what the docs say.
Why don't GCP budget alerts stop spending?
Google's budgets documentation is direct about this. It says an alerts-only budget "doesn't automatically cap Google Cloud or Google Maps Platform usage or spending." Alerts "might prompt you to take action", but nothing happens on its own.
Alerts are also slow, because they read the same billing data as your invoice:
- The budgets page says it "may take several hours before receiving the first email or Pub/Sub notification" after you create a budget, and that there is a delay between using a resource and its cost reaching Cloud Billing.
- The spend caps page says actual cost details are "typically available within a day, but can sometimes take more than 24 hours" to appear on billing reports.
- Programmatic notifications over Pub/Sub (Google's message queue service) use "at-least-once delivery", so messages can repeat or arrive out of order.
A commenter who says they worked on this feature at Google Cloud explained the root cause: "the data pipeline for billing in Google Cloud is very complicated and takes hours to reconcile." That is one unverified account, but it fits the documentation above.
This also limits the classic workaround. Google's disable-billing tutorial wires a budget to Pub/Sub and a Cloud Run function that removes billing from the project. It reacts to the same budget data, so it inherits the same delay. The tutorial also warns that it shuts down all resources and that "Resources might be irretrievably deleted."
What about the 20-minute alert in the post? Google's cost anomalies page describes "early anomalies" for the Gemini API and Vertex AI. They use near real-time cost estimates. The page says "the system delivers alerts with an expected latency of 20 to 40 minutes from the time of usage." The feature is in Preview, the thresholds are system-defined, and an expected latency is not a promise. Even when it works, it is still an alert.
What is a Vertex AI spend cap?
A spend cap is a budget with enforcement attached. Google lists the dates in the Cloud Billing release notes: Preview on July 27, 2026, and GA in the October 13, 2026 entry. The GA announcement on the Google Cloud blog followed on October 30. So at the time of the September incident in the post, spend caps were still a Preview feature.
According to the spend caps documentation, this is how it works:
- It uses estimated costs. The cap is checked against "gross, estimated costs", calculated from list prices without savings or credits. That is why it can react faster than billing reports. The GA blog post says spend caps for AI services "trigger within minutes of usage".
- It pauses new requests. Once estimated spend passes 100% of the amount, new usage of that service in that project is paused for the rest of the month. Usage covered by committed use discounts (CUDs) is paused too.
- It does not delete anything. Resources and data stay in place. Other services and other projects keep working.
- It resets monthly. On the first day of the next month, the cap lifts itself and the counter goes back to zero. You can also lift it by hand. After that it will not trigger again that month unless you raise the amount.
- It emails people. Billing account administrators and project owners get alerts at 50%, 80% and 100%. These recipients cannot be customized.
Google's docs now use a new name for the service: Gemini Enterprise Agent Platform (formerly Vertex AI). The API name is still aiplatform.googleapis.com.
What can a spend cap cover, and what does it miss?
The current list of eligible services is short. The documentation names four:
- Gemini API: service ID
AEFD-7695-64FA,generativelanguage.googleapis.com - Gemini Enterprise Agent Platform (formerly Vertex AI): service ID
C7E2-9256-1C43,aiplatform.googleapis.com - Cloud Run: service ID
152E-C115-5142,run.googleapis.com - Cloud Run functions: service ID
29E7-DA93-CA13,cloudfunctions.googleapis.com
The Reddit post says the cap covers six products. The documentation lists four. Google says more services will come in later releases.
Check the limits before you rely on it:
- One cap covers one project and one service. Folder, organization, label and multi-project budgets are out of scope.
- The period is always monthly. There is no daily cap.
- Reseller billing accounts are excluded.
- In-flight requests finish and are billed.
- Persistent resources, such as compute and storage, keep running and keep costing money.
- The GA blog post says "Provisioned Throughput is never halted." Reserved capacity keeps serving traffic.
- The cap is not instant. The docs say "any cost overages are billed as normal" and advise "setting your budget slightly below your absolute limit."
So a spend cap shrinks the damage window from hours to minutes. It does not close it.
How do you set a spend cap in the console?
The console flow, from the spend caps guide:
- Open Billing, then Budgets & alerts, and click Create new budget.
- In Define, choose Spend cap enforcement instead of Alerts only, and give the budget a name.
- In Scope, pick one project and one eligible service, for example Gemini Enterprise Agent Platform. The time range is locked to Monthly.
- In Amount, enter the target amount. Usage pauses when estimated spend passes it.
- In Actions, the 50%, 80% and 100% notifications are already set. Click Finish.
You cannot convert an existing alerts-only budget into a spend cap budget. Delete it and create a new one with the same scope. You need the billing.budgets.configureSpendCap permission on the billing account, or billing.resourcebudgets.configureSpendCap on the project.
How do you create a spend cap with the Budget API?
For many projects, the Budget API guide shows the same thing as a REST call. The sample below follows Google's request body. The changes are the budget name and the service ID, switched from the Gemini API to Vertex AI:
{ "displayName": "Vertex AI spend cap", "budgetFilter": { "projects": ["projects/YOUR_PROJECT_ID"], "services": ["services/C7E2-9256-1C43"], "creditTypesTreatment": "EXCLUDE_ALL_CREDITS", "calendarPeriod": "MONTH" }, "amount": { "specifiedAmount": { "units": "100", "nanos": 0 } }, "thresholdRules": [ { "thresholdPercent": 0.5 }, { "thresholdPercent": 0.8 }, { "thresholdPercent": 1.0 } ], "notificationsRule": { "enableProjectLevelRecipients": true }, "spendCap": { "inputState": "CONFIGURED" } } Save it as request.json and send it:
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-user-project: YOUR_API_PROJECT_ID" \ -H "Content-Type: application/json; charset=utf-8" \ -d @request.json \ "https://billingbudgets.googleapis.com/v1/billingAccounts/YOUR_BILLING_ACCOUNT_ID/budgets" The API is strict about spend cap budgets. The docs list these rules:
-
creditTypesTreatmentmust beEXCLUDE_ALL_CREDITS, because caps use gross costs. -
thresholdRulesmust be exactly 0.5, 0.8 and 1.0. Forecasted spend is not supported. -
notificationsRulemay only setenableProjectLevelRecipientstotrue. -
inputStatemust beCONFIGUREDwhen you create the budget.
When a cap fires, the budget's spendCap.outputState becomes ENFORCED. To lift it early, send a PATCH with updateMask=spendCap.inputState and set inputState to AWAITING_NEXT_PERIOD. You cannot edit or delete a budget while it is enforced, so lift it first. After a lift, services may take up to one hour to fully recover.
With the API, you can add the cap in the same script or Terraform module that creates a new project. The GA post suggests starting with "strict, low-dollar spend caps" on developer sandboxes and experimental agent projects.
Does lowering quotas stop a runaway Gemini job?
A commenter in the thread said quotas are the fast brake: lower the per-minute request and token quotas to what the app needs. Google Cloud does support this in general. The Cloud Quotas guide calls a lowered value a "quota override", sometimes called "capping usage". It also says "Quota overrides are not available to all services."
For Gemini models on Vertex AI, first check which consumption option you use. Under Standard PayGo, each usage tier sets a prioritized throughput threshold in tokens per minute (TPM), but the page says "Your traffic isn't strictly capped at your tier's TPM threshold." It also says a 429 error "doesn't indicate that you've hit a fixed quota." That is a capacity system, not a per-project budget brake. Do not count on it to stop a loop.
For other Google APIs with fixed per-minute quotas, a low override can still act as a brake. Another commenter described a stuck background service that produced a Google Maps API bill of about 4,000 pounds. Their fix: quotas set close to real usage, "so a runaway loop will hit 429s rather than my card."
What changes if you use the Gemini API instead of Vertex AI?
The Gemini API (the AI Studio side, generativelanguage.googleapis.com) has its own controls. They come from the Gemini API billing docs and rate limits docs:
- Prepay. New users default to the Prepay billing plan. When the credit balance hits $0, all API keys on that billing account stop and requests fail with HTTP 402. The docs warn of overages during "the approximately 10 minute billing pipeline latency."
- Project spend caps in AI Studio. These are marked experimental, with "around a 10 minute latency period" for overages. Batch jobs and agent sessions can run past the cap.
- Billing account tier caps. Tier 1 has a $250 monthly cap and Tier 2 has $2,000. Tier 3 ranges from $20,000 to $100,000 or more.
- Spend-based rate limits. On a rolling 10-minute window: $10 for Tier 1, $200 for Tiers 2 and 3. Going over returns
429 RESOURCE_EXHAUSTED. The docs say whether these apply "depends on your billing history and account standing."
If you set a Gemini API cap in both AI Studio and the Cloud Billing console, the spend caps FAQ says whichever budget sees the cost first triggers first, and the block applies to the project everywhere.
How do you add an app-side cost guard?
Every Google control above reacts in minutes or hours. Your own code can react before the next request. Two HN commenters described the same pattern. One writes the token count and cost of every call to a database and compares the day's spend with a budget. The Maps commenter keeps a running count of calls and stops a service when it is far above a normal hour.
The response from the google-genai Python SDK carries usage_metadata. In the SDK source (version 3.7.0), total_token_count is the sum of prompt_token_count, candidates_token_count, tool_use_prompt_token_count and thoughts_token_count. Google's Vertex AI pricing page prices "output and thinking tokens" together, so the guard below counts thoughts as output.
import sqlite3 import time from datetime import datetime, timezone class BudgetExceeded(RuntimeError): pass class SpendGuard: """Counts estimated LLM spend in SQLite and refuses calls over budget.""" def __init__(self, db_path, daily_limit_usd, hourly_limit_usd, input_usd_per_m, output_usd_per_m): self.db = sqlite3.connect(db_path) self.db.execute("CREATE TABLE IF NOT EXISTS spend (ts REAL, usd REAL)") self.daily_limit = daily_limit_usd self.hourly_limit = hourly_limit_usd self.in_price = input_usd_per_m / 1_000_000 self.out_price = output_usd_per_m / 1_000_000 def _spent_since(self, since_ts): row = self.db.execute( "SELECT COALESCE(SUM(usd), 0) FROM spend WHERE ts >= ?", (since_ts,) ).fetchone() return row[0] def check(self): now = time.time() midnight = datetime.now(timezone.utc).replace( hour=0, minute=0, second=0, microsecond=0).timestamp() today = self._spent_since(midnight) last_hour = self._spent_since(now - 3600) if today >= self.daily_limit: raise BudgetExceeded(f"daily limit hit: ${today:.2f}") if last_hour >= self.hourly_limit: raise BudgetExceeded(f"hourly limit hit: ${last_hour:.2f}") def record(self, usage): # Fields from google-genai's usage_metadata; missing ones count as 0. input_tokens = ((usage.prompt_token_count or 0) + (usage.tool_use_prompt_token_count or 0)) output_tokens = ((usage.candidates_token_count or 0) + (usage.thoughts_token_count or 0)) usd = input_tokens * self.in_price + output_tokens * self.out_price self.db.execute("INSERT INTO spend VALUES (?, ?)", (time.time(), usd)) self.db.commit() return usd Wrap every model call with it:
from google import genai from google.genai import types client = genai.Client(vertexai=True, project="YOUR_PROJECT_ID", location="global") guard = SpendGuard("spend.db", daily_limit_usd=20, hourly_limit_usd=5, input_usd_per_m=INPUT_PRICE, output_usd_per_m=OUTPUT_PRICE) guard.check() # raises BudgetExceeded before the call response = client.models.generate_content( model=MODEL_ID, contents=prompt, config=types.GenerateContentConfig(max_output_tokens=2048), ) guard.record(response.usage_metadata) Fill in INPUT_PRICE, OUTPUT_PRICE and MODEL_ID from the pricing page for the model you use. The class was run against simulated usage records, with no real API calls: at $1 and $10 per million tokens, a call with 200,000 input tokens, 20,000 output tokens and 10,000 thinking tokens cost $0.50, and a $1 hourly limit stopped the loop after two calls.
Limits of this design:
- It is an estimate. It charges cached tokens at the full input price, so it overestimates when you use context caching. That is the safe direction. It does not know about taxes, discounts or credits.
- It checks before the call and records after. Parallel workers can each pass
check()and overshoot by the calls in flight.max_output_tokensputs a ceiling on how much one call can cost. - The hourly limit is the important one. The poster's job ran for hours overnight. A limit sized to a normal hour stops that pattern long before a daily or monthly number does.
- SQLite is per machine. For several instances, keep the counter in a shared store such as your main database or Redis.
Which guardrail should you set up first?
Ordered by how fast each one acts:
- App-side cost guard: stops the next request, in your process.
- Spend cap budget (Vertex AI, Gemini API, Cloud Run): pauses new requests within minutes, from estimated costs.
- Gemini API prepay and spend-based rate limits: about 10 minutes of billing latency, Gemini API only.
- Early anomaly alerts: expected 20 to 40 minutes, Preview, email only.
- Alerts-only budgets and Pub/Sub automation: hours, sometimes more than a day.
Set up the first two before the next overnight job. Keep the last three as the backup signal, not the plan. Alerts tell you. Caps stop new requests.
FAQ
Does a Google Cloud budget stop spending when it hits 100%?
An alerts-only budget does not. It only sends notifications. A spend cap budget pauses new usage of one eligible service in one project once estimated spend passes the amount.
Does a spend cap cover Vertex AI?
Yes. Gemini Enterprise Agent Platform (formerly Vertex AI) is one of four eligible services, with service ID C7E2-9256-1C43.
Is spend cap enforcement instant?
No. Google says enforcement "isn't instant and any cost overages are billed as normal." It advises setting the cap slightly below your real limit.
Does a spend cap delete my resources?
No. It pauses new requests. Persistent resources keep running and keep billing, and Provisioned Throughput is never halted.
Can I set a daily spend cap?
Not with Cloud Billing spend caps, which are monthly only. For a daily or hourly limit, count costs in your own code.
