How to set a spending limit on the Gemini API
Last updated
Google gives the Gemini API three monthly spending limits: a spend cap you set on a project in Google AI Studio, the same kind of cap set as a budget in Google Cloud Billing, and a cap on your whole billing account that comes with your usage tier. If you prepay, your credit balance stops requests too. This page shows where to find and set them, what happens when one is reached, and what they don't cover.
Everything here was checked against Google's docs on November 12, 2026. The three reported messages and the note on API keys were added and checked on November 13, 2026. The sources are linked under the sections they back up.
The short version
- In Google AI Studio, open the Spend page.
- Under Monthly spend cap, click Edit spend cap.
- Enter an amount.
You need the project editor, owner or admin role. The cap can run about 10 minutes behind your spending.
Three limits, from Google and from you
- A project spend cap in AI Studio is one you set for each project. Google calls the feature experimental.
- A spend cap budget in Google Cloud Billing also covers one project, and you pick the Gemini API as its service. If you set caps in both places, the one that receives the usage cost first blocks the project's Gemini API usage, on every platform.
- Your tier's spend cap is set by Google for your whole billing account: $250 a month on Tier 1, $2,000 on Tier 2 and $20,000 to $100,000 on Tier 3. The free tier has none. Spend from every linked project that has the Gemini API enabled counts toward it.
AI Studio's spend caps aren't available on invoiced (offline) billing accounts, and Cloud spend cap budgets are only for first-party Google Cloud customers, not reseller accounts.
None of these is a limit on one API key. Google says API keys “have no independent billing settings”, and usage from every key in a project counts toward that project's spend cap. So a key that is the only key in its project is capped by that project's cap. If a key has already leaked, the steps for turning it off are in what to do when an AI API key leaks.
Sources: Google AI Studio, Billing, Google Cloud, Manage spend cap budgets
Set a project spend cap in AI Studio
- In Google AI Studio, open the Spend page.
- Under Monthly spend cap, click Edit spend cap.
- Enter an amount.
- Who can set it: accounts with the project editor, owner or admin role.
- It runs about 10 minutes behind. Billing data can take that long to process, and you pay for what's spent in the meantime.
- Long jobs can go over it. Google says batch mode completions and agent sessions may run past the cap.
- If you move the project to another billing account, the cap stays, but the spend counted so far starts again at $0.
Source: Google AI Studio, Billing
Set a spend cap budget in Google Cloud
- In the Google Cloud console, go to Budgets & alerts and click Create new budget.
- Choose Spend cap enforcement, not Alerts only. Give the budget a name and click Next.
- Select one project, and the Gemini API as the service. The time range is always monthly. Click Next.
- Enter the Target amount, click Next, then click Finish.
- Who can set it: for example, a Billing Account Administrator, or someone with Billing Account Costs Manager on the billing account and Editor on the project. Google's page also lists permissions you can grant on the project alone.
- It isn't instant. It works from estimated costs at list price, before savings and credits, and overages are billed as normal. Google suggests setting it a little below the most you want to spend.
- When it's reached, new Gemini API requests from that project are paused for the rest of the month. Requests already running finish and are billed. Nothing is deleted.
- To lift it early, open Budgets & alerts, select View spend cap details, open the budget and select Lift spend cap, then Confirm. Services can take up to an hour to come back. A lifted cap won't trigger again that month unless you raise the target amount.
- It resets at the start of each month. Billing administrators and project owners get notifications at 50%, 80% and 100%, and you can't change who gets them or when.
- If you move the project to another billing account, its spend cap budgets are deleted and you have to create them again. A cap that was enforced at the time is lifted.
- An Alerts only budget just sends alerts. Google says it “doesn't automatically cap” usage or spending.
Sources: Google Cloud, Manage spend cap budgets, Google Cloud, Budgets
Your tier's spend cap
When your billing account's total reaches the tier's cap, the Gemini API stops for every project linked to that billing account until the 1st of next month. So one runaway project can stop all your other projects on the same billing account.
- Moving up a tier is automatic once you qualify, though Google says it may deny an upgrade in rare cases. Tier 2 needs $100 paid for Google Cloud services, not only the Gemini API, and 3 days since your first successful payment. Tier 3 needs $1,000 and 30 days.
- To ask for a higher cap, use the request form linked from Google's Billing page.
- On postpaid billing, you're charged at the end of the month, or when your costs reach the cap for your tier.
Source: Google AI Studio, Billing
A 10-minute spend limit too
Google also limits how much you can spend in any 10 minutes: $10 on Tier 1, and $200 on Tiers 2 and 3. Google says whether these limits apply to you depends on your billing history and account standing. Go over one and requests fail with error 429 RESOURCE_EXHAUSTED. Google's advice is to wait and retry after a short period.
Source: Google AI Studio, Rate limits
What happens when you reach a limit
Your prepaid balance reaches $0
Requests fail with error 402 until you add credits. Every API key in every project linked to that billing account stops at the same time. Your projects don't drop back to the free tier; to get service back at your paid tier, you buy more credits. Google says not to retry a 402.
{
"error": {
"code": 402,
"message": "Your prepayment credits are depleted. Please go to AI Studio at https://ai.studio/projects to manage your project and billing. Learn more at https://ai.google.dev/gemini-api/docs/billing#prepay. ",
"status": "RESOURCE_EXHAUSTED"
}
}This response is from a GitHub issue dated November 7, 2026. Google's docs describe the error (“Your Prepay credit balance is depleted.”) but don't show the response. A notice on Google's developer forum dated September 18, 2026 says these requests returned a 429 until then. Our guide to this error covers adding credits and what to check if your balance isn't $0.
- It isn't instant. Google says prepaid billing can run over during the roughly 10 minutes its billing pipeline takes, and batch jobs and agents may keep using credits past your balance.
- Auto-reload buys more credits for you. To cap it, set a monthly auto-charge limit: once auto-reload has bought that much in a month, it turns off until the next month.
A spend cap is reached
Google's docs don't say which error you get when a project cap, a Cloud spend cap or your tier's cap is reached. On Google's developer forum, developers have posted a 429 RESOURCE_EXHAUSTED with the message “Your project has exceeded its monthly spending cap.” or “Your billing account has exceeded its monthly spending cap”. In one of them, AI Studio showed spend below the cap.
Developers also report a banner in AI Studio: “You've reached the billing account tier cap and service has been paused.” (forum posts from October 22 and November 3, 2026). At the tier limit, Google's Billing page says service is paused for every project linked to the billing account until the 1st of next month. “Your tier's spend cap” above covers moving up a tier and asking for a higher cap.
If requests stop while you still have prepaid credits, Google says you may have hit your tier's limit, or the status of your Cloud Billing account may be the cause.
“You exceeded your current quota”
{
"error": {
"code": 429,
"message": "You exceeded your current quota, please check your plan and billing details.",
"status": "RESOURCE_EXHAUSTED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Learn more about Gemini API quotas",
"url": "https://ai.google.dev/gemini-api/docs/rate-limits"
}
]
}
]
}
}Google's advice for a 429 is to check that you're within the model's rate limits, then wait and retry. In one report the message goes on to name the quota, free-tier requests per day, and says to retry in 13 hours (GitHub, November 10, 2026). For a daily quota like that one, Google's errors page for the Interactions API says to wait until the quota resets or ask for an increase. The check below retries this 429 up to its attempt limit, daily quota or not.
This response is from Google's developer forum, November 5, 2026. Google's docs don't contain the sentence. The spend cap messages above say “monthly spending cap” instead.
Sources: Google AI Studio, Billing, Google AI Studio, API errors, API errors (Interactions API), Google AI Developers Forum, April 21, 2026, August 24, 2026
Stop your code from retrying a cap
Google says to retry only transient errors, like 429, 408 or 5xx, with a maximum number of attempts, and not to retry errors like 400, 402 or 403. The 10-minute spend limit comes back as a 429, and the cap errors developers have posted are 429s too. A loop that retries every 429 with no limit can keep failing until the cap changes. Check before you retry:
from google.genai import errors
# For errors from client.models.generate_content
# Google: retry these, up to a maximum number of attempts
RETRY = {408, 429, 500, 502, 503, 504}
MAX_ATTEMPTS = 5
def spend_cap_reached(error: Exception) -> bool:
"""Best effort: a 429 whose message mentions a spending cap."""
return (
isinstance(error, errors.APIError)
and error.code == 429
and "spending cap" in (error.message or "").lower()
)
def should_retry(error: Exception, attempts: int) -> bool:
"""attempts: how many times this request has been sent so far."""
if not isinstance(error, errors.APIError) or attempts >= MAX_ATTEMPTS:
return False
if spend_cap_reached(error):
return False
# Everything else, such as 400, 402 (prepaid credits used up) and 403
return error.code in RETRYimport { ApiError } from "@google/genai";
// For errors from ai.models.generateContent
// Google: retry these, up to a maximum number of attempts
const RETRY = new Set([408, 429, 500, 502, 503, 504]);
const MAX_ATTEMPTS = 5;
// The SDK puts Google's whole error response, as JSON, in error.message
function googleMessage(error: ApiError): string {
try {
return String(JSON.parse(error.message)?.error?.message ?? "");
} catch {
return error.message;
}
}
// Best effort: a 429 whose message mentions a spending cap.
function spendCapReached(error: unknown): boolean {
return (
error instanceof ApiError &&
error.status === 429 &&
googleMessage(error).toLowerCase().includes("spending cap")
);
}
// attempts: how many times this request has been sent so far.
function shouldRetry(error: unknown, attempts: number): boolean {
if (!(error instanceof ApiError) || attempts >= MAX_ATTEMPTS) return false;
if (spendCapReached(error)) return false;
// Everything else, such as 400, 402 (prepaid credits used up) and 403
return RETRY.has(error.status);
}Call the retry check after each failed attempt. When it says yes, back off and try again. When the spend cap check says yes, stop and tell someone: the request will keep failing until the cap changes or the month resets.
- The spend cap check reads the message. Google doesn't document the error, so the check looks for “spending cap”, the wording developers report. Treat it as best effort. The attempt limit still stops the loop if the wording is different.
- The checks are for generate content calls:
client.models.generate_contentin Python andai.models.generateContentin TypeScript. Google now recommends the newer Interactions API for its latest features and models. That API raises different error classes, which these checks don't catch. - SDK retries. Google's troubleshooting page says the Python SDK retries transient errors up to four times. In our test with both SDKs at 3.2.0, that held for the Interactions API: one 429 became 5 requests by default. Generate content calls didn't retry by default, in all four SDK versions we tried. With retry options set (3.2.0 only; the older versions have no such option), they sent 5 requests, and a spend cap 429 was retried like any other 429. Count SDK retries toward your own limit.
We ran the checks with the Python SDK (google-genai 3.2.0 and 1.20.0) and the TypeScript SDK (@google/genai 3.2.0 and 1.10.0), against a local test server that sends the errors described above.
Sources: Google AI Studio, Troubleshooting, Google AI Studio, Rate limits, Google AI Studio, API errors, python-genai, js-genai
What the caps don't cover
- They're monthly. A loop can spend the whole month's cap in one night, and requests keep failing until you raise or lift the cap, or the month resets.
- They run behind. AI Studio's cap by about 10 minutes, and Cloud's isn't instant either. Google says batch mode and agent sessions may go over AI Studio's cap.
- The tier cap covers the whole billing account. One project can stop the others.
- They only see Google. OpenAI, Anthropic and OpenRouter each have their own cap. This guide covers all four.
Where Billfuse fits
Billfuse is the tool we built for these gaps. It doesn't replace Google's caps. Keep them on.
- One budget across Gemini and your other providers. Billfuse emails you at 50%, 80% and 100% of the budget, and can post to Slack too. Gemini support is in beta: Billfuse reads Gemini spend from your Google Cloud billing export in BigQuery, using a service account key. It counts spend before credits and discounts, so it can be higher than Google's bill. Each sync runs a small query in your project, which Google bills like any BigQuery query.
- Spike alerts, with no budget needed. When one provider's day reaches 3 times a normal day, and at least $10 more, you get an email, and a Slack message if you added one.
- What it can't do. It can't pause Gemini. And Google's billing data usually arrives within a day, sometimes later, so Gemini spend, and any alert it triggers, reaches Billfuse about a day late. Google's own caps are much faster. Billfuse also doesn't read your prepaid credit balance, so it doesn't warn you when credits are about to run out.
More guides
- How to put a hard spending cap on OpenAI, Anthropic, Gemini and OpenRouter
- How to set a hard spending limit on the OpenAI API
- How to set a spending limit on the Anthropic API
- How to set a spending limit on the OpenRouter API
- Billing error or rate limit? AI API errors from OpenAI, Anthropic, Gemini and OpenRouter
- Leaked AI API key: what to do first
- Fix "Your credit balance is too low to access the Anthropic API"
- Gemini API error 402: "Your prepayment credits are depleted"
- OpenAI error 429 insufficient_quota: "You exceeded your current quota"
- OpenRouter 402: "This request requires more credits, or fewer max_tokens"
It's free while Billfuse is in early access. You can try it with sample data first, no sign-up needed.