504 Gateway Timeout from an API: did my request go through?
A 504 from an API means a proxy stopped waiting for the server. Your request may still be running, so check before you resend. How to avoid 504s.

A 504 Gateway Timeout from an API means a gateway or proxy between you and the API server stopped waiting for the server's answer. It does not mean the server rejected your request: the work may have been accepted and may still be running. So don't resend a request that creates or bills something until you have checked. For long work, submit asynchronously with an idempotency key and poll for the result instead of holding one request open.
The status code definitions come from RFC 9110, the HTTP semantics standard. The worked example is Sume's job API, from its Jobs and results docs. Both were read on 2026-09-28.
Whose timeout fired?
Not the API's. RFC 9110 defines 504 as a server, acting as a gateway or proxy, that did not receive a timely response from the upstream server it needed. The 504 is written by whatever sits in the middle: a load balancer, a CDN, an API gateway, or your own reverse proxy. That is also why a 504 body may not look like the API's usual JSON error.
| What you got | What it means | Is the work still running? |
|---|---|---|
502 Bad Gateway | The gateway received an invalid response from the server behind it | Unknown: check before resending |
504 Gateway Timeout | The gateway got no timely response from the server behind it | Unknown: check before resending |
| Your own client timeout | Your code stopped waiting; no status at all | On Sume, it isn't canceled: the job keeps running and billing |
524 on Sume's MCP jobs_wait | A transport failure, never a job outcome | The job is unaffected: re-issue jobs_wait on the same ids |
Did my request still go through after a 504?
Maybe, and you can't tell from the 504. What you do next depends on whether you already have an id for the work:
- You have a job id: poll it. Sume's docs say to keep the job id and recover with the jobs API instead of submitting duplicate paid work. A client-side timeout does not cancel the job; it keeps running and still bills.
- You have no id, because the 504 answered a submit that carried an idempotency key: retry it with the same
Idempotency-Keyand the same body. On Sume'sPOST /v1/videos, a replay returns the original job, so the retry doesn't start a second paid one. - You sent no idempotency key: look before you resend. On Sume,
GET /v1/jobslists jobs, so you can check whether the first attempt created one.
# A retry after a 504: same key, same body, same job
curl -X POST https://api.sume.com/v1/videos \
-H "Authorization: Bearer $SUME_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: desk-pan-2026-09-28-001" \
-d '{"model": "sume/auto", "prompt": "A slow pan across a desk at sunrise"}'Why do long API calls return 504?
Because a request held open with nothing transferring looks idle to everything in between. Writing about its hosted MCP waits, Sume's docs say every edge closes such a request eventually, and that a request held for 600 seconds dies at the edge (502 / Transport send error) before it can answer. Video jobs routinely outlast even a 30-second wait.
An API can avoid the gateway timeout by never holding the request that long. Sume caps the blocking wait on a submit at 30 seconds. When the wait runs out, the response is still a 2xx with the job id, and the docs say you must not submit a new paid job for the same intent.
How do I stop getting 504s on long jobs?
- Submit asynchronously. Sume's default
asyncmode returns202with the job envelope right away, as the asynchronous request-reply pattern describes. - Send an
Idempotency-Keyon every submit, so a retry returns the original job instead of billing a second one. - Poll
status_urlwith short requests, honoringnext_poll_after_seconds, or take a webhook and keep polling as the backup. - Put your long deadline in your own client, not in one HTTP request. Video generation API timeouts lists Sume's caps and the SDK defaults.
Sources
Related posts
More in Developers
- AI model aggregator: what it is and when to go direct
An AI model aggregator sells many labs' models behind one API key, one request shape and one bill. What you gain, what you give up, and what to check.
- AI model router: what it does and what you give up
An AI model router picks which model serves each request, so your code sends one id. How that differs from pinning a model, and the control you trade.
- Why an API returns 404 Not Found, and how to fix it
An API returns 404 when no route matches your path or method, or when the id doesn't exist for your credentials. How to tell them apart and fix each.
- API vs SDK: what's the difference, and do you need one?
An API is the contract: routes, fields and errors. An SDK is a library in one language that calls that API for you. What an SDK adds, and when to skip it.
Written by Sume