ERROR CODES / ENGLISH

API timeout: the request did not complete in time

Five causes of AI API timeouts, from client thresholds that are too short to slow upstreams, with settings for common clients.

Reviewed 2026-11-13 · ERROR CODES / ENGLISH · Chinese detail: 完整中文页

What it means

The request did not receive a complete response within the configured time. Raise the timeout threshold first, then check the network path. Most timeouts come from client settings that are too short, not from a service outage.

Error: The operation timed out.
FetchError: request to https://api.example.com/v1/messages failed, reason: connect ETIMEDOUT
{"error":{"message":"upstream request timeout","type":"new_api_error"}}

Common causes

ShareCause
40%Client timeout set too short (the default 30s is not enough for long answers)
30%Upstream under high load, responding slowly
15%Network path problem (cross-border, proxy)
10%Relay gateway timeout is shorter than your own
5%The streaming response was interrupted mid-way

How to confirm

Measure where the time goes:

curl -o /dev/null -s -w "connect: %{time_connect}s\nfirst byte: %{time_starttransfer}s\ntotal: %{time_total}s\n" \
  https://api.example.com/v1/models -H "Authorization: Bearer $KEY"

Fix

Raise the timeout:

ClientHow to set it
OpenAI SDKclient = OpenAI(timeout=120)
Anthropic SDKclient = Anthropic(timeout=120)
Node fetchAbortSignal.timeout(120_000)
curl--max-time 180
CursorFind Network / Timeout in settings

Long answers need 120 seconds or more. Generating 4000 tokens on a slow channel can exceed 60 seconds.

If it still fails

SymptomResponsible party
Short requests work, long answers time outYour timeout threshold
All requests time outNetwork or the site is down
Timeouts only at peak hoursUpstream load
Switching network fixes itYour link

General guidance, not a statement about any specific provider. For measured data, see the relay directory and method.