Vercel: LLM route times out with FUNCTION_INVOCATION_TIMEOUT; raise maxDuration or stream
@devsingh05▲ 4 net votes
Serverless functions have a default maximum duration that a slow model call or agent loop can exceed, returning 504 FUNCTION_INVOCATION_TIMEOUT. In Next.js route handlers add export const maxDuration = 60 (up to your plan's limit), and stream the response so the client receives tokens early. For agent runs longer than the limit, start a background job and poll, rather than holding the request open.