Developers who send a PDF to an LLM through Anthropic’s Messages API get billed for each page two times. The service pulls the text off the page and also renders the page as a picture, then feeds the model both versions. Every request carrying that file incurs both charges.
The shortcut is tempting because it removes parsing code, OCR steps and mangled tables. Encode the file, attach a question, and charts get read along with the prose. The catch appears later, on the invoice or when a 300-page contract hits a size limit.
What the API does with a PDF
Anthropic’s PDF documentation describes the process: each page is rasterized, its text is extracted separately, and the model receives the pair. That pairing lets it answer questions about a bar chart that carries no text at all. The price splits accordingly.
- Text layer: a dense page runs about 1,500 to 3,000 tokens, a sparse one less.
- Page image: no more than 1,568 visual tokens, since renders are fitted to the standard resolution tier.
Consider a 40-page report that is mostly prose. With roughly 2,000 text tokens and up to 1,568 image tokens on each page, one call uses around 140,000 input tokens. Sending only the extracted text brings that to about 80,000. For a question like a revenue summary, the images added nothing.
Page count is a second limit. One request allows 600 pages, or 100 when the context window is below 1M tokens, and crowded pages can exhaust the window sooner. Plan on splitting big files, and don’t treat that as an edge case: any team working with long contracts or reports will hit it.
Count tokens before you guess
Skip guesses based on page numbers. Anthropic offers a free token counting endpoint that takes the same content blocks as a normal message request, and it handles base64 PDFs but not URL or file sources. Run it once on the PDF and once on plain extracted text. The gap is the price of the images for your own files.
Use the model you plan to call. Claude Opus 4.7 and later use a newer tokenizer that yields about 30 percent more tokens for identical text, so numbers from an older model come out too low.
Route by what the question needs
Nobody needs to ban PDFs. The decision is made per file and per question: does the picture of the page matter?
- Prose-heavy files such as contracts and policies: pull the text yourself and send it as a text block, which is cheaper and easier to chunk or cache.
- Scans, charts and forms, where layout carries meaning: send the PDF.
- Mixed files: send text for most pages and ship only the figure pages as PDF or images.
A basic router can test for a usable text layer. One rule of thumb treats fewer than about 200 characters per page on average as a probable scan. Adjust that cutoff against your own documents, and override it whenever the question concerns a chart.
Standalone images follow the same logic
Claude prices images by 28 by 28 pixel patches: the width divided by 28 and rounded up, multiplied by the height divided by 28 and rounded up. Claude 4.7 and later offer a high-resolution tier of up to 2,576 pixels on the long edge and 4,784 tokens, about triple the standard tier.
An unresized 4K screenshot is scaled down and still costs the full 4,784 tokens. Shrink it first if the detail isn’t needed. Go easy on compression, because heavy JPEG artifacts can blur small text and turn savings into a wrong answer.
What to do before you ship
Treat image input as an option, not the default. It earns its cost on scans, charts and forms and is wasted on a contract that works as plain text. Measure a few real files, route by the question, and cache any document you query repeatedly.
Limits change often. Check the current PDF and vision documentation before you hard-code any numbers.
Source: Dan Holloran