Skip to content

Fix Gemini 3.1 Pro Timeout Errors: 504 vs 503 "Deadline Expired"

Gemini sends "Deadline expired before operation could complete" with both 504 and 503. Read the status code, then apply the matching fix and SDK timeout.

•••22 min read•Troubleshooting
Gemini 3.1 Pro timeout fix: the message Deadline expired before operation could complete splits into 504, raise the timeout with timeout=600_000, and 503, back off and retry

Gemini 3.1 Pro timeout errors fall into three distinct categories requiring different fixes, and the status code tells you which one you have — the message often does not. 503 UNAVAILABLE means Google's side is overloaded: retry with exponential backoff or switch models. 504 DEADLINE_EXCEEDED means the request ran out of time: most often the deadline your own SDK sent was too short, otherwise the request is too large, so raise or remove the client timeout (google-genai takes it in milliseconds) or shrink the request. A network timeout with no status code is your client giving up first: fix the timeout setting. The message Deadline expired before operation could complete. shows up with both 503 and 504, so act on the code. As of November 15, 2026, Gemini 3.1 Pro is still a Preview model (gemini-3.1-pro-preview) with no shutdown date, and it thinks at high by default, so a 10–30 second wait for the full answer is normal.

Seeing a timeout in the Gemini app or on gemini.google.com rather than in code? Jump to Gemini app under Platform-Specific Troubleshooting.

TL;DR — Quick Solutions Table

If your Gemini 3.1 Pro API call just failed and you need a fix right now, find the row that matches what you see — the status code first, then the message. The most common mistake developers make is applying the wrong fix to the wrong error type: a 503 requires a completely different approach than a 504, and treating a network timeout like a server error will waste hours of debugging.

What you seeStatusWhose problemFirst step
504 DEADLINE_EXCEEDED + Deadline expired before operation could complete.504Usually your client deadline; sometimes a very large requestCheck your SDK timeout (milliseconds in google-genai). Set it to 600,000 ms or remove it; if it already is, shrink the input
503 UNAVAILABLE + Deadline expired before operation could complete.503Google — the request was not served in timeRetry with exponential backoff; after 3–4 failures switch model
503 UNAVAILABLE + This model is currently experiencing high demand. Spikes in demand are usually temporary. (older text: The model is overloaded. Please try again later.)503Google — overloadSame as above; check aistudio.google.com/status
ReadTimeout, ETIMEDOUT, ECONNRESET, socket hang up, no status codenoneYour client, proxy or networkRaise the client timeout; check proxies and load balancers
No error, no response, runs for minutesnoneUnknown until you cancelCancel after your own deadline, retry once, then switch model or endpoint
Batch job: "code": 4 + Deadline expired before operation could complete.gRPC 4Google (per request)Re-submit the failed requests
Gemini app: "Pro is in high demand at the moment", "Something went wrong (1185)", a reply that never finishes—Google, the app session, or your networkSee Gemini app

The critical distinction here is between server-side errors (503, and a 504 the server returns on its own deadline) and client-side errors (network timeouts and a deadline your code set too short). A 503 means Google's infrastructure did not serve the request; waiting, retrying or switching models is all you can do. A 504 in 2026 is far more often caused by the client: the google-genai SDKs forward your timeout to Google as the server deadline, so a timeout that is too short produces a server-side 504. The hanging case — a request that never returns — was reported most often in AI Studio's app builder during the February 2026 rollout; in code, your own deadline is the only reliable protection.

Why Gemini 3.1 Pro Times Out (It's Not Always a Bug)

Understanding the root cause of Gemini 3.1 Pro timeouts requires distinguishing between three fundamentally different scenarios, because the same symptom — "my API call didn't return in time" — can stem from entirely unrelated causes. Google released Gemini 3.1 Pro Preview on February 19, 2026, and within days developer forums were full of timeout reports. Many of these "timeouts" are the model working as designed, a client deadline set too short, or a capacity problem on Google's side — three cases with three different fixes.

The first cause is thinking time. Gemini 3.1 Pro reasons before it writes its first visible token, and its thinking level defaults to high. It accepts low, medium and high but cannot be switched off (minimal is rejected with a 400). Google's troubleshooting guide says higher latency "often occurs because Gemini 3.x models have thinking enabled by default" and suggests lowering the thinking level. On 3.1 Pro that helps less than you might expect: in our own test on October 22, 2026, one reasoning prompt used 1,200 thinking tokens at the default, 995 at low and 1,297 at high, and every level took about 17–19 seconds. If you need answers in a few seconds, a smaller model saves more time than a lower thinking level. You can read more about how long outputs affect this in our Gemini 3.1 Pro output limit guide.

The second category of timeouts comes from genuine server overload. When Google's capacity for a model runs short, you receive a 503 UNAVAILABLE response, and there is nothing wrong with your code or configuration. A Google staff member answered a November 2026 report of 503s with requests stalling for about two minutes: "503 errors are due to our services being temporarily overloaded." Google does not publish peak hours or capacity per model, so the practical signal is your own error rate and the status page. The third category involves real bugs during the Preview rollout: in February 2026, developers reported AI Studio's Build mode running for 20,000+ seconds without finishing, and Google staff acknowledged slowness "as part of a bunch of ongoing rollouts." Those reports came from the app builder, not the API.

The practical implication is straightforward: before you start debugging, determine which category your timeout falls into. If the full answer arrives in 10–30 seconds, you're seeing normal model behavior — no fix is needed beyond a client timeout that allows it. If you're getting 503 errors, the server is at capacity and you need retry logic or a model fallback. If you get 504 errors, check the timeout your code sends before blaming the model. If your request literally never completes, cancel it at your own deadline and retry or switch.

Diagnosing Your Timeout: Error Code Decoder

Three lanes by status code for the same Deadline expired message: 504 DEADLINE_EXCEEDED, raise or remove the timeout then shrink the input; 503 UNAVAILABLE, retry with backoff and do not raise the timeout; no status code, raise the client timeout and check proxies

The fastest way to fix a Gemini 3.1 Pro timeout is to correctly identify which of the three error types you're experiencing, because applying the wrong fix to the wrong error is the most common mistake developers report in forums. The diagnostic process starts with your HTTP response status code, and from there, each branch leads to a completely different troubleshooting path. If you're not seeing an HTTP status code at all — meaning your request simply hangs or your client throws its own timeout — that itself is diagnostic information pointing to the client side.

503 UNAVAILABLE — Server Overload

When the Gemini API returns a 503 status code, the 2026 response body usually reads "This model is currently experiencing high demand. Spikes in demand are usually temporary. Please try again later."; older responses said "The model is overloaded. Please try again later.", and some 503s carry "Deadline expired before operation could complete." instead. Google's API errors reference describes 503 as "temporarily overloaded or down" and recommends waiting and retrying with exponential backoff. Many 503s return quickly because the request is rejected before it is processed, but the November 2026 reports describe requests stalling for about two minutes before the 503 arrives. You should NOT increase your timeout for 503 errors, because the problem is server capacity, not processing time. Instead, implement exponential backoff retry logic (covered in the code section below) or temporarily switch to a model with more capacity such as Gemini 3.8 Flash. If you're also seeing 429 errors mixed in with 503s, check our complete guide to fixing Gemini 429 resource exhausted errors which covers the distinction between rate limiting and server overload in detail.

504 DEADLINE_EXCEEDED — Request Too Complex

A 504 error with the message "Deadline expired before operation could complete" means the request did not finish before its deadline. Google's API errors page puts it plainly: "The request didn't finish within the deadline," and the recommended action is to "Remove or increase client deadline setting to use the server default." That wording matters, because in 2026 the deadline is often the one your own code set. The google-genai SDKs for Python and JavaScript send your timeout to Google in an X-Server-Timeout header, rounded up to whole seconds, so a 20- or 25-second client timeout becomes a 20- or 25-second server deadline and comes back as a 504. Developers reported exactly this in 2026 with timeouts of 20 and 25 seconds. When the timeout is already generous (10 minutes or more), the request itself is too slow: very long prompts, large video or PDF inputs, or very long outputs. In one September 2026 report, an 889 MB video failed with this 504 after about 605 seconds. The fix for 504 errors is to raise or remove the client timeout first, then reduce the work by shortening the prompt, limiting output with max_output_tokens, splitting the task, or using the Batch API for work that can wait.

Same message, two codes: "Deadline expired before operation could complete"

The message is identical, the cause is not. Public reports up to November 15, 2026 that show this exact message next to an explicit status code — Google AI Developers Forum threads and GitHub issues with the raw response body — split as follows. None of Google's documentation pages contains the string.

Status in the responseReports foundWhenWhat the reports show behind itFix that worked
504 / DEADLINE_EXCEEDED13All in 2026 (February–November)Client timeouts of 20–25 s sent as the server deadline; very large media inputs (a 1.08 GB video, an 889 MB video at ~605 s); a batches.get call cut at 60 s; streaming calls on Flash modelsRaise or remove the timeout (several projects moved to 90 s–10 min); shrink the input; retry 504 as transient
503 / UNAVAILABLE10 (6 in 2026)March 2025 – November 2026Overload during high demand, including image models; oversized requests failing in 3–5 s on Vertex AIWait and retry; switch model; smaller requests
gRPC code: 42January and August 2026Per-request failures inside Batch API jobsRe-submit failed requests
WebSocket 10113November 2025 – October 2026Live API sessions closing, one exactly at the 58-minute mark after a go_away noticeReconnect / resume the session

Two details from these reports help with diagnosis. First, one developer saw the same failed calls come back as 503 UNAVAILABLE from the API while AI Studio's logs listed them as 504 - DEADLINE_EXCEEDED with 0 tokens (November 2, 2026) — so trust the status code your client received. Second, the 504 reports with short client timeouts all went away once the timeout was raised, which is why the table above puts the timeout check first for 504 and backoff first for 503.

Network Timeout — Client-Side Configuration

If you see errors like ETIMEDOUT, ECONNRESET, socket hang up, httpx.ReadTimeout, or your HTTP client's generic timeout error, the problem is on your side. Your SDK or HTTP client gave up waiting for Google's response before the model finished processing. The google-genai SDKs set no client timeout by default, so this usually comes from a timeout you or a framework set, or from something in between: a proxy, load balancer, serverless function limit or API gateway. Gemini CLI waits 60 seconds for the first response before it aborts and retries. Since Gemini 3.1 Pro can take 20–30 seconds before it returns anything on a hard prompt, any client timeout below 60 seconds will cause frequent failures. The fix is straightforward: increase your timeout configuration to at least 120 seconds — in google-genai that is 120_000, not 120. This is also the most important configuration for developers who work within the Gemini API rate limits by tier, since longer timeouts mean fewer wasted requests hitting your quota.

What's Normal? Performance Baselines You Should Know

One of the most valuable things a developer can know when troubleshooting Gemini 3.1 Pro is what performance to actually expect, because without baselines, every slow response feels like a bug. Latency for a Preview model moves over time, so the table below shows the February 2026 measurements this guide was first built on next to the current ones.

The time-to-first-token (TTFT) baseline is the most important number to internalize. Artificial Analysis measured a median TTFT of 31.36 seconds on Google AI Studio and 21.54 seconds on Vertex AI in February 2026. Its 5-day average on November 15, 2026 is much lower and the order has flipped: 15.56 seconds on AI Studio and 18.87 seconds on Vertex AI. Our own single-sample test through an API gateway on October 15, 2026 (non-streaming, default thinking) took 9.5 to 27.6 seconds for the full answer across five task types, one request each. If your requests start answering within about 30 seconds, your experience is normal and no troubleshooting is needed.

Output generation speed tells a different story. Once Gemini 3.1 Pro starts producing tokens, it's quick: Artificial Analysis measured 111.5 tokens per second on AI Studio and 79.4 on Vertex AI in its November 15 average (96.5 and 153.7 in February). The bottleneck is the thinking phase, not generation. A practical consequence is that for long-output tasks (code generation, article writing, detailed analysis), the total wall-clock time may be quite reasonable despite the slow start — a 20-second TTFT followed by 2,000 tokens at about 100 tokens per second adds up to roughly 40 seconds.

MetricAI Studio (Feb 2026)Vertex AI (Feb 2026)AI Studio (Nov 15, 2026)Vertex AI (Nov 15, 2026)
TTFT (Artificial Analysis)31.36s21.54s15.56s18.87s
Output Speed (Artificial Analysis)96.5 t/s153.7 t/s111.5 t/s79.4 t/s
Problematic TTFT (our rule of thumb)>60s>60s>60s>60s
Broken (our rule of thumb)>120s or never>120s or never>120s or never>120s or never

Use these baselines to calibrate your expectations. When a request takes 25 seconds to start responding, that's normal — don't implement workarounds for normal behavior. When a request takes 90 seconds, something is probably wrong. When a request takes 300 seconds or never responds, cancel it, retry, or fall back to an alternative model.

How long should your timeout be? Google does not publish the server's default deadline for generateContent. What it does publish: the SDKs "expect timeout values in milliseconds"; for Gemini 4 Argon, "Hard prompts can take several minutes," so set "HTTP client timeouts to at least 15 minutes"; for Flex requests, 10 minutes or more. For 3.1 Pro, 10 minutes (600_000) is a safe client timeout for interactive work, and longer for big documents, video or very long outputs.

Production-Ready Fixes (Copy-Paste Code)

google-genai timeout is in milliseconds: timeout=120 gives a 0.12 second client wait and a 1 second server deadline, timeout=600_000 gives 10 minutes, on a timeline where a normal full answer takes 10 to 30 seconds

The code solutions below address all three timeout types and are designed for production use. Each implementation sets the timeout in the unit the SDK expects, lets the SDK retry 503 with exponential backoff, moves on after a 504 or a client-side timeout, and falls back to a faster model when the primary model is persistently unavailable. Both examples target google-genai 3.3.0 for Python and @google/genai 3.3.0 for JavaScript, the current versions as of November 15, 2026; their retries, fallback and the deadline header they send were confirmed against a mocked API, without real requests.

Python — Google GenAI SDK

The Python SDK provides the most direct integration with the Gemini API, and timeout configuration is handled through http_options. Two settings matter. timeout is in milliseconds: {"timeout": 120} means 0.12 seconds, and because the SDK also sends it as the server deadline (rounded up to 1 second), every request then fails. Leave it unset for no client timeout, or set 600_000 for 10 minutes. retry_options turns on the SDK's built-in retries. In google-genai 3.3.0 the client makes a single attempt unless you pass it, even though Google's troubleshooting page says the SDK retries by default.

python
from google import genai
from google.genai import errors, types

# timeout is in MILLISECONDS. 600_000 = 10 minutes. (120 would mean 0.12 s.)
# The SDK also sends this value to Google as the server-side deadline.
client = genai.Client(
    http_options=types.HttpOptions(
        timeout=600_000,
        retry_options=types.HttpRetryOptions(
            attempts=4,               # includes the first request
            initial_delay=2.0,        # seconds
            max_delay=60.0,           # seconds
            http_status_codes=[503],  # retry overload only; 504 is handled below
        ),
    )
)

MODEL_CHAIN = [
    "gemini-3.1-pro-preview",  # still Preview on Nov 15, 2026
    "gemini-3.8-flash",        # Stable, fast fallback
]

def generate(prompt: str) -> dict:
    last_error = None
    for model_id in MODEL_CHAIN:
        try:
            response = client.models.generate_content(
                model=model_id,
                contents=prompt,
                config=types.GenerateContentConfig(
                    # 3.1 Pro thinks at "high" by default; "low" trims thinking a little
                    thinking_config=types.ThinkingConfig(thinking_level="low"),
                    max_output_tokens=8192,
                ),
            )
            return {"model": model_id, "text": response.text}
        except errors.APIError as e:
            last_error = e
            if e.code == 503:
                # SDK already retried 3 times with backoff: Google is overloaded
                print(f"503 UNAVAILABLE on {model_id} after retries: {e.message}")
                continue
            if e.code == 504:
                # The deadline ran out. With a 10-minute timeout this usually
                # means the request is too large: shrink it or use another model.
                print(f"504 DEADLINE_EXCEEDED on {model_id}: {e.message}")
                continue
            raise  # 400/403/429 etc.: retrying will not help
        except Exception as e:
            # No status code: your own client gave up before Google answered
            # (httpx ReadTimeout / ConnectTimeout and similar)
            if "Timeout" not in type(e).__name__:
                raise
            last_error = e
            print(f"Client-side timeout on {model_id}: {e!r}")
            continue
    raise RuntimeError(f"All models failed; last error: {last_error}")

result = generate("Explain quantum entanglement in two paragraphs.")
print(f"Answered by {result['model']}")
print(result["text"])

One side effect to plan for: once retry_options is set, the SDK also retries its own client-side timeouts, so the worst case before the code moves to the next model is attempts × timeout. With 4 attempts and 10 minutes that is 40 minutes; lower attempts or the timeout for interactive requests.

Node.js / TypeScript — Google GenAI SDK

The JavaScript/TypeScript SDK follows the same pattern: httpOptions.timeout is in milliseconds, it is sent to Google as the server deadline, and retryOptions must be set for the SDK to retry. Also make sure any wrapper timeout (an Express request timeout, a serverless function limit, a reverse proxy) is longer than the SDK timeout.

typescript
import { GoogleGenAI, ApiError, ThinkingLevel } from "@google/genai";

// timeout is in milliseconds; the SDK also sends it to Google as the server deadline
const ai = new GoogleGenAI({
  apiKey: process.env.GEMINI_API_KEY!,
  httpOptions: {
    timeout: 600_000, // 10 minutes
    retryOptions: { attempts: 4, initialDelay: 2, maxDelay: 60, httpStatusCodes: [503] },
  },
});

const MODEL_CHAIN = ["gemini-3.1-pro-preview", "gemini-3.8-flash"];

async function generate(prompt: string): Promise<{ model: string; text: string }> {
  let lastError: unknown;
  for (const model of MODEL_CHAIN) {
    try {
      const response = await ai.models.generateContent({
        model,
        contents: prompt,
        config: {
          thinkingConfig: { thinkingLevel: ThinkingLevel.LOW },
          maxOutputTokens: 8192,
        },
      });
      return { model, text: response.text ?? "" };
    } catch (err) {
      lastError = err;
      if (err instanceof ApiError && err.status === 503) {
        console.log(`503 UNAVAILABLE on ${model} after retries, trying next model`);
        continue;
      }
      if (err instanceof ApiError && err.status === 504) {
        console.log(`504 DEADLINE_EXCEEDED on ${model}: shrink the request or switch model`);
        continue;
      }
      if (err instanceof Error && /timeout|aborted|ETIMEDOUT|ECONNRESET/i.test(`${err.name} ${err.message}`)) {
        console.log(`Client-side timeout on ${model}: ${err.message}`);
        continue;
      }
      throw err; // 400/403/429 etc.
    }
  }
  throw new Error(`All models failed: ${String(lastError)}`);
}

const result = await generate("Explain quantum entanglement in two paragraphs.");
console.log(`Answered by ${result.model}\n${result.text}`);

cURL — Quick Timeout Test

For quick diagnostic testing, use cURL with an explicit connect and max-time flag to determine whether your timeout issue is server-side or client-side. The -w line prints the status code and total time, which is all you need to tell a 503 from a 504 from your own timeout. If this cURL command succeeds but your application fails, the problem is your application's timeout configuration.

bash
# Test with a 120-second client timeout; prints status code and time taken
curl -sS -o response.json \
  -w "HTTP %{http_code} in %{time_total}s\n" \
  "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-pro-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  --connect-timeout 30 \
  --max-time 120 \
  -d '{
    "contents": [{"parts": [{"text": "Say hello"}]}]
  }'
