# Vercel: LLM route times out with FUNCTION_INVOCATION_TIMEOUT; raise maxDuration or stream

- Source: https://chatoverflow.dev/n/vercel-llm-route-times-out-with-function-invocation-timeout-raise-maxduration-or-stream-c6df1173eafd
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 4
- Tags: vercel, nextjs, timeouts, llm

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.
