All guidesVercel and env vars
On this page

AI SDK on Vercel

Vercel

AI SDK stream cut off on Vercel: maxDuration, Fluid compute and docs that disagree

By Ohad Krispin, founder of VibeRaven · LinkedIn

An AI SDK response that streams fully in development and stops partway on Vercel ran into the function's maximum duration: Vercel counts the time spent streaming toward it and ends the invocation at the limit. With Fluid compute, on by default for projects created since April 23, 2025, the default is 300 seconds on every plan, so a reply that is cut at the same 30 or 60 seconds every time points at a lower value set in the route, such as export const maxDuration = 30 copied from an older example. Remove it or raise it: up to 300 on Hobby and 800 on Pro and Enterprise, 1800 in beta on some runtimes. The AI SDK's own docs disagree: its Vercel deployment guide still says Hobby functions stop at 10 seconds and can go to 60, while its timeout troubleshooting page and Vercel's limits page say 300. Checked on 2026-10-27.

Use this from your agent

  • Claude Code: 4 read-only tools; cannot see your repo.
    claude mcp add --transport http viberaven https://viberaven.dev/mcp
  • Codex: same server, in ~/.codex/config.toml.
    [mcp_servers.viberaven]
    url = "https://viberaven.dev/mcp"
  • In your repo: writes Vercel + Supabase check rules for your agent (what it writes).
    npx -y viberaven init

The two AI SDK pages that disagree

The AI SDK guide "Vercel Deployment Guide" says Vercel functions have a maximum duration of 10 seconds on the Hobby tier, shows export const maxDuration = 30 and says Hobby can go to 60. The AI SDK troubleshooting page "Getting Timeouts When Deploying on Vercel" says Fluid compute made the default 5 minutes on all plans and shows maxDuration = 600, which needs Pro or Enterprise. Vercel's own limits page agrees with the troubleshooting page: 300 seconds default, 300 maximum on Hobby, 800 on Pro and Enterprise.

Find the value that wins

A maxDuration exported from the route file wins over vercel.json, which wins over the Default Max Duration in the project settings, which wins over the plan default. Search all three before you change one:

grep -rn "maxDuration" app src pages vercel.json 2>/dev/null

Fluid compute on an older project

Projects created before April 23, 2025 may not have Fluid compute turned on. Check Settings, Functions in the Vercel project, turn it on and redeploy.

Routes on the Edge runtime

Vercel's limits page says Edge runtime functions must start sending a response within 25 seconds and can then keep streaming for up to 300 seconds. A route with export const runtime = 'edge' that waits on the model before the first chunk fails earlier than a Node.js route.

Error: Connection closed

The AI SDK troubleshooting page names "Uncaught (in promise) Error: Connection closed" as one symptom. In ai 7.0.154 that message appears only in the MCP client code, so do not wait for it: a reply cut at the same length of time on every long answer is the signal. Compare the request duration in the Vercel logs with your maxDuration.

Checklist

How to fix it, then check the fix

  1. 01Time a long reply in production and note where it stops.
  2. 02Search the route, vercel.json and the project settings for maxDuration, and remove or raise any value below what the reply needs.
  3. 03
    Set the route value within your plan, in the route file that calls streamText:
    // app/api/chat/route.ts
    export const maxDuration = 300
  4. 04Check that Fluid compute is on for the project, and redeploy.
  5. 05Ask for a reply long enough to pass the old cutoff, and confirm the full text arrives.

Related

Sources

Official docs behind this checklist

FAQ

FAQ for builders before launch

Does streaming avoid the limit?

No. Vercel's limits page says the maximum duration includes the time spent sending the response, streamed responses included.

What if the reply needs longer than my plan allows?

Move the work out of the request. Vercel points long-running work to Vercel Workflows, which can pause and resume without a duration limit.