← Blog

Claude API PDF Document Parsing Tool: Setup Guide

2026-11-13 · 4 min read · SubToAPI Team

If you're looking for a Claude API PDF document parsing tool, the short answer is: Claude's native multimodal document support. Claude models (Opus, Sonnet, Haiku on recent versions) accept PDFs directly as part of a message's content array, alongside text and images. You don't need a separate OCR pipeline or PDF-to-text library in most cases — you send the raw PDF bytes (or a URL to the file), and Claude reads the pages, including layout, tables, and embedded images, as part of its reasoning.

This matters because PDF parsing has historically been painful: regex extraction breaks on multi-column layouts, OCR tools mangle tables, and PDF libraries choke on scanned documents. Claude's document understanding treats the PDF like a human reader would — it sees page structure, not just extracted text strings. Below is a practical walkthrough of how to send PDFs to the Claude API, structure extraction prompts, and handle common failure modes like oversized files and multi-page documents.

How PDF input works in the Claude API

Claude's Messages API supports a document content block type. Instead of pre-extracting text yourself, you base64-encode the PDF and attach it to a user message:

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-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [{
      "role": "user",
      "content": [
        {
          "type": "document",
          "source": {
            "type": "base64",
            "media_type": "application/pdf",
            "data": "<base64-encoded-pdf>"
          }
        },
        {
          "type": "text",
          "text": "Extract the invoice number, total amount, and due date as JSON."
        }
      ]
    }]
  }'

Claude processes each page as both text and a rendered image internally, which is why it handles scanned PDFs, tables, charts, and handwriting reasonably well — far better than text-only extraction.

Writing extraction prompts that actually work

The quality of your parsed output depends heavily on prompt structure. A few patterns that consistently improve results:

Example prompt for a multi-page contract:

Extract the following fields from this contract as JSON:
- parties (array of company names)
- effective_date (ISO 8601)
- termination_clause (verbatim text, or null if absent)
- governing_law (jurisdiction name)

Return only valid JSON, no explanation.

Handling large or multi-page PDFs

PDF input is subject to size and page limits that vary by model version, so for large documents:

Batching PDF parsing across many files

If you're building a pipeline that parses invoices, resumes, or contracts in bulk, structure each PDF as an independent request rather than concatenating multiple documents into one call. This keeps token usage predictable per document and makes retries cheap when one file fails extraction (corrupted PDF, password-protected file, scanned image with poor resolution).

A typical pipeline looks like:

  1. Fetch PDF from storage (S3, GCS, local disk).
  2. Base64-encode and attach as a document block.
  3. Send with a fixed extraction schema prompt.
  4. Validate the JSON response against your schema.
  5. Retry with a clarifying prompt if validation fails.

Where SubToAPI fits in

If you're already parsing PDFs through Claude and want to turn that workflow into a production API without managing Anthropic billing, rate limits, and key rotation yourself, SubToAPI lets you issue scoped sub_live_... keys for each service or team member, with usage metadata per request so you can track exactly which key is processing how many documents and tokens. Document parsing calls work the same way as any other Messages request — see /docs/messages for the request format and /docs/quickstart to get a key running in minutes. If your pipeline streams partial extraction results for large documents, check /docs/streaming.

Common pitfalls

FAQ

Does the Claude API require a separate OCR step before parsing PDFs? No. Claude accepts PDFs natively as document content blocks and handles scanned pages, tables, and layout internally without a separate OCR tool in most workflows.

What's the best way to get consistent structured data from PDF parsing? Request a fixed JSON schema in your prompt, specify how to handle missing fields, and validate the response programmatically — don't rely on free-text extraction.

Can SubToAPI be used for PDF parsing workflows? Yes. Any Claude Messages API call, including document/PDF content blocks, works the same through SubToAPI's sub_live_... keys — see /docs/messages and /pricing for plan details.

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 →