GrepBoard/Manuals
605 manuals ·

Gemini API 402 payment_required: Prepay Credits Depleted

·Tested on Gemini API docs (API errors, Billing) · 2026-11·Test scope ↓·7 steps

Gemini API 402 payment_required means your Prepay credit balance is $0. Don't retry: add credits in AI Studio, and set a monthly limit if you use auto-reload.

output
payment_required | 402 Payment Required | Your Prepay credit balance is depleted.

That line is copied from the table in the official Gemini API errors page. It means the Prepay credit balance on your billing account has run out. The documented fix is to add credits, and until you do, the same request will not succeed, so stop sending it.

[1] Check the status code first. Several failures look alike from the application side, but the codes differ. This is the official error table, trimmed to the relevant rows.

HTTPCodeDocs sayWhat to do first
402payment_requiredPrepay credit balance depletedSteps [3]-[4] below
400failed_preconditionA prerequisite is not met (the docs' example: disabled billing)Check the project's billing status
401authenticationAPI key missing, invalid, or expiredCheck the API key
403permission_deniedKey lacks permission, or the project is restricted or needs billing changesGemini project has been denied access
429rate_limit_exceeded · quota_exceeded · too_many_requestsPer-minute, per-second, or daily limit exceededGemini API 429 and 503 retry code

[2] Make sure your retry logic is not resending the 402. The error table says "Don't retry: the request won't succeed until credits are added." Code written as "retry anything that is not 200" is the problem. Don't approve all of 5xx at once either; go by code. In the same table, 501 unimplemented means the feature is not supported and tells you to switch features, and 429 quota_exceeded says to wait for the quota to reset or request an increase. Neither succeeds by repeating. Example (a decision function, not run):

python
RETRYABLE = {429, 500, 503, 504}   # 501 left out. 429 is pointless for quota_exceeded (daily): see the linked 429 post def should_retry(status: int) -> bool:    return status in RETRYABLE      # 402 is not here, so it fails immediately

On a 402, the caller should stop the job and raise an alert. Repeating the request until credits arrive returns the same result.

[3] Look at the balance on the billing page. Open AI Studio Billing, then check the Billing Tier or Status column for the project on the Projects page. The docs define the labels like this.

LabelMeaning
No creditsThe billing account must buy credits, but the Prepay payments account is not set up or the balance is depleted
Set up PrepayA billing account is attached, but the Prepay plan still needs setup
Set up billingThe project has no billing account attached

[4] Add credits. On AI Studio Billing, choose Buy credits. The docs give a $5 minimum and a $5,000 maximum for prepaid credits.

The fix may not be instant. The docs' processing-times section says most card payments are instant, but some payment types such as bank transfers can take several days to clear, and service resumes only after the purchase is officially confirmed. If you paid and still see 402, the payment may be pending: check whether the balance on the Billing page has updated instead of repeating the request.

[5] Decide whether to turn on auto-reload. It is optional; the docs describe it as topping up the Prepay balance when it runs low, to prevent service interruptions. On the Billing page, click Setup auto-reload in the Available credits card and set the payment method, the reload amount, and the minimum balance that triggers a reload.

[6] Leave headroom if you run long jobs such as batch or agents. The billing page notes about 10 minutes of billing pipeline latency, during which usage keeps accumulating, and says batch mode and agent tasks may keep consuming credits beyond your balance before usage is halted. In other words, extra charges can accrue after the balance reaches $0. The page sets no maximum for the overage, so don't assume it is small.

[7] If the error is not 402 after all, follow the matching post. For 429 with healthy billing, see Gemini API 429 and 503 retry code. For 503, see Gemini API 503 "model is overloaded". For a 404 on an old model name, see Gemini no longer available to new users.

What the docs do not say: the exact wording of a 402 response body, which exception the official SDKs raise for it, and how long it takes for requests to succeed again after a top-up. The docs give only "several days" for bank transfers and "within 10 minutes" for tier upgrades.

#gemini-api#402#payment-required#prepay#billing#auto-reload