Gemini API error 402: "Your prepayment credits are depleted"
Last updated
If the Gemini API answers with HTTP 402 and “Your prepayment credits are depleted”, stop retrying and check your Prepay credit balance in Google AI Studio. In Google's docs a 402 means one thing: your Prepay credits have run out. Requests fail until you add credits.
Everything here was checked against Google's docs on November 13, 2026. Parts that rest on forum posts say so and give the date.
The short version
- Stop retrying. Google says the request won't succeed until credits are added.
- Check your Prepay credit balance on the AI Studio Billing page.
- If the balance is $0 or less, select Buy credits.
Every API key in every project on that billing account stops at the same time. If AI Studio shows a balance above $0 and the error continues, see “If your balance isn't $0” below.
The full error
{
"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 is the response as a notice on Google's developer forum showed it on September 18, 2026, spaces included.
- The HTTP status is 402. The status field says
RESOURCE_EXHAUSTED, the same string a 429 carries. Google's API errors page for generate content lists both, and describes the 402 as “Your Prepay credit balance is depleted.” - The sentence isn't in Google's Gemini API docs. We searched the docs' full-text file (aistudio.google.com/llms-full.txt) on November 13, 2026: “prepayment credits” appears 0 times. The docs only have the description above.
- On the Interactions API, the docs list the error code
payment_requiredwith HTTP 402. They don't show its message. - In the Python SDK, the exception text starts with
402 RESOURCE_EXHAUSTED.and then repeats the response. That is how it read in our test, described further down. - Match on the status, not the text. The notice has four spaces before the first link. A developer's paste from September 28, 2026 shows one.
- Both links lead to AI Studio. When we checked, ai.studio/projects redirected to aistudio.google.com/projects, and the billing link to aistudio.google.com/docs/billing.
Sources: Google AI Developers Forum, notice of September 18, 2026, forum post of September 28, 2026, Google AI Studio, API errors (generate content), API errors (Interactions API)
A forum notice says it used to be a 429
The same forum notice announced a change: “Requests failing because a project's prepayment credits are depleted will now return HTTP 402 Payment Required instead of HTTP 429 Resource exhausted. This change separates retriable errors from ones that require your attention to resolve.” It adds that other rate limit errors keep returning 429.
- It's a forum post, not documentation. The account that posted it has the title “Google”, and the forum doesn't mark it as staff. Google's Gemini API docs list the 402 today, but neither those docs nor the release notes mention the change.
- Older threads show this sentence with a 429. If you search for the error and find “429 RESOURCE_EXHAUSTED” next to it, the post is likely from before the change.
- The difference matters to retry logic. In our test, with retries turned on, the SDKs sent a 429 again. They didn't send the 402 again. See “Don't retry a 402” below.
Sources: Google AI Developers Forum, notice of September 18, 2026, forum post of September 16, 2026, Google AI Studio, Release notes
What Google says happens at $0
On the Prepay billing plan you buy credits first, and Google deducts your Gemini API usage from that balance in near real time. Google rolled the plan out on March 23, 2026.
Google's Billing page says new users default to Prepay. The same page also says accounts created after that date may start on Postpay and be switched to Prepay later. Its FAQ says new users “might be required” to use Prepay. Google says it is moving developer accounts from Postpay to Prepay for the Gemini API. The cutover date is in each account's notice.
- Every API key on the billing account stops. Google: “all API keys in all projects linked to that billing account will stop working simultaneously.” The forum notice speaks of a project's credits, but Google's Billing page puts the balance on the billing account.
- Keys have no billing of their own. Google says API keys inherit the billing status of their project.
- Prepay credits pay only for the Gemini API. Google: “Prepay credits apply only to Gemini API usage costs; you can't use them to pay for other Google Cloud services.” Google Cloud's docs say that when the balance is exhausted, “the specific service requiring prepayment stops working until you add more credits.”
- You don't drop to the free tier. Google: “Your projects aren't automatically downgraded to the Free Tier.” To use the free tier, you would disable billing on the project. Google says some projects need verification first, and that not all projects or accounts are eligible for the free tier.
- “Immediately”, or about 10 minutes later. Google's Billing page says both. Its FAQ says services “will stop immediately”. A note on the same page says Prepay billing “is subject to overages during the approximately 10 minute billing pipeline latency”. It adds that batch mode and agents may keep using credits past your balance. Your balance can then show as negative.
- Google Cloud credits stop being used too. Google: “When your Prepay credit balance on the billing account hits $0, Google Cloud credits will no longer be consumed.”
- Listing models can still work. Google says a 200 from
models.listdoesn't mean generate content calls are enabled. That endpoint only checks that your API key exists, not your billing status.
Sources: Google AI Studio, Billing, Troubleshooting, Release notes, Google Cloud, In-product Cloud Billing setup
Don't retry a 402
Google's API errors page says: “Don't retry this request: it won't succeed until credits are added.” Its troubleshooting page lists 402 with 400 and 403 as errors not to retry. Check for it before you retry:
from google.genai import errors
# For errors from client.models.generate_content
def prepay_credits_depleted(error: Exception) -> bool:
"""A 402. Google: the Prepay credit balance is depleted, don't retry."""
return isinstance(error, errors.APIError) and error.code == 402import { ApiError } from "@google/genai";
// For errors from ai.models.generateContent
// A 402. Google: the Prepay credit balance is depleted, don't retry.
function prepayCreditsDepleted(error: unknown): boolean {
return error instanceof ApiError && error.status === 402;
}When the check says yes, stop the job and tell someone who can add credits. Every other key on the billing account is failing the same way.
- The check is for generate content calls:
client.models.generate_contentin Python andai.models.generateContentin TypeScript. The Interactions API raises different error classes, which this check doesn't catch. - SDK retries. In our test, the default client sent this 402 once, in all four SDK versions we tried. With retry options turned on, the 3.3.0 SDKs sent a 429 five times and the 402 once. The two older versions have no retry option. The Interactions API client in 3.3.0 retries without being asked: it sent a 429 five times and a 402 once.
- For the other statuses, see “Stop your code from retrying a cap” in our Gemini spending limit guide. It has a fuller retry check.
We ran the check with the Python SDK (google-genai 3.3.0 and 1.20.0) and the TypeScript SDK (@google/genai 3.3.0 and 1.10.0), against a local test server that sends the error above and eight others.
Sources: Google AI Studio, API errors (generate content), Troubleshooting, python-genai, js-genai
Add credits, and how long they take
- Open the AI Studio Billing page.
- Select Buy credits.
- How much: Google's Billing page gives a minimum purchase of $5 and a maximum of $5,000. Its FAQ says the purchase screen shows the minimum for your region and tier.
- How long: The FAQ on Google's Billing page says that after you buy credits, you should be able to use the Gemini API. It adds: “there might be a delay while our systems update to reflect your credit balance”. It doesn't say how long. The same page's section on processing times says most card payments are instant, and some payment methods, like bank transfers, may take several days to clear. Service resumes only once the purchase is confirmed.
- A negative balance comes off first. If usage ran past $0, Google deducts the negative balance from your next credit purchase.
- Auto-reload tops up the balance when it runs low. In the Available credits card, click Setup auto-reload or Manage auto-reload. Set the payment method, the reload amount and the balance that triggers a reload. You can also set a monthly auto-charge limit: once auto-reload has bought that much in a month, it turns off until the next month.
- Credits expire, and Google limits refunds. Google's Billing page says unused credits expire after 12 months, and that “Refunds aren't allowed for Prepay billing accounts, except when switching account types.” The same page's FAQ says switching from Prepay to Postpay isn't supported. The two don't agree. The details are in Google's Refunds section.
- If Prepay was never set up, the Projects page in AI Studio shows it. Google says a project that needs action shows Set up billing, Set up Prepay or No credits, and that you click the message to continue.
Auto-reload keeps buying credits as you spend them. To put a monthly cap on what a project can spend, see our Gemini spending limit guide.
Source: Google AI Studio, Billing
If your balance isn't $0
Developers keep posting this error on Google's forum while they see money on their account. On November 13, 2026, a forum search found dozens of such threads: their titles say the account is funded or the balance is positive. We can't tell you which case is yours. Here is what Google's docs say, and what developers and forum moderators have written.
You paid in the Google Cloud console
Google Cloud's docs say Prepay credits “are stored in a separate balance”. Google's Billing page says the balance and its transaction history are managed in the AI Studio Billing tab.
- November 2, 2026: a developer reported paying USD 30 into a Cloud Billing account and still getting the 402. A forum moderator replied the next day: “Payments added directly to a Google Cloud Billing account in Cloud Console do not fund the separate Prepay credit balance used in Google AI Studio”. The same reply says: “There is no manual sync process at our end.”
- September 16, 2026, when the status was still 429: a developer reported the error with a funded balance. Five days later the same developer wrote: “the pre-payment was made at console.cloud.google.com and it didn't work, we then made a pre-payment at aistudio.google.com and then it worked.”
These are forum posts, not documentation.
You have Google Cloud credits
Google says Prepay users must buy Prepay credits before any eligible Google Cloud credits can be used for the Gemini API. A developer with monthly Google Cloud credits reported the 402 on September 28, 2026. A forum moderator answered the next day by quoting that rule.
Google also says its $300 Welcome credit can't be used for the Gemini API at all on billing accounts opened after March 2, 2026.
You see a positive Prepay balance
- October 5, 2026: a developer reported the 402 with a positive Prepay balance on the AI Studio Billing page, and a No credits warning on the project.
- November 9, 2026, in the same thread: a second developer reported the 402 with a positive prepaid balance. The post doesn't say where the balance was shown. On November 13, a moderator asked whether it was the Prepay credit balance in AI Studio.
- October 9, 2026: a developer reported the 402 on every model with a $14.27 prepaid balance. That post doesn't say where the balance was shown either.
In both threads, forum moderators asked for details in private, and neither thread showed an outcome when we checked.
Google's Billing page names two causes for usage that stops while the balance is above $0. One is your tier's usage limit. The other is the status of your Cloud Billing account, such as a missed payment for other Google Cloud services. It doesn't say which error either one returns. Google's API errors page puts an unpaid balance under 403 PERMISSION_DENIED, and so does its troubleshooting page. The API errors page lists “exceeding spend-based limits for your account's billing history and tier” under 429. It lists neither under 402.
Google's Billing page also describes adding Prepay to an existing Postpay account and canceling halfway. The billing account stays in a state that restricts the linked projects that rely on Prepay services. To restore service, Google says to finish the setup or contact Cloud Billing support.
If none of this fits, Google's docs point to its developer forum for questions and to Cloud Billing support for billing help. In one of the threads above, a moderator asked the developer to send the project ID and the billing account ID through a form, not in the thread.
Sources: Google AI Studio, Billing, Google Cloud, In-product Cloud Billing setup, API errors (generate content), Troubleshooting. Google AI Developers Forum: November 2, 2026, September 16, 2026, September 28, 2026, October 5, 2026, October 9, 2026
Where Billfuse fits
Billfuse is the tool we built to watch AI API spend. It would not have prevented this error. It reads Gemini spend about a day late, it doesn't read your Prepay balance, and it can't pause Gemini.
- Gemini spend reaches it about a day late. Gemini support is in beta: Billfuse reads Gemini spend from your Google Cloud billing export in BigQuery. It syncs every hour, but Google's billing data usually arrives within a day, sometimes later. A balance that runs out in a few hours is gone before Billfuse sees the spend.
- It doesn't read your Prepay balance. Billfuse reads what you spent, not what you have left.
- It can't pause Gemini. Pause exists only for OpenAI and Anthropic. It's off unless you turn it on, and it isn't instant.
- It can't help when the balance isn't $0. See “If your balance isn't $0” above.
What Billfuse does: one monthly budget across OpenAI, Anthropic, Gemini and OpenRouter, with emails at 50%, 80% and 100% of it. It also alerts you when one provider's day reaches 3 times a normal day, and at least $10 more. For Gemini, both arrive about a day late. Against this error, use Google's own tools: check the balance on the AI Studio Billing page, and if you turn on auto-reload, give it a monthly limit.
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 Gemini 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"
- 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.