Fix Webhook Timeout on a Long Running AI Call (4 Patterns)
To fix a webhook timeout on a long running AI call, return 200 or 202 with a job ID immediately, run the LLM call in a background workflow or queue, then deliver the result by callback URL, polling or streaming. Raising the timeout rarely works because the limit is usually not yours.
- Three layers can time out: the sender's webhook client, the automation platform's step or execution limit, and the LLM API or the proxy in front of it.
- The status code and the step duration in the execution log tell you which layer gave up, and timing the LLM call alone with curl confirms it.
- The reliable fix is to acknowledge fast with a job ID, work in the background, and deliver the result by callback, polling or streaming.
- Every retried webhook must carry an idempotency key, otherwise a sender timeout makes the LLM run twice and you pay twice.
- Output tokens dominate latency, so max_tokens, a smaller model, shorter prompts and parallel chunks often remove the timeout without any redesign.
Why does a webhook time out on a long running AI call?
A webhook is a request that expects a quick reply. Senders such as Slack, Twilio, Stripe, form tools and CRMs usually wait somewhere between 3 and 30 seconds. An LLM call that writes a long answer can take 30 to 120 seconds or more, so the sender hangs up before your workflow responds.
The timeout can happen in three separate places, and raising a limit in the wrong one changes nothing:
The sender's webhook client gives up and may retry. The automation platform (Zapier, Make, n8n, Pipedream) cuts a step or the whole execution. The LLM API, or a proxy or gateway in front of it (Cloudflare, a load balancer, a serverless function), closes the connection.
| Layer | Typical symptom | Example limits (verify, they change by plan and version) |
|---|---|---|
| Sender's webhook client | Sender shows failed delivery, 408 or its own timeout, then retries | Chat and telephony tools often want an ack in about 3 to 15 seconds |
| Automation platform | Step fails with a platform error while the sender is fine | Webhooks by Zapier about 30 s; Zapier Code steps roughly 1 to 10 s depending on plan; Make webhook response about 40 s plus a scenario execution cap; n8n HTTP Request has a configurable timeout option |
| LLM API, proxy or serverless host | 504, 524 or a dropped connection with no body | Cloudflare returns 524 after about 100 s of waiting; serverless functions have per-plan maximum durations |
How do I find which layer timed out?
Start with the error, then the clock. Each layer fails in a recognizable way, and the step duration in the log usually points straight at the limit that fired.
- Read the status code. 408 or a sender-side 'timed out' means the caller gave up. 504 means a gateway or proxy gave up waiting on an upstream. 524 is Cloudflare waiting more than about 100 seconds. A platform-specific message such as 'execution timed out' or 'operation timed out' means the platform's own cap.
- Open the execution log and compare the failed step's duration with the limits above. A failure at almost exactly 30, 40 or 100 seconds is a limit, not a random fault.
- Check whether the workflow kept running after the sender failed. If the run completed, the caller timed out but your work succeeded, which means you need an early response, not a faster model.
- Time the LLM call alone with curl, using the same model, prompt and max_tokens. If it takes longer than the shortest limit in the chain, no setting will save you except changing the pattern or shortening the call.
time curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","max_tokens":1500,
"messages":[{"role":"user","content":"<your real prompt>"}]}' \
-o /dev/null -w 'total: %{time_total}s\n'Which pattern should I use?
Choose by who is calling and how long the work takes. If the caller needs an answer inside its own window, you must acknowledge first, whatever the model speed.
| Caller | Under 10 s | 10 to 60 s | Over 60 s |
|---|---|---|---|
| Human in a chat UI | Respond directly | Streaming (SSE), or ack then post the message | Ack, then push result to the chat |
| Another system you control | Respond directly | Ack plus callback, or polling | Callback plus queue worker |
| Slack, Twilio or similar (3 to 15 s ack) | Respond directly only if reliably fast | Ack immediately, reply through the response URL or API | Ack immediately, queue, post result later |
| No-code form or CRM trigger | Respond directly | Respond early, continue in the same workflow | Second workflow or queue, write result back to the record |
How do I acknowledge immediately and call back?
This is the core fix. The caller sends the request with a callback_url and an idempotency key. You return 202 with a job ID in well under a second, then run the LLM call elsewhere and POST the result to the callback.
Request from the caller:
POST /webhook/summarize
{
"idempotency_key": "order-81734-summary-v1",
"callback_url": "https://caller.example.com/hooks/ai-result",
"input": { "document_id": "81734" }
}
Immediate response (202):
{ "job_id": "job_01HZX", "status": "queued" }
Later callback to callback_url:
{
"job_id": "job_01HZX",
"idempotency_key": "order-81734-summary-v1",
"status": "succeeded",
"result": { "summary": "..." },
"error": null
} What about queues, polling and streaming?
Idempotency checklist: store each idempotency key with its job ID before doing any work; if the same key arrives again, return the existing job ID and do not call the LLM; keep keys for at least as long as the sender retries. Sign callbacks with an HMAC header (for example X-Signature over the raw body with a shared secret) and set a timeout of about 10 seconds on the callback itself. Retry failed callbacks with exponential backoff, such as 5 s, 30 s, 2 min, 10 min, then give up and alert.
Queue-based: for volume, put jobs in a queue (SQS, Redis with BullMQ, a database table, a Make data store, or n8n queue mode) and let workers call the LLM. Cap worker concurrency to stay under your provider's rate limit. On a 429, respect the Retry-After header or back off exponentially with jitter. After a fixed number of attempts (3 to 5), move the job to a dead-letter queue or a 'failed' status so a human can inspect it instead of it vanishing.
Polling: the caller gets a job_id and calls GET /jobs/{id}. Use the statuses queued, running, succeeded and failed. Poll every 2 to 5 seconds, backing off toward 10 to 15 seconds, and stop at a hard ceiling such as 5 to 10 minutes, then treat the job as failed. Return the result or error in the same response once finished.
Streaming: set stream: true and send tokens over Server-Sent Events. Bytes flowing keeps most connections open and users see output at once. Most no-code webhook steps cannot consume a stream, so it suits custom front ends. Disable proxy buffering (for nginx, proxy_buffering off or the X-Accel-Buffering: no header) and send a comment heartbeat such as ': ping' every 15 seconds so idle-timeout proxies do not close the connection.
How do I set this up in n8n, Make and Zapier?
Each platform can acknowledge early. The exact node and module names below are the general approach, so confirm the labels in your version.
- n8n: set the Webhook node's response mode to respond immediately, or use 'Using Respond to Webhook Node' and place a Respond to Webhook node right after validation, returning {"job_id": ..., "status": "queued"} with code 202. Continue the same branch to the LLM node. For slow models, raise the timeout in the HTTP Request node's options. End with an HTTP Request node that POSTs to the callback_url, plus an Error Trigger workflow that alerts you.
- Make: put the Webhook response module early in the scenario, right after the trigger, so the sender gets its reply inside the roughly 40 second window. The modules after it keep running. For heavier jobs, have the first scenario store the job in a data store and call a second scenario through a custom webhook, so the LLM work runs on its own execution. Add an error handler route to the OpenAI module.
- Zapier: use Catch Hook as the trigger, which acknowledges the sender itself. Do not make the LLM call with Webhooks by Zapier or a Code step, because Webhooks by Zapier waits only about 30 seconds and Code steps have even shorter limits, so a long completion hits the same timeout. Instead, use Webhooks by Zapier only to hand the job (job ID, prompt input, idempotency key) to an external worker such as a small function, Pipedream or n8n, which returns immediately. The worker makes the LLM call and POSTs the result to a second Zap's Catch Hook, which writes it back to your app. The limit now belongs to the worker: Pipedream workflows, for example, have a configurable execution timeout that is capped by plan, and a serverless function has its own maximum duration, so confirm that cap exceeds your slowest call. A native AI app step is only an option if you have timed it past 30 seconds on your own plan, because its cap is not guaranteed. Use Storage by Zapier to hold job state between the two Zaps.
- Pipedream or a custom endpoint: return a response with the job ID first, then continue the work (in Pipedream, respond early from the HTTP trigger and keep the workflow running), or hand the job to a queue.
How do I make the LLM call itself faster, and what mistakes should I avoid?
Output tokens dominate latency. At roughly 30 to 100 tokens per second, a 2,000-token answer takes about 20 to 65 seconds, while the prompt contributes comparatively little. So cut output first: set max_tokens, ask for concise or structured JSON output, and request only the fields you need.
Then use a smaller model (a mini or flash class model instead of a flagship), avoid reasoning-heavy modes unless the task needs them, trim the prompt and context, and enable prompt caching for large repeated prefixes, which mostly reduces cost and time to first token. For big documents, split into chunks, run them in parallel within your rate limit, then merge the results.
Common mistakes: doing the work before responding; not returning a job ID; letting the sender's retry start a second LLM run because there is no idempotency key; simply raising the timeout, which hits the next limit down the chain; callback URLs with no authentication or signature; and failing silently with no error branch or alert.
To test, add a deliberate delay (a sleep of 45 or 90 seconds) in place of the LLM and confirm the ack still returns fast. Log start time, end time and duration per job. Alert on failed jobs and on jobs stuck in running past your ceiling. Replay the same idempotency key twice and check that only one LLM call is made.
Common questions
Why does Zapier time out when calling OpenAI?
Webhooks by Zapier waits roughly 30 seconds, and Code steps have even shorter limits that depend on your plan. A long completion can exceed that, so shorten the output with max_tokens, use a faster model, or offload the call to an external worker that calls back into a second Zap's Catch Hook.
Does Make.com really have a 40 second limit on the OpenAI module?
Make documents about 40 seconds for a webhook response and applies a scenario execution cap that varies by plan. Respond early with the Webhook response module and run the model call after it, or move it to a second scenario. Confirm the current numbers for your plan.
Can I just increase the timeout in n8n's HTTP Request node?
You can, and it helps when the n8n node was the one giving up. It does not help if the sender, a reverse proxy or Cloudflare closes the connection first, so respond to the webhook immediately as well.
How do I stop a retry from running the LLM twice?
Require an idempotency key (or use the sender's event ID) and store it with the job before any work starts. When a duplicate arrives, return the existing job ID and skip the LLM call.
Should I use polling or a callback?
Use a callback when the caller can expose a public HTTPS endpoint, since it needs no repeated requests. Use polling when the caller sits behind a firewall, runs in a browser, or cannot receive inbound requests.