I started with what sounded like a simple product question:
What is the maximum PDF size I can send through OpenRouter?
That question is wrong in a useful way.
After testing OpenRouter routes, Gemini providers, Gemini Files API, Anthropic, OpenAI, the Vercel AI SDK, and several families of generated PDFs, the answer is not a single number like “10 MB” or “50 MB.” A PDF request is a pipeline. The first failing layer determines whether a document works.
transport/fetch → file admission → PDF parser → page-count gate → rendering/tokenization → model context → generation
A 100 MiB PDF can pass if most of those bytes are ignored after %%EOF. A 1 MiB PDF can fail if it has too many pages. A 50 MiB PDF can upload to Gemini Files API and still fail when you try to use it for generation.
If you are building a product where users upload PDFs, this matters. The honest UX is not “max PDF: 50 MB.” The honest UX is a preflight step that says one of:
- this PDF can be read directly;
- this PDF is large, so we will split or index it;
- this PDF needs OCR/text extraction first;
- this PDF exceeds the selected provider route.
This post explains the experiment and distills it into concrete builder guidance.
Conclusions first
If you only remember five things, remember these:
- Do not show users “max PDF: 50 MB.” That number may only describe upload/admission, not successful model use.
- For Gemini native PDF through OpenRouter/Google Vertex, start conservative: direct-read PDFs under roughly 10 MiB / 450 dense pages; split or index beyond that.
- Enforce page count separately from bytes. A sparse 1.07 MiB / 1,500-page PDF failed because the route enforced a 1,000-page limit.
- Use native PDF for small, layout-sensitive documents; use extraction/indexing for long Q&A. Do not stuff long PDFs into one model call by default.
- Make the upload UX return a plan, not a limit: “read directly,” “split,” “OCR,” “index,” or “too large for this route.”
Here is the user-facing policy I would start with for Gemini native PDFs via OpenRouter/Google Vertex:
| PDF profile | What to tell the user |
|---|---|
| ≤10 MiB and ≤450 normal text pages | “This PDF is likely to work.” |
| 10–15 MiB or 450–650 dense pages | “This PDF is near the reliability boundary. We need to check it before continuing.” |
| >15 MiB dense text | “This PDF is unlikely to work as one native PDF request.” |
| >1,000 pages | “This PDF has too many pages for this route.” |
| ~50 MiB uploaded through Gemini Files API | “Upload may succeed, but model use can still fail.” |
| scanned/image-heavy | “File size alone is not enough to predict this. We need to inspect the pages.” |
The short version
Here is the most useful summary from the current results.
| Route / path | What worked | What failed | Practical lesson |
|---|---|---|---|
| OpenRouter → Gemini 3.1 Pro → Google Vertex → native PDF | 100 MiB padded transport-control PDFs | Realistic dense PDFs around 15 MiB / 675 pages | byte transport is not the same as PDF ingestion |
| OpenRouter → Gemini 3.1 Pro → Google Vertex → native PDF | sparse 1,000-page PDF | sparse 1,500-page PDF | page count is a separate hard gate |
| Gemini Files API direct | uploaded and activated a ~50 MiB PDF | generation with that file failed | Files API admission is not generation success |
| OpenRouter with a Gemini Files API URI | n/a | PERMISSION_DENIED | Files API URIs are scoped to the uploading Google project/auth |
| OpenRouter → Claude Sonnet 4.5 → Anthropic | padded 30 MiB PDF | padded 32 MiB PDF | Anthropic exposed a clearer file-size admission limit |
| Vercel AI SDK → OpenRouter → Google Vertex | padded PDFs through 50 MiB | same caveats as OpenRouter route | SDK layer was not the limiting factor in this probe |
The most important product takeaway:
Do not build a PDF upload UX around one advertised MB limit. Build it around a route-specific preflight plan.
Figure 1: where the same PDF request can fail
The UX problem is that users think they uploaded “a PDF,” but your system has to move that PDF through every stage in the diagram.
Figure 2: observed outcomes are not ordered by file size
This is why the answer cannot be “the limit is N MiB.” The outcome depends on file size, page count, PDF structure, provider route, and whether you mean upload or generation.
Method
I tested PDFs through OpenRouter’s /api/v1/chat/completions endpoint using public Cloudflare R2 URLs. For provider-specific routing I used provider slugs and disabled fallbacks:
{
"model": "google/gemini-3.1-pro-preview",
"provider": {
"only": ["google-vertex"],
"allow_fallbacks": false
},
"plugins": [
{ "id": "file-parser", "pdf": { "engine": "native" } }
]
}
Every test PDF contained a visible marker:
OPENROUTER_PDF_OK
The model was asked to read the PDF and return exactly that phrase. A pass only means the route accepted the request, fetched or received the file, processed enough of the PDF to see the marker, and generated the expected response. It is not a document-understanding benchmark.
The experiment code lives here:
experiments/openrouter-file-limits/
The most important scripts are:
scripts/generate-pdfs.ts # padded transport-control PDFs
scripts/generate-pdflib-pdfs.ts # standards-compliant dense-text PDFs
scripts/generate-pdf-corpus.ts # sparse-page corpus
scripts/run-openrouter-tests.ts # direct OpenRouter runner
scripts/run-vercel-ai-sdk-tests.ts # Vercel AI SDK → OpenRouter runner
scripts/run-gemini-files-api-tests.ts # Gemini Files API runner
The pipeline model
A provider’s “PDF limit” usually conflates several different limits.
| Layer | Question | Example failure |
|---|---|---|
| Transport / fetch | Can the router/provider fetch or receive the bytes? | URL download failure, request too large |
| File admission | Does upstream accept or store the file object? | file too large, Files API rejection |
| PDF parser | Can upstream parse the PDF graph? | The document has no pages |
| Page-count gate | Does the file exceed a page cap? | exceeds the supported page limit of 1000 |
| Rendering / tokenization | Can pages, text, and images become model input? | OCR/rendering failure, image-token explosion |
| Context | Does the resulting input fit in the model context? | input token count exceeds maximum |
| Generation | Can the model answer cleanly? | empty answer, length stop, timeout |
This table is the core of the investigation. When someone asks “what PDF size works?”, the real question is: which layer fails first for this PDF, on this provider route, for this task?
Finding 1: transport controls are useful but misleading
The first PDFs were intentionally weird: a tiny valid one-page PDF followed by padding after %%EOF. This isolates transport and URL fetching. The PDF parser can ignore most of the bytes.
Through OpenRouter → Google Vertex → Gemini 3.1 Pro → native PDF, padded PDFs passed up to 100 MiB.
| PDF family | Size | Result |
|---|---|---|
| post-EOF padded | 50 MiB | pass |
| post-EOF padded | 75 MiB | pass |
| post-EOF padded | 100 MiB | pass |
This does not mean Gemini can read arbitrary 100 MiB PDFs through OpenRouter. It means this route could fetch a 100 MiB object and parse the small valid PDF body at the front.
That distinction turned out to be everything.
Finding 2: realistic PDF structure fails much earlier
I then generated standards-compliant PDFs using pdf-lib: normal pages, fonts, metadata, and lots of text. These are still synthetic, but they are boring valid PDFs rather than hand-written PDF objects.
Google Vertex + Gemini 3.1 Pro + OpenRouter native PDF produced this pattern:
| Size | Pages | Result |
|---|---|---|
| 1 MiB | 50 | pass |
| 10 MiB | 450 | pass |
| 11 MiB | 500 | pass |
| 12 MiB | 550 | inconclusive: provider timeout 524 |
| 13 MiB | 600 | pass |
| 14 MiB | 650 | inconclusive: provider timeout 524 |
| 15 MiB | 675 | fail: The document has no pages. |
| 20 MiB | 900 | fail: The document has no pages. |
| 25 MiB | 1,125 | fail: The document has no pages. |
| 30 MiB | 1,350 | fail: The document has no pages. |
| 50 MiB | 2,250 | fail: The document has no pages. |
Two points matter:
- The same route that accepted a 100 MiB padded object failed on a normal 15 MiB dense-text PDF.
- Near the boundary, some failures were provider timeouts rather than clean validation errors.
The error message is also misleading. These PDFs do have pages. Smaller PDFs from the same generator pass. So The document has no pages appears to be a generic upstream parser/ingestion failure at this complexity boundary, not a literal statement about the file.
Finding 3: a tiny PDF can fail from page count alone
To isolate page count from byte size and text density, I generated sparse PDFs: many pages, very little text per page.
Google Vertex + Gemini 3.1 Pro + OpenRouter native PDF:
| Size | Pages | Result |
|---|---|---|
| 0.07 MiB | 100 | pass |
| 0.36 MiB | 500 | pass |
| 0.71 MiB | 1,000 | pass |
| 1.07 MiB | 1,500 | fail: The document contains 1500 pages which exceeds the supported page limit of 1000. |
This is the cleanest result in the whole experiment.
A 1 MiB PDF failed because it had too many pages. Meanwhile, a 100 MiB padded PDF passed because most of the bytes were irrelevant to the parser.
So “file size” is clearly not the right user-facing abstraction.
Finding 4: Gemini Files API accepts large files, but that is not the same as generation success
Google recommends Gemini Files API for larger PDFs and reusable documents. I tested whether uploading to Files API first would make large PDFs work.
The AI Studio key worked for Files API. A 1 MiB PDF uploaded, became ACTIVE, and generated successfully with direct Gemini:
state=ACTIVE
uri=https://generativelanguage.googleapis.com/v1beta/files/...
direct PASS text="OPENROUTER_PDF_OK"
Then I tried larger dense-text pdf-lib PDFs:
| File | Files API upload | Generation result |
|---|---|---|
| 10 MiB / 450 pages | ACTIVE | fail: input token count exceeds max |
| 15 MiB / 675 pages | ACTIVE | fail: input token count exceeds max |
| 50 MiB / 2,250 pages | ACTIVE | fail: invalid argument |
The 50 MiB file is especially clarifying. The upload succeeded:
{
"mimeType": "application/pdf",
"sizeBytes": "52434249",
"state": "ACTIVE",
"source": "UPLOADED"
}
But generation failed.
So Gemini Files API’s 50 MB support is an admission/storage capability. It does not guarantee that the model can successfully use the uploaded PDF in a generation request. Page count, context, and rendering/tokenization still matter.
I also tried passing a Gemini Files API URI into OpenRouter. That failed with:
403 PERMISSION_DENIED
You do not have permission to access the File ... or it may not exist.
My interpretation: Files API URIs are scoped to the Google project/auth that uploaded them. OpenRouter’s upstream Google request cannot access a file uploaded with my local key unless OpenRouter is actually using that same upstream auth context.
Finding 5: providers fail differently
The whole point of a model router is that provider routes vary. PDF handling is no exception.
Anthropic
OpenRouter → Claude Sonnet 4.5 → Anthropic, using padded transport-control PDFs:
| Size | Result |
|---|---|
| 30 MiB | pass |
| 32 MiB | fail: The file exceeds the maximum allowed size. |
Anthropic exposed a clearer provider admission limit around 32 MiB in this route.
OpenAI
OpenRouter → GPT-5.4 Nano → OpenAI, using padded transport-control PDFs:
| Size | Result |
|---|---|
| 50 MiB | pass |
| 75 MiB | fail: File urls cannot be larger than 32MB. |
| 100 MiB | fail: File urls cannot be larger than 32MB. |
The 50 MiB pass plus 75/100 MiB “32MB” failures need follow-up with real PDF families. But they reinforce the broader lesson: provider-specific file paths have their own behavior, and the error messages are not always straightforward.
What this means for builders
If users upload PDFs into your app, do not expose one number and hope it maps to reality.
A better product model is:
upload → preflight → user-facing verdict
The preflight step should answer three practical questions:
- Can I send this file as one native PDF request?
- If not, what should I tell the user?
- Which failure should I prevent before the user waits for a doomed request?
Figure 3: a user-facing verdict chart
The key product move is to turn uncertainty into a verdict. The user does not need to understand parser limits or context windows; they need to know whether this file is likely to work, needs a compatibility check, or should be rejected before a doomed model call.
The upload statuses I would actually show
| Status | When to show it | Copy |
|---|---|---|
| Likely to work | small, normal PDF within safe route limits | “This PDF is likely to work with the selected model.” |
| Check required | near observed route boundary | “This PDF is near provider limits. We need to check it before continuing.” |
| Too many pages | exceeds hard page limit | “This PDF has too many pages for the selected model route.” |
| Too large / too complex | exceeds observed reliable zone | “This PDF is unlikely to work as one native PDF request.” |
| Cannot read | encrypted/corrupt/unparseable | “Upload an unlocked or re-exported copy.” |
| Upload only | Files API accepted it, but generation is risky | “The file uploaded, but that does not guarantee the model can use it.” |
What to inspect
At minimum, compute:
type PdfProfile = {
bytes: number;
pages: number;
encrypted: boolean;
hasText: boolean;
textChars: number;
estimatedTextTokens: number;
isProbablyScanned: boolean;
images?: {
count: number;
pagesWithLargeImages: number;
};
parseWarnings: string[];
};
Then compare that profile against the route you intend to use:
type PdfRouteProfile = {
routeId: string;
label: string;
hardLimits: {
maxBytes?: number;
maxPages?: number;
};
softLimits: {
directBytesSafe?: number;
directPagesSafe?: number;
timeoutRiskPages?: number;
};
};
From the current data, I would start Gemini Vertex native PDF conservatively:
const geminiVertexNativePdf = {
routeId: 'openrouter:google/gemini-3.1-pro-preview:google-vertex:native-pdf',
label: 'Gemini 3.1 Pro via Google Vertex',
hardLimits: {
maxPages: 1000,
maxBytes: 50 * 1024 * 1024,
},
softLimits: {
directBytesSafe: 10 * 1024 * 1024,
directPagesSafe: 450,
timeoutRiskPages: 550,
},
};
Those are not universal truths. They are operational guardrails for this route based on the observed corpus.
What to tell users
Do not say:
Max PDF size: 50 MB.
Say something closer to:
We check every PDF before processing. Small PDFs are read directly. Larger PDFs are split, indexed, or OCR’d depending on their structure. Some providers also enforce page-count limits.
Then show a concrete plan.
Ready
Ready for direct reading
4.2 MB · 38 pages
This PDF can be read directly by Gemini.
Large but processable
Large PDF
18.7 MB · 620 pages
This is too large for one reliable direct model call. We'll split it into sections and answer from the relevant parts.
Needs conversion
Needs OCR
12.1 MB · 90 scanned pages
Native model reading may be unreliable. We'll OCR the document first, then answer from extracted text.
Too large for selected route
Too many pages for Gemini native PDF
1.1 MB · 1,500 pages
The selected route supports up to 1,000 pages. This file is very likely to fail.
Compatibility check required
Near provider limits
13.4 MB · 608 pages
This PDF is near the known reliability boundary for Gemini native PDF reading. It may fail or time out.
So what files can I send?
For the route I tested most carefully — OpenRouter → Gemini 3.1 Pro → Google Vertex → native PDF — I would summarize the current evidence like this:
| File shape | Send as one native PDF request? | Why |
|---|---|---|
| ≤10 MiB and ≤450 normal/dense text pages | Yes, likely | Passed in this corpus with margin. |
| 11–13 MiB and 500–600 dense text pages | Maybe | Some passed, but this is near the noisy boundary. |
| 14–15 MiB and 650–675 dense text pages | Risky / likely no | Timeouts and parser failures appeared here. |
| 50 MiB dense text PDF | No | Files API upload can succeed, but generation failed; OpenRouter native route failed too. |
| ≤1,000 sparse pages | Yes, page-count-wise | Sparse 1,000-page PDF passed. |
| >1,000 pages | No for this route | Explicit provider error: supported page limit of 1,000. |
Padded bytes after %%EOF | Not representative | 100 MiB passed, but only as a transport probe. |
| Anthropic native PDF around 32 MiB | No in this route | Provider rejected with file-size error. |
That table is the most practical output of the experiment. It is intentionally route-specific. Change the provider route, and you should assume the table changes.
How do I know if a PDF will fail?
You cannot know from file size alone. But you can catch most doomed cases before sending the model request.
Check these fields before calling OpenRouter:
| Field | Why it matters | User-visible consequence |
|---|---|---|
| bytes | Some routes reject large file objects or URLs. | “This file is too large for the selected route.” |
| page count | Gemini/Vertex showed an explicit 1,000-page gate. | “This PDF has too many pages.” |
| text density | Dense PDFs hit parser/context/timeout boundaries earlier. | “This PDF is near the reliability boundary.” |
| scanned/image-heavy pages | Byte size may understate visual processing cost. | “This PDF needs extra checking.” |
| encryption/corruption | The route may not parse it at all. | “Upload an unlocked or re-exported copy.” |
| provider route | Anthropic, OpenAI, Google Vertex, and Google AI Studio differ. | “This file may work with one provider and fail with another.” |
For users, synthesize all of that into a small number of verdicts:
| Verdict | Meaning |
|---|---|
| Likely to work | Within the route’s observed safe zone. |
| Needs compatibility check | Near the observed boundary; may timeout or fail. |
| Too many pages | Exceeds an explicit page cap. |
| Too large or complex | Past the route’s observed reliable zone. |
| Cannot read this PDF | Encrypted, corrupt, or metadata cannot be parsed. |
How do I prevent failures?
Prevent the failures you can classify cheaply:
- Reject obvious hard-limit violations before model calls. For Gemini/Vertex native PDF, do not send a >1,000-page PDF as one file.
- Treat advertised upload limits as admission limits. Gemini Files API accepting a 50 MiB PDF does not mean generation will work.
- Keep a per-route safe zone. For Gemini/Vertex native PDF, this experiment suggests “likely to work” should start around ≤10 MiB and ≤450 dense pages, not 50 MiB.
- Show uncertainty explicitly near the boundary. A 13–15 MiB dense PDF is not a clean yes/no; call it “needs compatibility check.”
- Log failures by layer. “PDF failed” is useless. “page_count_limit,” “provider_file_size_limit,” “parser_failure,” and “context_limit” tell you how to improve your user-facing verdicts.
What changed my mind
Before running the experiments, I expected to find a rough OpenRouter-side file-size threshold. I now think that framing is too coarse.
The decisive observations were:
- 100 MiB passed when the extra bytes were after
%%EOF. - 1.07 MiB failed when the file had 1,500 pages.
- 50 MiB uploaded successfully to Gemini Files API, then failed at generation time.
- 15 MiB failed for a normal dense-text PDF even though the same route transported much larger objects.
Those four facts cannot be explained by one file-size limit. They require a pipeline model.
Downloadable artifacts
The generated PDFs are public so readers can rerun or falsify the tests.
Public prefix:
https://pub-e68ba3382809416cb3ae5ad57c5ff6e4.r2.dev/openrouter-file-limits
Useful standards-compliant dense-text artifacts:
| Artifact | Size | Pages |
|---|---|---|
openrouter-pdflib-pdf-limit-1mib.pdf | ~1 MiB | 50 |
openrouter-pdflib-pdf-limit-10mib.pdf | ~10 MiB | 450 |
openrouter-pdflib-pdf-limit-13mib.pdf | ~13 MiB | 600 |
openrouter-pdflib-pdf-limit-15mib.pdf | ~15 MiB | 675 |
openrouter-pdflib-pdf-limit-50mib.pdf | ~50 MiB | 2,250 |
Sparse-page artifacts:
| Artifact | Size | Pages |
|---|---|---|
openrouter-sparse-pages-100pages.pdf | ~0.07 MiB | 100 |
openrouter-sparse-pages-500pages.pdf | ~0.36 MiB | 500 |
openrouter-sparse-pages-1000pages.pdf | ~0.71 MiB | 1,000 |
openrouter-sparse-pages-1500pages.pdf | ~1.07 MiB | 1,500 |
Conclusion
A model router can normalize request shape, routing, and billing. It cannot make every upstream provider’s document ingestion pipeline behave the same way.
For PDFs, the meaningful limit is not “MB.” It is the first failing layer among transport, file admission, parsing, page count, rendering/tokenization, model context, and generation.
So if you are building with PDF uploads, the action item is not to find one magic maximum. The action item is to build a preflight system that turns a messy PDF into a concrete processing plan.