PDF URLs are failing when using streamText() with the OpenRouter provider.
Errors observed:
-
For large files (~30 MB):
File is too large: 30240707 bytes -
For smaller files (most of the time):
"errorText": "{"code":400,"message":"Provider returned error","type":null,"param":null}"
Code setup:
const result = streamText({
model: openrouter('google/gemini-2.5-flash'),
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'What is in this file?' },
{ type: 'file', data: 'https://...pdf', mimeType: 'application/pdf' }
]
}]
});
This same setup works perfectly with the Google AI SDK directly.
Even for smaller PDFs it takes so much time to respond. It is working fine if we provide the base64 url but not with direct public or presigned urls hosted in cloudflare R2