← Blog

Claude API PDF Document Processing Guide

2026-10-18 · 6 min read · SubToAPI Team

Claude's API can read PDFs natively — you don't need a separate OCR pipeline or a PDF-to-text library before sending a document to the model. Claude processes both the text and the visual layout of each page, which means it can answer questions about tables, charts, scanned forms, and multi-column layouts, not just plain text extraction.

This matters because most "PDF processing" problems aren't really about getting text out of a file — they're about getting the right text out, in the right structure, including numbers in tables, labels next to checkboxes, or figures inside charts. This guide covers how PDF input works with the Claude API, how to send documents correctly, and what to watch out for when you move from a prototype to a production pipeline.

How Claude Handles PDF Input

When you send a PDF to Claude, the model receives it as a document content block alongside your text prompt. Internally, Claude processes each page both as text and as an image, which is why it can reason about visual structure — a table's column headers, a form's layout, a chart's axis labels — rather than just a flat stream of extracted characters.

This is different from traditional PDF parsing, where you extract raw text and then hope the layout information wasn't lost. With Claude, you send the file once and ask your question directly: "What was the total revenue in Q3?" or "List every line item in this invoice as JSON."

Sending a PDF to the API

PDFs are sent as base64-encoded data inside a message, using the same messages endpoint you'd use for text or image prompts. Here's a minimal example:

curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-3-5-sonnet-20241022",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "base64",
              "media_type": "application/pdf",
              "data": "BASE64_ENCODED_PDF"
            }
          },
          {
            "type": "text",
            "text": "Extract every line item from this invoice as a JSON array with description, quantity, and price."
          }
        ]
      }
    ]
  }'

In JavaScript, the base64 encoding step looks like this:

import fs from "fs";

const pdfData = fs.readFileSync("./invoice.pdf").toString("base64");

const response = await fetch("https://api.anthropic.com/v1/messages", {
  method: "POST",
  headers: {
    "x-api-key": process.env.ANTHROPIC_API_KEY,
    "anthropic-version": "2023-06-01",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    model: "claude-3-5-sonnet-20241022",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          { type: "document", source: { type: "base64", media_type: "application/pdf", data: pdfData } },
          { type: "text", text: "Summarize the key findings in this report in bullet points." },
        ],
      },
    ],
  }),
});

What You Can Extract From PDFs

Because Claude reads both text and layout, PDF processing with the API goes well beyond simple text dumps:

If you need the output in a predictable shape for downstream systems, pair your extraction prompt with a clear JSON schema description and ask Claude to return only the JSON object, with no surrounding commentary.

Multi-Page and Large Document Considerations

PDFs consume tokens based on their content — more pages and denser text mean more input tokens. A few practical guidelines:

Common Use Cases

PDF processing with the Claude API shows up in a lot of production systems:

Using SubToAPI for PDF Document Pipelines

If you're building a product on top of Claude's document capabilities, you still need standard API infrastructure: application-scoped keys, usage metadata per request, streaming for long extraction jobs, and team access control — none of which Claude's raw API gives you by itself.

SubToAPI turns your existing Claude access into an HTTPS API with sub_live_... keys you can issue per application or per customer, so a PDF-processing feature in your product doesn't need to share a single Anthropic key across every environment. Requests to document endpoints work the same way as any other Claude call — see the messages docs for the request format and streaming docs if you're extracting from long documents and want partial results as they're generated. Usage and cost per key are visible in the dashboard, which is useful when you're billing PDF processing as a feature to different teams or customers.

Setup takes a few minutes — check the quickstart, compare plans, or start a free trial if you want to try it against a real document pipeline.

Best Practices for PDF Document Processing

FAQ

Does Claude need a text layer in the PDF, or can it read scanned documents? Claude reads PDFs as both text and images, so scanned or image-only PDFs work without a separate OCR step. Very low-resolution scans may reduce accuracy on small text.

What's the best way to get structured JSON out of a PDF with Claude? Describe the exact JSON schema you want in your prompt and instruct Claude to return only the JSON object. Pairing this with the tools/function-calling feature gives even more reliable structured output.

Can I send multiple PDFs in one request? Yes — you can include multiple document content blocks in a single message, which is useful for comparing contract versions or cross-referencing data across related files.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →