413 Request Entity Too Large in workflow

I am trying to run a python block in a Workflow. This block keeps erroring out with this as the message:

413 Request Entity Too Large

And I am 99% sure that it's because of an input variable to the block (a base64 string representation of a set of images) that is too many MB. Reducing the size of the input allows that block to pass.

My question -- is there any way of fixing this by [preventing] an input variable from being used as an input to a python block?

I have seen existing recommendations re: this error to adjust the client_max_body_size (see this) but that seems not to be accessible in a retool workflow.

1 Like

Hey @Alex_Gao - I think your instinct here is probably right on. There is a hard limit on the size of the request used to transfer data between workflow blocks, which I believe is ~100MB. This restriction can't be bypassed by setting environment variables, either.

The only real workaround is to chunk your data up via a loop or something similar. Would that be feasible in this particular case? I might be able to provide more insight if you describe the preceding blocks and your high level goal with this workflow.

Hi Darren;

We are receiving a webhook with a link to a PDF, parsing that PDF into a bunch of base64 image representations, passing those base64 image representations to GPT, and receiving back the text of those PDFs. so, just PDF OCR basically.

We could go one by one through those base64 image representations in a loop - I haven't done that in retool before but it seems to be possible.

If there are any better suggestions for doing this PDF OCR, perhaps using built in retool tools, would love to hear them! new to this stuff.

Thanks!

That makes sense. :+1: Unfortunately, there's not a great native option for OCR within a Retool workflow. For such use cases, I usually recommend folks import a Python library or make a query directly to the LLM of their choice. Either way, it'll typically be necessary to do so from within a loop.

At a high level, retrieving data via an API request and then performing an operation on each individual element from within a loop is a super common pattern. There are some good examples here in the community, in addition to the docs that I linked above. Let me know if you have any questions! And if you feel like you want some additional assistance, we host Office Hours every Tuesday and Thursday. :slightly_smiling_face:

Have you had a chance to revisit this, @Alex_Gao?

Yup, we're looping. Thanks for the follow up Darren!

1 Like