How to Set Spending Limits and Alerts on AI and Cloud API Accounts
Stolen AI keys from the Railway breach ran up about $740,000 in charges. Here is how to cap spending and get alerts on OpenAI, Anthropic and Google Cloud accounts.
In this article
- Key takeaways
- Before you start
- Step 1: OpenAI API platform
- Set an organisation-wide cap
- Set a cap per project
- Step 2: Claude (Anthropic) Console
- Create a separate workspace
- Set the spend limit and alerts
- Step 3: Google Cloud (including Gemini and Vertex AI)
- Step 4: Reduce the damage a leaked key can do
- Troubleshooting
- Checklist
- Sources
On 10 November 2026, the developer platform Railway published an updated report on an October breach. Attackers decrypted customer environment variables, the place where many apps keep their API keys, for up to 1.85% of workspaces. They specifically hunted for AI provider keys, and the stolen credentials generated about $740,000 in unauthorised AI usage. Railway says it is working with providers on refunds, but the lesson for everyone else is clear: if a key leaks, a spending cap is what stands between you and a huge bill.
This guide is for small businesses, startups and freelance developers in Nigeria and across Africa who pay for AI or cloud services with a company or personal card, often in dollars. It walks through the exact settings on three popular platforms.
Key takeaways
- Alerts warn you; hard limits stop usage. You usually want both.
- Give each app or environment its own project or workspace, with its own key and its own limit.
- Google Cloud’s standard budgets only send alerts; they do not cap spending on their own.
- Rotate keys immediately if a service you use reports a breach.
Before you start
- Owner or admin access to each account.
- A realistic monthly figure for each app. Check last month’s usage page to set it.
- A shared inbox (for example, billing@yourcompany) for alerts, so they are not lost when one person is away.
Step 1: OpenAI API platform
Set an organisation-wide cap
- Sign in to the OpenAI platform and open Settings > Organization > Limits.
- Under Spend, select Edit spend limit.
- Enter your Monthly spend limit.
- Turn on Enforce a hard limit. Without this, OpenAI only notifies you and traffic continues.
- Select Save.
Set a cap per project
- Open Project settings for the project and select Limits.
- Under Spend, select Edit spend limit, enter the amount, turn on Enforce a hard limit and save.
When a hard limit is reached, requests fail with a 429 error until you raise the limit or the next monthly cycle begins. OpenAI notes enforcement is not instant, so spending can slightly exceed the figure. Spend alerts keep working alongside hard limits, so set an alert below the cap to get advance warning.
Step 2: Claude (Anthropic) Console
Create a separate workspace
- In the Claude Console, go to Workspaces and click Create workspace.
- Name it after the app or environment (for example, “Website chatbot – production”) and click Create workspace.
- Create API keys inside this workspace so each key can only use that workspace’s resources.
Set the spend limit and alerts
- On the Workspaces page, select the workspace.
- In the panel that opens, click Spend limits, set a monthly cap and add alert thresholds.
Important: you cannot set spend limits on the Default Workspace, which is another reason to move real apps into their own workspaces. You can also lower per-model rate limits on the Rate limits page by choosing the workspace from the Workspace dropdown and clicking Edit next to a model. Lower rate limits slow down how fast a stolen key can burn money.
Step 3: Google Cloud (including Gemini and Vertex AI)
- In the Google Cloud console, open Billing > Budgets & alerts and choose your billing account.
- Click Create budget, select Alerts only and give it a name.
- Under Scope, keep the time range as Monthly and pick the projects or services to watch.
- Under Amount, choose Specified amount and enter your target.
- Under Actions, keep or adjust the default thresholds of 50%, 90% and 100%. Consider adding a Forecasted threshold so you are warned before you actually reach the amount.
- Under Manage notifications, choose who receives the emails, then click Finish.
Google is explicit that an alerts-only budget does not cap usage or spending. Notifications can take hours to arrive and costs are reported with a delay, so set the budget below the money you can actually afford to lose. For eligible services, Google also offers a separate spend cap budget on a project; check whether it applies to the services you use.
Step 4: Reduce the damage a leaked key can do
- One key per app. If one leaks, you revoke it without breaking everything else.
- Never put keys in website code, mobile apps or public code repositories. Keep them in your hosting platform’s secret settings.
- Rotate keys after any breach notice from a provider you use, as Railway told its customers to do.
- Use a dedicated card with a low limit for API billing where your bank allows it, so a runaway bill cannot drain your main business account.
Troubleshooting
- My app suddenly returns 429 errors. On OpenAI, check whether you hit your own hard limit (the error mentions organization or project spend limit) or ran out of prepaid credit.
- I can’t see the Spend limits option in Claude Console. You may be in the Default Workspace or may not have the right role. Ask an organisation admin.
- I set a Google Cloud budget but got no email. Emails are only sent when a threshold is crossed, and the first alerts can take several hours.
Checklist
- Organisation-wide hard limit set on OpenAI
- Each live app in its own project or workspace with its own key
- Per-project or per-workspace caps and alerts configured
- Google Cloud budget with actual and forecasted thresholds
- Alerts going to a shared inbox
- Keys stored only in secret settings and rotated after any breach notice
Sources
Was this article helpful?
adminVerified expert
Cybersecurity Analyst
Federal Capital Territory (Abuja)
Credentials: MCPN, MNCS, IAENG | System Analyst · Web Developer · CEH · CC · CDST
Got expertise to share? Write for us →