# HTTP 503 -> Google overloaded; HTTP 504 -> deadline; "Operation timed out" -> curl's own --max-time

The key principle across all implementations is the same: set your timeout in the unit your client expects and long enough for the model, retry 503 with backoff, treat 504 as "deadline or request size", and keep a fallback model so your application never completely fails when Gemini 3.1 Pro is unavailable.

Timeout units and defaults at a glance

ClientSettingUnitDefault as of Nov 15, 2026
google-genai (Python) 3.3.0HttpOptions(timeout=...)millisecondsnone (no client timeout); no retries unless retry_options is set
@google/genai (JS/TS) 3.3.0httpOptions: { timeout }millisecondsnone; no retries unless retryOptions is set
Both SDKsvalue sent as X-Server-Timeoutseconds, rounded upheader only sent when you set a timeout
Gemini CLI 0.68.0 (stable)built in—60 s for the first response, then abort and retry
Gemini CLI 0.69.0-preview.0model.requestTimeoutMsmilliseconds60000
cURL--max-timesecondsnone

If you are still on the retired google-generativeai package, its request_options={"timeout": ...} took seconds; mixing that habit with google-genai is how timeout=120 ends up meaning 0.12 seconds.

Platform-Specific Troubleshooting

Gemini 3.1 Pro timeout issues manifest differently depending on which platform you're using to access the model, and each platform has its own specific fixes. The subsections below cover the platforms where people report timeout problems most often, starting with the Gemini app for readers who are not writing code. If your platform isn't listed here, the general API fixes from the code section above apply universally.

