Gemini FAILED_PRECONDITION: meaning, cause, and fix

The error that only shows up after you deploy. Your code didn't change between laptop and server — its mailing address did.

By the benchr team · · Verified against Google's Gemini API troubleshooting docs, June 12, 2026

Google GeminiHTTP 400severity: highquota & billing

A region wall, not a code bug

The pattern is so consistent it deserves a name: everything passes on your laptop, then the first request from a fresh VPS or cloud box dies with a 400. Free-tier availability depends on the country the request comes from, and a datacenter in Frankfurt or Singapore isn't the desk you tested at. The API rejects the call before processing a single token; the precondition check runs first. Enabling billing removes the wall, because the paid tier doesn't carry the free tier's regional restrictions.

What it looks like

A representative response body, in Google's standard envelope where the numeric code mirrors the HTTP status and status carries the gRPC name:

{
  "error": {
    "code": 400,
    "message": "User location is not supported for the API use without a billing account linked.",
    "status": "FAILED_PRECONDITION"
  }
}

Phrasing varies by setup, so key your handling off the status string, not the sentence.

Three checks, in order

First: where does the server run? Not where you bought it, where the datacenter sits. Hosting dashboards bury this; your provider's region setting is the truth. Second: is billing linked? Open the project in Google AI Studio and check, don't assume. Third: is the key from the project you think it is? Stale environment variables point at unbilled sandbox projects more often than anyone admits, and the fix you applied to the right project does nothing for the wrong key.

After billing: budget like an adult

Once billing is on, the free tier goes back to its real job — testing, not production traffic. Set budget alerts the same day, sized to a number that would make you look twice. Then price the workload honestly: Gemini 3.5 Flash at $1.50 in and $9.00 out per million tokens keeps modest products in pocket-change territory, and knowing that number beats fearing it. If your project truly belongs on a $0 budget, the no-subscription guide covers who can stay free without hitting walls like this one.

Frequently asked

Why does my code work locally but not on my server?

The API checks where the request comes from. Your laptop sits in a country the free tier covers; your server's datacenter sits in one that requires a billing account first. Same code, different mailing address.

Is my API key broken?

No. FAILED_PRECONDITION is a precondition failure, not an authentication one. A key with missing permissions returns PERMISSION_DENIED (403) instead. Your key is fine; the project behind it needs billing.

Does enabling billing mean I'll be charged right away?

You pay for usage beyond the free allowances, not for linking the account. Set budget alerts the same day you enable it so a surprise spike sends an email instead of an invoice shock.

Changelog

  • — Published. Region condition, billing fix, and error envelope verified against Google's Gemini API troubleshooting guide.

Sources

  • Gemini API troubleshooting: ai.google.dev/gemini-api/docs/troubleshooting (verified June 12, 2026)
  • benchr api-errors.json (structured entry for this error)