Minutes 0–5: is it Gemini, or is it your limit?
Start from your own traffic, not a status page. A status page updates after your users notice, so the earlier signal is your error rate by status code, per provider and model.1 Google AI Studio's status page renders by script, so it is linked here rather than quoted: open aistudio.google.com/status (opens in a new tab) yourself, and read it as confirmation, not as the trigger. Google's own troubleshooting page (opens in a new tab) lists the exact error messages; check it for the wording on the day.
Then sort the failures you see:
| You see | Reads as | Whose problem | First move |
|---|---|---|---|
| 503 UNAVAILABLE ("model is overloaded") | The model is short of capacity right now | Google's | One jittered retry, then fail over |
| 429 RESOURCE_EXHAUSTED | A limit on your project or key was reached | Usually yours | Find which limit; do not fail over around a spend cap |
| 500 | A server-side error | Probably Google's | Retry once, then compare requests (below) |
| Timeouts, connection resets | Host unreachable or stuck | Google or the network path | Retry once if the deadline allows, then fail over |
| 400, 401, 403 | The request, the key or permissions | Yours | Stop; fix it |
The distinction that matters most is 503 against 429. A 503 says nothing in your request or account is wrong; a 429 says a limit on your side was reached, and often your own traffic caused it.2 A deploy that doubled traffic produces 429s that look exactly like an outage on a dashboard that groups every non-200 together. For the 429 branch, see Gemini API 429 RESOURCE_EXHAUSTED: which limit, and what to do.
For a 500, I could not read Google's page, so treat the cause as open. A quick test: replay the failing prompt and a trivial one. If only the same prompt fails every time, suspect the request (size, tools, schema), not an outage.
- Group Gemini errors by status code and model for the last 15 minutes
- Separate 429s from 5xx and timeouts on the dashboard
- Compare against the previous hour and the last deploy time
- Open Google's status page and the troubleshooting page, and note what they say and when
- Replay one failing request and one trivial request to see whether the failure is general
Minutes 5–10: stop making it worse
Retries are the main way your own code deepens an outage. During a capacity shortage every client is retrying into the same shortage, so retrying the same host mostly adds latency.2 Three moves, in order:
- Cap retries. One or two jittered attempts, bounded by the user's deadline, not only by a count. If a gateway already fails over for you, do not stack a client retry loop on top; retries at two layers multiply.2
- Shorten timeouts. A request held for minutes is a user who has already left. Set a per-attempt timeout that leaves room for a fallback inside the whole deadline.
- Open the circuit, and pause background work. Stop sending traffic to a target whose error rate is over your threshold and probe it on a timer. Only failures that say "unhealthy" (5xx, timeouts, broken connections) should count; a 429 means busy, not broken, and should not open the breaker.1 Backfills, evaluation runs and re-indexing compete with user traffic, so stop them first.
def classify(status: int | None) -> str:
"""Returns what the caller should do next. status None = timeout/connection error."""
if status is None or status >= 500:
return "retry_once_then_failover" # provider unhealthy or unreachable
if status == 429:
return "check_limit" # yours: do not fail over around a cap
if status in (400, 401, 403, 404):
return "stop" # the request or the key is the problem
return "stop"Minutes 10–20: Vertex AI first, another model second
Failover is only safe to a target you have tested for this workload. Prompts tuned for one model behave differently on another, and structured output, tool calling and context limits differ.1 Choose in this order.
First fallback: Gemini on Vertex AI
Gemini on Vertex AI is the nearest fallback: the same model family served from another host, so behaviour is closest. It is not free of work. Vertex AI is a separate Google Cloud project with its own credentials, model enablement and quota, and its 429s have their own causes; read Vertex AI 429 resource exhausted: two causes, two fixes before you rely on it. A Vertex AI connection in INFRO takes a service-account key and your Google Cloud project ID.3 Do that connection, and one test request, before the incident, not during it.
With two connections that serve the same model, INFRO's connection failover tries the next connection when one fails before the first token, and your client sees only a slightly higher time to first token; with a single connection there is nothing to fail over to.4 A connection can also list more API hosts for the same key, tried when the first cannot be reached.2 That helps with unreachable hosts, not with a 503 from a host that is up and answering, where a second connection or model is the lever.2
Second fallback: another model
When the whole Gemini model is unavailable, the next step is a different model. INFRO's model fallbacks take an ordered list of up to five catalog model IDs, tried once every connection for the primary model has failed before the first token.4 The trade-off is quality and format: a different model changes tone, tool-call behaviour, JSON reliability and context limits. Use only a model that has passed your own evaluation for this task; Is your fallback model good enough? gives a method. Price differences also move your provider bill; see what failover does to your bill.
Never fail over around a limit
A 429 that is your own spend or quota cap says stop. Moving that traffic to another provider spends around the limit you set.1 Note that INFRO's connection failover moves on provider 429s as well as 5xx and timeouts,4 so decide per failure kind on the route. Routes carry failure rules that decide, per failure kind, whether to retry, move on or stop, and if-rules that send matching requests to their own targets by feature, streaming, prompt size and more.5 A sensible Gemini policy:
| Failure | Rule |
|---|---|
| 503, timeout, connection error | One short retry, then next target |
| 429 from a provider-side or INFRO spend cap | Stop and alert a person |
| 429 from rate limits with headroom elsewhere | Next connection |
| 400, 401, 403 | Stop; the request or credential is wrong |
This is a policy to design against, not INFRO's configuration syntax; the schema is in the routes documentation (opens in a new tab).
- Send one request to the Vertex AI connection and confirm it answers
- Move a share of traffic first, and watch error rate before widening
- Route latency-sensitive features to the short-deadline target, batch work to the patient one
- Turn on a second-model fallback only for features that passed evaluation
- Decide per feature: degrade (cached or partial results), queue, or fail clearly
Minutes 20–30: tell users and watch
Say what is affected, what still works, and what you are doing, in plain words. Avoid promising a recovery time you do not control.
Then watch, because failover has limits. It acts before the first token, so a stream that breaks mid-answer is not rescued by it.4 Expect some users to see a cut-off answer and give them a retry button. A gateway shortens an outage for new requests; it does not prevent one and cannot make Google's service available.
- Post the status message, with a time for the next update
- Watch the 503 rate on the primary and the success rate on the fallback separately
- Keep background jobs paused until the primary's error rate is back to normal
- Probe the primary on a timer and shift traffic back in steps, not all at once
- Write down timestamps: first error, failover, recovery
After the incident: what to check in the request trace
The request log records the model, the selected provider connection, the outcome, timings, usage and estimated provider cost for each request, and the trace names the route and the connection that served it.6 That answers the questions the incident left open:
- Did failover work? Filter for the incident window and look at which connection served each request. Requests that errored despite a fallback need a closer look.
- What did it cost in latency? Sort by slowest; the list endpoint supports
sort=slowestandstatus=errorfilters.6 - What did it cost in money? Sort by costliest, and compare estimated provider cost on the fallback with the primary. Unpriced requests come last, never as $0.6
- Were retries stacked? Count attempts per request to find a client loop sitting on top of gateway failover.
- Did a 429 hide inside the outage? Check that limit errors were classified separately.
curl "https://api.infro.io/v1/requests?limit=25&status=error&sort=slowest" \
-H "Authorization: Bearer $INFRO_API_KEY"The history window depends on your plan, and prompt and completion bodies are off unless you turned logging on.6 Then fix what the incident exposed: add the Vertex AI connection if it was missing, run a failover drill so the next one is a rehearsal, and file the timestamps with the postmortem.