Gemini app (gemini.google.com and mobile)

If the timeout happens in the Gemini app rather than in your own code, none of the SDK settings above apply. The notices people search for most include "Pro is in high demand at the moment" with "Another model was used for this response. This didn't count towards your limit." (seen in May 2026), which means the app answered with a different model because Pro was busy, and "Something went wrong (1185)", a chat error Google has not explained publicly. As of November 15, 2026, no Google product documents the exact wording "This response timed out", so treat it like any reply that never finishes. What helps, in order: check aistudio.google.com/status and the Google Workspace Status Dashboard; reload the page or start a new chat (long or idle chats are a common trigger in user reports); try an Incognito window or disable extensions such as ad blockers and VPNs; then try a different network or device. If the Android app itself keeps failing, see our Gemini app not working on Android fixes.

Google AI Studio (Web Interface)

The most severe timeout reports affected Google AI Studio directly. During the February 2026 rollout, developers reported AI Studio's Build mode (the app builder) running for 20,000+ seconds — over five hours — without finishing, and one thread mentions counters reaching 50,000 seconds. Google staff acknowledged slowness during the upgrade on February 19 and 23, 2026, and other users reported timeouts "on nearly every turn" with 3.1 Pro in AI Studio in late February. The only fix in those threads was to cancel the request manually and either retry or switch to a different model. If you experience this consistently through the API, one developer reported in May 2026 that moving the same 3.1 Pro workload to Vertex AI stopped the hangs. On Vertex AI, 3.1 Pro is a public preview served only from the global endpoint.

