Contact
Skip to the page text

Documentation / Concepts

Long Requests and Timeouts

A large language model can take minutes to answer. A very long prompt can take minutes before the first word appears, and a reasoning model can pause for a long time between parts of its answer. The platform keeps such a request alive, and it tells the client clearly when it gives up.

How Long a Request May Take

LimitValueWhat the client sees
Whole request10 minutes for the answer to start502 with the reason
First part of a streamed answergrows with the prompt: 10 seconds for a short prompt, about 5 minutes for a half-megabyte prompt, never more than 10 minutes503 with Retry-After: 2 and the code ttft_deadline_exceeded; an error event inside the stream when the stream had already started
Silence between two parts of a streamed answer2 minutesan error event inside the stream: the model has stalled

When the platform gives up on a request, it also stops the model working on it, so a stopped request does not keep a GPU busy.

What a Streaming Client Sees

  • Within 2 seconds the response starts: status 200, the headers, and a first line : stream-open.
  • Every 15 seconds while the model is silent, before the first word and between parts, a line : keepalive.
  • Lines that start with : are comments in the event-stream format. Every client library ignores them; they exist so that nothing between the client and the platform mistakes a thinking model for a dead connection.
  • A fast error (a bad parameter, for example) still arrives with the model's own status code and reason, because it happens before the stream starts.
  • An error after the stream started arrives as an error event inside the stream, never as a stream that just stops. A stream that ends without an error or its normal end marker was cut by something between the client and the platform.

Non-Streamed Requests

A non-streamed request receives its whole answer at the end and nothing before it. If anything between the client and the platform closes connections that stay silent (see below), use streaming for long answers.

When a Client Gives Up

A client that closes its connection before the answer starts stops the model's work on that request at once. Set the client's own timeout to at least 10 minutes for long answers; a shorter client timeout wastes the work done so far.

When the Platform Restarts

A restart or update of the API gateway lets requests that are already running finish, for up to 10 minutes, before it stops. New requests are not accepted during that time.

A Proxy or Load Balancer in Front of the API Gateway

Anything placed between clients and the API gateway (a reverse proxy, a load balancer, an ingress) must allow what the platform allows, or it cuts long requests off itself:

SettingAt least
Request timeout (the whole request)600 seconds
Idle or read timeout (time between two bytes)60 seconds. Streams send a byte at least every 15 seconds; a non-streamed request sends nothing until its answer is complete, so it needs the full 600 seconds here
Response bufferingoff for text/event-stream responses. The platform sends X-Accel-Buffering: no and Cache-Control: no-cache, no-transform on every stream
Compressionoff for text/event-stream responses

Defaults that are too short and have cut requests off in practice:

ProductSettingDefault
Envoy, Envoy Gatewayroute request timeout15 seconds
nginxproxy_read_timeout60 seconds
Cloud load balancersidle timeoutoften 60 seconds

The symptom of a proxy limit that is too short: requests fail after exactly the same number of seconds every time, with 504 or a closed connection, while the same request sent straight to the API gateway succeeds.

Which Alert Points at a Connection Problem

These alerts appear on the Alerts page. Each names the inference node or model it is about.

AlertWhat it meansWhat to do
Inference node keeps losing its connection to the API gatewayThe connection between an inference node and the API gateway ended at least twice in 30 minutes; requests to that node's models failed each time.A fixed rhythm points at a setting on the node or the gateway; an irregular one points at the network between them. Check both logs for the reason given at each end.
Inference node's connection to the API gateway is stalledThe connection is open, but nothing answers over it; requests hang.If it recovers on its own, the connection was failing. If it persists, check the inference node's log and restart the model from the Servers page.
Inference node has no connection to the API gatewayThe node is up but none of its models can be reached by clients.Check that the API gateway is running and that the node can reach the API gateway address under Configuration.
Requests to a model failed because a connection droppedClients got errors because the connection ended during their requests.Look at the connection alerts for the same inference node: they name the cause.
Model is running but the API gateway does not route to itThe Servers page shows the model running, but clients cannot reach it.Check the node's connection to the API gateway; restarting the model registers it again.
Model's engine answers its health check slowlyThe model still works, but slowly; requests are likely stalling.Check the model's console log on the Servers page; a restart clears a hung engine.
Requests to a model keep failingMore than 10% of real client requests failed over 10 minutes.Check the model's console log for the engine's errors, and the connection alerts for its inference node.

Found a mistake, or is something missing? Suggest an improvement to this page on GitHub.

Platform release 5.10.4, . Source of this page at v5.10.4. This page as Markdown.