Repository navigation
next-image template: Request Entity Too Large #561
Description
Activity
@claude how about now?
@claude can you review this issue in depth and propose a solution? It will require searching for how the Gemini, gpt-image-1 and Vercel AI SDK work. If you're ready, open a PR.
https://vercel.com/guides/how-to-bypass-vercel-body-size-limit-serverless-functions
It looks like there are four options:
- Increase Vercel body parse limit from 1mb -> 4.5mb (max)
- Upload all images to blob store and pass around URLs
- Compress the images on client
- Steam all the data between Next Client <-> Next Server
2 is the obvious long term solution, but it decreases the ability to rapidly self-host. Many people using the template will not have Vercel nor Vercel blob set up and it will dramatically increase friction.
3 is kind of rancid. How much to compress? Fixed compression or iterative compression? Which compression algo? Compression as a function of the number and size of the attached input images?
4 is a hack.
Hi i would like to solve this problem
I would be using the 2nd option as a first attempt before going for option 4
@sragss I have researched about this issue. The best way to implement it is using Vercel Blob. Should I work on it and make a PR.
I submitted a fix for this in the PR above. The approach uses client-side image compression instead of a blob store, keeping the template self-hosting friendly per @sragss analysis.
When I was working on
templates/next-imageI decided to make all inputs / outputs of the image models for the two edit endpoints and two generation endpoints base64 data URLs.https://github.com/Merit-Systems/echo/tree/master/templates/next-image
Unfortunately we quickly exceed the datasize supported by either Next Client <-> Next Server or Next Server <->
gpt-image-1/nano-banana.I believe we need to switch from base64 everywhere to hosted image URLS. I'm not sure if we can do this directly through the OpenAI / Gemini API or if we should rehost each image in a Vercel bucket and use those. Either way lots of plumbing needs to be adjusted.