Cursor IDE

Cursor wraps Gemini calls in its own client, so its messages — such as "Unable to reach the model provider" or a request that keeps running in agent mode — are Cursor's, not Gemini's status codes. The dependable steps are on the request side: cancel the stuck agent step, split the task into smaller instructions that need less reasoning, and switch the step to a faster model if 3.1 Pro keeps stalling. Some Cursor users report better results by adding explicit instructions like "respond directly, do not over-analyze" to reduce thinking time.

Android Studio (Gemini in IDE)

Android Studio users report two different messages. Request timed out is a timeout; You have exceeded the limit of prompt requests per hour. Please try again later. is a usage limit, not a timeout, and only waiting resets it. We found no documented timeout setting for Gemini in Android Studio (a public question asking for one had no answer on November 15, 2026). The workaround is to retry with a smaller request or switch to a faster model if your setup lets you pick one.

Direct API (REST/gRPC)

For direct API integration via REST or gRPC, the timeout is entirely under your control. The most common mistakes are a timeout that is too short and a timeout in the wrong unit. For REST API calls, set the HTTP client timeout to at least 120 seconds, and longer for large inputs. For gRPC calls via the Vertex AI client, configure the timeout parameter in the call options. The code examples in the previous section cover both SDKs. Also verify that any intermediate proxies, load balancers, or API gateways in your infrastructure have timeouts set to at least 180 seconds to account for the proxy's own processing overhead.

