Preview or Production site on Vercel

504: GATEWAY_TIMEOUT — Code: FUNCTION_INVOCATION_TIMEOUT

What it means
A server action or API route took too long to finish, so Vercel stopped waiting and closed the request.
Likely causes
  • An AI call is waiting on a slow or unresponsive provider instead of failing fast to the backup or streaming.
  • A database query or loop is running one query per item instead of fetching in parallel.
Prevention
Set maxRetries: 0 on the main AI client so slow refusals reach the backup immediately, and cap max_completion_tokens.

Copy for your agent

My deployed site returned `504 FUNCTION_INVOCATION_TIMEOUT`. Read the Vercel runtime logs (`npx vercel logs`), find what timed out, and make sure AI calls use `maxRetries: 0` on Tokentide with the Gateway fallback.

Full help articleThe Preview works but the live site doesn't

Last reviewed Nov 8, 2026