Skip to content

next-image template: Request Entity Too Large #561

Description

@sragss

When I was working on templates/next-image I 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.

Generation failed
HTTP 413: Request Entity Too Large FUNCTION_PAYLOAD_TOO_LARGE iad1::55kxp-1760452325185-1866997c3cd4

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.

Activity

sragss commented on Oct 14, 2025

@sragss
ContributorAuthor

@claude how about now?

sragss commented on Oct 14, 2025

@sragss
ContributorAuthor

@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.

sragss commented on Oct 14, 2025

@sragss
ContributorAuthor

https://vercel.com/guides/how-to-bypass-vercel-body-size-limit-serverless-functions

It looks like there are four options:

  1. Increase Vercel body parse limit from 1mb -> 4.5mb (max)
  2. Upload all images to blob store and pass around URLs
  3. Compress the images on client
  4. 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.

added
bugSomething isn't working
MeritTag for Merit bounties.
on Oct 22, 2025

Otaiki1 commented on Oct 25, 2025

@Otaiki1

Hi i would like to solve this problem

Otaiki1 commented on Oct 25, 2025

@Otaiki1

I would be using the 2nd option as a first attempt before going for option 4

sachigoyal commented on Nov 1, 2025

@sachigoyal
Contributor

@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.

added a commit that references this issue on Mar 15, 2026
ad62897

Gengyscan commented on Mar 15, 2026

@Gengyscan

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.

added a commit that references this issue on Apr 8, 2026
added a commit that references this issue on Apr 19, 2026
bddb0b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    $250MeritTag for Merit bounties.bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions