Spinning out a follow-up flagged in PR #409 review (#409 (comment) / r2218663501).
OpenAICompatibleVideoAdapter.getVideoUrl falls through to videos.downloadContent/content/getContent/download and a raw fetch for backends that don't return a CDN URL on retrieve(). In every fallback path we read the entire video into an ArrayBuffer, base64-encode it, and emit a data: URL. PR #409 added a >10 MiB warning (warnIfLargeMediaBuffer) but the underlying behaviour is still unsafe on Workers / Lambda / small isolates.
This will almost certainly blow up workers. It's pretty common for videos to be bigger than 100mb. — @tombeckenham
Downloading the video and base64'ing it will cause most backends to run out of memory. I'm wondering if we support these older methods at all. At the very least we should add a warning with logger and look at whether buffers are over e.g. 10mb. It's quite hard to figure out where memory issues come from as they don't necessarily occur at the point this blob would be created. I'm wondering if we might want to add a media uploader function to the the constructor in a future PR — @tombeckenham
Scope
Related
cc @tombeckenham
Spinning out a follow-up flagged in PR #409 review (#409 (comment) / r2218663501).
OpenAICompatibleVideoAdapter.getVideoUrlfalls through tovideos.downloadContent/content/getContent/downloadand a rawfetchfor backends that don't return a CDN URL onretrieve(). In every fallback path we read the entire video into anArrayBuffer, base64-encode it, and emit adata:URL. PR #409 added a >10 MiB warning (warnIfLargeMediaBuffer) but the underlying behaviour is still unsafe on Workers / Lambda / small isolates.Scope
mediaUploader(orMediaUploadStrategy) constructor option onOpenAICompatibleVideoAdapter(and likely image/audio adapters too) that takes a stream-or-blob and returns a public URL.retrieve()-time CDN URL, return aVideoUrlResultthat surfaces "upstream URL not available; provide amediaUploaderto download/host the bytes" rather than silently base64ing.warnIfLargeMediaBufferto flow through theInternalLoggerinstead ofconsole.warnonce a logger is plumbed through these methods.Related
video.ts:148andvideo.ts:165.responses-text.tsbase64 data-URI thread (feat: extract @tanstack/openai-base and @tanstack/ai-utils packages #409 (comment)) — Tom mentioned an in-flight PR removing that for input attachments; this issue covers the symmetrical concern on the output side.cc @tombeckenham