feat(ai): experimental_transcribe({maxDownloadSizeInBytes})#9481
feat(ai): experimental_transcribe({maxDownloadSizeInBytes})#9481
experimental_transcribe({maxDownloadSizeInBytes})#9481Conversation
2a2539c to
3bc4ce1
Compare
|
Could affect generate/stream text/object url downloads |
I confirmed that it e.g. applies to this example, without a way to set a max download size. await generateText({
model: openai('gpt-4o'),
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Describe the image in detail.' },
{
type: 'image',
image:
'https://github.com/vercel/ai/blob/main/examples/ai-core/data/comic-cat.png?raw=true',
// OpenAI specific option - image detail:
providerOptions: {
openai: { imageDetail: 'low' },
},
},
],
},
],
});should we add |
Adding maxDownloadSizeInBytes to all methods breaks encapsulation regarding download configuration and leads to unspecified behavior with custom download functions. instead I'd prefer if we could expose our download function somehow, with the max download size as an option (but there will be a naming conflict with the upcoming download for the files api that we need to solve). |
|
closing in favor of #12445 |
- Replace unbounded `arrayBuffer()`/`blob()` calls in `download()` and
`downloadBlob()` with streaming reads that enforce a **2 GiB default
size limit**
- Add `abortSignal` passthrough from callers (`transcribe`,
`generateVideo`) to `fetch()`
- Check `Content-Length` header for early rejection before reading body
- Track bytes incrementally via `ReadableStream.getReader()`, abort with
`DownloadError` when limit exceeded
- Expose configurable `download` parameter on `transcribe()` and
`experimental_generateVideo()` (instead of adding a new
`maxDownloadSize` argument) — keeps download config separate from API
function signatures
- Export `createDownload({ maxBytes })` factory from `ai` for custom
size limits
closes #9481 / addresses
#9481 (comment)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
- Replace unbounded `arrayBuffer()`/`blob()` calls in `download()` and
`downloadBlob()` with streaming reads that enforce a **2 GiB default
size limit**
- Add `abortSignal` passthrough from callers (`transcribe`,
`generateVideo`) to `fetch()`
- Check `Content-Length` header for early rejection before reading body
- Track bytes incrementally via `ReadableStream.getReader()`, abort with
`DownloadError` when limit exceeded
- Expose configurable `download` parameter on `transcribe()` and
`experimental_generateVideo()` (instead of adding a new
`maxDownloadSize` argument) — keeps download config separate from API
function signatures
- Export `createDownload({ maxBytes })` factory from `ai` for custom
size limits
closes #9481 / addresses
#9481 (comment)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Background
Summary
Manual Verification
Checklist
pnpm changesetin the project root)pnpm prettier-fixin the project root)Future Work
Related Issues