← Blog

Anthropic PDF Inputs Need a Page-Count Gate

Parminder Singh
Parminder Singh··5 min read
Summarize with AI

Anthropic currently accepts up to 600 PDF pages per request on a 1M-token context window and up to 100 pages when the request context window is smaller. Those limits cover all PDFs in the request, and dense content can exhaust context earlier. A gateway should count pages before Messages dispatch, resolve the model window, enforce a lower route budget where needed, and record split-document lineage.

AI Security Solutionsai-securityllm-securitypolicy-enforcementzero-trustarchitectureaudit
Anthropic PDF Inputs Need a Page-Count Gate

Anthropic's PDF limits apply to the entire request. Current documentation permits up to 600 pages when the request uses a 1M-token context window and 100 pages when the context window is smaller. A 120-page PDF can therefore pass one model route and fail another before Claude reads a word.

I want page counting at the HTTP boundary, tied to the resolved model and all document blocks. File size alone cannot predict page count or context cost.

TL;DR

  • Count pages across every PDF in the final request, rather than checking each attachment separately.
  • Resolve the destination model's context window before applying Anthropic's 600-page or 100-page ceiling.
  • Enforce route budgets below the provider maximum for dense or sensitive workloads and workloads with tight latency bounds.
  • Record document digest and page range, split lineage, resolved model and total pages, plus the exact admission decision.

The limit follows the request and model window

Anthropic's PDF support documentation sets a 600-page maximum per request, reduced to 100 when the request's context window is under 1M tokens. The guide also links to the official API request-size limits, which list a 128 MB maximum on the first-party Claude API and explain that other platforms vary.

These are aggregate constraints. Three 40-page PDFs produce a 120-page request. Each file looks valid by itself, yet the combined request exceeds the page limit for a model with less than a 1M-token window.

Resolve model aliases before counting against a window class. A route that accepts a caller-supplied model name without canonical resolution can apply the wrong ceiling. Preserve the resolved model and capability snapshot in the policy record.

The Anthropic API gateway pattern places that resolution beside authenticated identity and provider dispatch.

Page count is only the first admission gate

Anthropic notes that dense PDFs can fill context before the page maximum. Small fonts and complex tables increase processing demand, as do heavy graphics, because each page is processed as an image. Files API references reduce request payload size, but they do not erase page count or context consumption.

Set a route page budget below the provider ceiling where the workload needs predictable latency or has a narrow question. A policy-review route might permit 80 pages. An archival analysis route on an approved 1M-token model could allow more after a cost and quality test. Keep total request bytes and page count separate from estimated context.

My opinion is that 600 pages is a protocol ceiling, not a sensible default workload. Sending an entire closing binder to answer one clause question is weak data minimization.

Use per-route AI policies to name the lower operational cap, approved model class, source system, and exception owner.

The preflight parser must fail safely

Count pages using a parser that reads the PDF cross-reference structure and handles malformed files under strict resource limits. Reject encrypted or password-protected PDFs because Anthropic's documented format requirement is a standard PDF without passwords or encryption. Detect recursive objects and decompression bombs, and enforce parser timeouts before the request reaches the main worker pool.

Compare the declared application/pdf type with the file signature. For base64 sources, count decoded bytes and pages. For URL sources, the gateway can validate the URL reference but cannot count remote bytes that Anthropic fetches unless the application retrieves the file first. A route requiring deterministic page admission should prefetch into a controlled scanner or require an approved Files API upload with stored metadata.

For file_id, bind provider reference to upload-time page count and digest, plus tenant and MIME type. Reusing a file ID should reuse verified metadata only when the content is immutable under that identifier.

Splitting preserves lineage and loses context

Anthropic recommends splitting large PDFs into sections when size or density causes failures. A split workflow needs more than files named part-1.pdf and part-2.pdf. Record the original document digest and source page range, chunk digest and extraction tool version, plus overlap policy and ordering.

Preserve page labels and printed pagination where possible. PDF page index 17 may display page "xii" or "3-4" on the sheet. Citations and reviewer checks need both the source index and visible label.

A physical detail matters here: place a small footer on each synthetic test page with the original digest prefix and source page number. When a chunk is reordered or duplicated, the error becomes visible in the rendered page and the machine record.

A model call over each chunk creates separate HTTP decisions. The application owns cross-chunk synthesis and completeness checks. Automatic recursive summarization can lose qualifications that appear in another section, so keep the original artifact available to authorized reviewers.

Evidence needs page and chunk fields

Before dispatch, record authenticated principal and route, resolved model and context-window class, source type and document count, aggregate pages and total bytes, encryption state and parser version, plus policy cap and outcome. For split documents, add parent digest and chunk ordinal, plus source page range and overlap.

Use digests and protected artifact references in the general audit event. Full PDFs can contain contracts, medical records, source code, or financial statements. Storing their bytes in every gateway log duplicates exposure and complicates deletion.

The AI audit log schema supplies common identity and route fields, policy and timestamp data, plus provider fields. Prompt injection protection covers untrusted instructions inside the accepted PDF. Page admission cannot establish document trust.

Fixtures should combine files and model changes

Create synthetic PDFs with 99 and 100 pages, plus one with 101 pages. Send them to a route whose resolved model has less than a 1M-token context window. The first two should pass the page-count gate if they satisfy the route's lower cap; 101 should stop before provider dispatch.

For a controlled 1M-token route, test 599 and 600 pages, then 601 pages. Add three 40-page documents to prove the validator aggregates across blocks. Then keep the pages fixed while increasing embedded image size and table density to exercise request-byte and context safeguards separately.

Include an encrypted PDF and a malformed cross-reference table. Add a base64 payload with the wrong MIME label, a URL whose metadata lacks page count, and a file ID owned by another synthetic tenant. Split a 120-page fixture into three chunks. Reorder two, duplicate one overlap page, and confirm the lineage validator catches each mutation.

DeepInspect

DeepInspect can enforce aggregate PDF page count and request size, plus source policy and resolved-model window rules, on authenticated user or agent HTTP requests deliberately routed through its proxy to Anthropic. It can reject oversized or malformed inline documents before provider dispatch and record page, model, and lineage metadata for each decision.

The application owns controlled URL prefetch and upload-time parsing, plus chunk creation and cross-chunk completeness. Anthropic processes accepted documents after receipt. Files and calls that bypass the proxy remain outside DeepInspect's evidence path.

Book a technical deep dive at deepinspect.ai.

Frequently asked questions

What is Anthropic's PDF page limit?

The current PDF guide states 600 pages per request for a 1M-token context window and 100 pages when the request context window is smaller. Route policy can set a lower budget.

Does the limit apply to each PDF separately?

No. Anthropic says page and request-size limits cover the entire request payload, including other PDFs and content sent alongside them. Aggregate every document block.

Does the Files API bypass page limits?

No. A file reference can keep the JSON request smaller, but the referenced PDF still consumes pages and model context. Store verified page metadata beside the file ID.

Can the gateway count pages for an arbitrary URL PDF?

Only after fetching and parsing it. If Anthropic fetches the URL after dispatch, the gateway sees the reference rather than the remote bytes. Deterministic admission requires controlled prefetch or trusted upload metadata.