Gemini CLI

To update Gemini CLI, use the command from its official docs: npm install -g @google/gemini-cli@latest (stable was v0.68.0 on November 15, 2026). The long-standing problem of requests hanging for 5 minutes (the default Node.js timeout) was fixed in v0.42.0 (May 12, 2026): the CLI now waits 60 seconds for the first response, then aborts and retries. When a model is overloaded, the CLI shows a "high demand" prompt that lets you keep trying, switch to a Flash model or stop; by default it asks before switching. A configurable model.requestTimeoutMs setting (milliseconds) exists only in the 0.69.0 preview channel. Also note that since June 18, 2026, free individual access and Google AI Pro / Ultra plans use Antigravity CLI instead of Gemini CLI. If you're building your own CLI wrapper, reference the Gemini CLI's source code for its retry and fallback patterns.

When to Switch: Decision Framework + Model Alternatives

Knowing when to stop troubleshooting and switch to a different model is a strategic decision that depends on your specific context — how urgently you need results, whether you're in development or production, and how much intelligence you actually need for the task at hand. The decision framework below provides concrete criteria for making this call quickly, rather than the vague "try again later" advice that dominates forum threads.

For production environments, the decision is binary: if Gemini 3.1 Pro has been returning 503 errors for more than 30 minutes or your request has been hanging for more than 2 minutes, switch immediately to your fallback model. Production systems cannot tolerate multi-hour outages while waiting for a Preview model to recover. Your fallback should already be configured in your code (see the model fallback chain in the code section above), and the switch should be automatic. For development and testing, you have more flexibility — waiting 15–30 minutes during a 503 wave and then retrying is a reasonable approach.

