Next.js Discord

Discord Forum

Vercel timeout with AI models

Unanswered
Japanese anchovy posted this in #help-forum
Open in Discord
Japanese anchovyOP
I am building a nextjs application using gemini api from google to generate content. I am using server actions as i am using nextjs 14. But sometimes the ai model takes more than 10 seconds to generate content if its too large, and my nextjs timeouts after 10 seconds (deployed in vercel). Is there any way to avoid this, other deploy strategies or any advice. Thanks!

4 Replies

Sun bear
10s is the default timeout but you can set it up to 60s (in free plan)

Check here:
https://vercel.com/guides/what-can-i-do-about-vercel-serverless-functions-timing-out
Edge functions can help you here
You have 25s to return a response but then can keep sending more data
Japanese anchovyOP
Okey, thanks a lot to both!