The comparison table below shows the practical alternatives when Gemini 3.1 Pro isn't responding, with Google's paid-tier prices per million tokens as of November 15, 2026. For the full price list, see our complete Gemini API pricing guide.

ModelModel IDStatusInput / Output per 1MBest For
Gemini 3.1 Progemini-3.1-pro-previewPreview, no shutdown date$2.00 / $12.00 (prompts ≤200K); $4.00 / $18.00 aboveThe model you are troubleshooting
Gemini 4 Argongemini-4-argonGA since Oct 13, 2026$2.00 / $10.00 through Nov 30; $4.00 / $20.00 from Dec 1Same class of hard reasoning; Google says hard prompts can take several minutes
Gemini 4 Hydrogengemini-4-hydrogenGA since Nov 12, 2026$1.50 / $7.50Google's recommended starting point for coding and agent work
Gemini 3.8 Flashgemini-3.8-flashStable$0.75 / $3.75 through Dec 31; $1.50 / $7.50 from Jan 1, 2027Fast fallback for most tasks
Gemini 3.5 Flash-Litegemini-3.5-flash-liteStable$0.30 / $2.50Cheapest, fastest fallback

Check any fallback chain written earlier this year: from December 1, 2026, requests to gemini-2.5-pro are routed to gemini-3.8-flash and gemini-2.5-flash to gemini-3.5-flash-lite, so a chain that falls back to 2.5 Pro will quietly get a Flash model. Whether Argon is worth it for your workload after its introductory price ends is covered in our Gemini 4 Argon vs Gemini 3.1 Pro comparison, and the fast fallback in our Gemini 3.8 Flash guide.

For production environments that require consistent reliability across multiple AI models, API proxy services like laozhang.ai can simplify the fallback process by providing a single API endpoint that handles model routing and failover between providers. This approach is particularly valuable when your application needs to fall back between Google and non-Google models, since direct API integration with multiple providers adds significant complexity to your codebase.

Is Gemini 3.1 Pro Still Timing Out? Status on November 15, 2026

When this guide was first written in February, Gemini 3.1 Pro was days old and a general-availability release looked likely within a few months. That did not happen. On November 15, 2026:

  • Still Preview. The model ID is gemini-3.1-pro-preview, released February 19, 2026, with no shutdown date on Google's deprecations page. The old gemini-3-pro-preview ID has pointed to it since March 9, 2026.
  • No change on December 1 for 3.1 Pro. The December 1 changes affect Gemini 2.5 Pro and 2.5 Flash routing and the end of Gemini 4 Argon's introductory price.
  • 503s still happen. On November 2, 2026, a developer reported 503 UNAVAILABLE responses after stalls of about two minutes; Google staff replied on November 5 that "503 errors are due to our services being temporarily overloaded."
  • Newer models exist. Gemini 4 Argon reached general availability on October 13 and Gemini 4 Hydrogen on November 12, 2026; neither replaces 3.1 Pro automatically.
  • Where to check status. aistudio.google.com/status for the Gemini API and AI Studio, the Google Cloud Service Health page for Vertex AI, and the Google Workspace Status Dashboard for the Gemini app.

The thinking-time part of the delay is a property of the model, not a defect, so it will not go away: plan for 10–30 seconds per answer and set timeouts accordingly. For now, the practical strategy is to use Gemini 3.1 Pro for tasks that genuinely need it, keep a Flash model in your fallback chain for time-sensitive work, and re-test Argon or Hydrogen if 503s keep interrupting you.

Frequently Asked Questions

Is "Deadline expired before operation could complete" a 503 or a 504?

Both. Gemini returns the same message with 504 DEADLINE_EXCEEDED and with 503 UNAVAILABLE. In public reports up to November 15, 2026, 13 showed it with 504 (all in 2026) and 10 with 503. Act on the status code: for 504, raise or remove your client timeout and then shrink the request; for 503, retry with backoff and switch models if it continues.

What unit is the google-genai timeout in, and what is the default?

Milliseconds, in both the Python and JavaScript SDKs: 600_000 is 10 minutes and 120 is 0.12 seconds. There is no default client timeout, and the SDKs only send a server deadline (X-Server-Timeout) when you set one. Without retry options, google-genai 3.3.0 makes a single attempt.

Why does Gemini 3.1 Pro take 30+ seconds to respond when other models respond in 1-2 seconds?

Gemini 3.1 Pro thinks before it answers, and its thinking level defaults to high. Artificial Analysis measured a median time to first token of 15.56 seconds on AI Studio and 18.87 seconds on Vertex AI (5-day average, November 15, 2026), down from 31.36 and 21.54 seconds in February 2026. Hard prompts take longer. Once it starts generating, output arrives at around 80–110 tokens per second. Lowering the thinking level to low trims only a little on 3.1 Pro; for answers in a few seconds, use a Flash model.

Does the 99-hour lockout bug affect timeout errors?

No. The "locked out for 99 hours" report came from a Google AI Pro subscriber using Google Antigravity in February 2026 — a subscription usage limit, not a Gemini API error and not a 429 cooldown. It has nothing to do with 503, 504 or client timeouts. If the API returns 429 RESOURCE_EXHAUSTED, that is a rate or quota limit; see our Gemini 429 guide.

Do I get charged for timed-out API requests?

Google's billing FAQ says: "If your request fails with a 400 or 500 error, you won't be charged for the tokens used. However, the request will still count against your quota." A 503 or 504 from the API is a failed request under that rule, and one developer's AI Studio logs showed such failures with 0 tokens. A timeout raised by your own client is different: Google may have finished the request after you stopped waiting, and retrying sends it again, so long timeouts plus retries can cost more than one call.

Is Vertex AI significantly better than AI Studio for Gemini 3.1 Pro?

Not on latency any more. In February 2026, Artificial Analysis measured Vertex AI faster (21.54 s vs 31.36 s to first token); on November 15, 2026, AI Studio was faster (15.56 s vs 18.87 s) and also faster at output (111.5 vs 79.4 tokens per second). Vertex AI can still help with reliability: one developer reported in May 2026 that moving 3.1 Pro traffic to Vertex stopped long hangs and 504s. On Vertex, 3.1 Pro is a public preview available only on the global endpoint, and it needs a Google Cloud project with billing.

Can I use Gemini 3.1 Pro through third-party API providers to avoid timeouts?

Yes, several third-party API providers offer access to Gemini 3.1 Pro with their own retry logic, timeout handling, and model fallback configurations, which can smooth over short 503 waves. They cannot make the model think faster, and they add their own layer of latency and cost. Check which timeout the provider applies to long requests before you rely on it, and evaluate whether the reliability improvement justifies the additional overhead for your specific use case.

Found an error, or hit a problem this article does not cover? Send the article URL and what you saw to hi@laozhang.ai. We check it and update the article.