← Blog

Claude API PDF Parsing and Extraction Tool Guide

2026-11-10 · 5 min read · SubToAPI Team

What "Claude API PDF parsing" actually means

If you're searching for a Claude API PDF parsing and extraction tool, you're probably trying to pull structured data — line items, dates, names, totals, clauses — out of invoices, contracts, resumes, or research papers without building a separate OCR pipeline. The good news: Claude's Messages API accepts PDFs directly as a content type. You don't need to convert pages to images yourself or run Tesseract first. Claude reads the text layer when one exists, and falls back to its vision capabilities for scanned pages, charts, and tables rendered as images.

This matters because most "PDF extraction" problems aren't really parsing problems — they're reasoning problems. A PDF invoice might have a table that spans two pages, a total that's computed rather than stated, or a signature block formatted inconsistently across vendors. A model that understands layout and context handles those cases far better than regex-based text extraction.

How PDF extraction works in the Claude API

You send a PDF as a document content block inside a normal Messages API request. The model processes both the text and the visual layout of each page, which is why it handles tables and multi-column layouts better than plain text extraction.

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, due date, and total amount."
        }
      ]
    }]
  }'

Key things to know:

Forcing structured output with tool use

Asking Claude to "extract the key fields" in plain English works, but for a production extraction tool you want a predictable schema every time. The reliable way to do this is tool use (function calling): define a tool with the exact JSON shape you need, and Claude returns a tool call instead of free text.

{
  "name": "extract_invoice_fields",
  "description": "Extract structured fields from an invoice PDF",
  "input_schema": {
    "type": "object",
    "properties": {
      "invoice_number": { "type": "string" },
      "due_date": { "type": "string" },
      "total_amount": { "type": "number" },
      "line_items": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "description": { "type": "string" },
            "amount": { "type": "number" }
          }
        }
      }
    },
    "required": ["invoice_number", "total_amount"]
  }
}

Attach the PDF document block alongside this tool definition and set tool_choice to force the model to call it. You'll get back a parsed JSON object instead of a paragraph you have to regex yourself — this is the core of any reliable Claude API PDF parsing and extraction tool.

Common use cases worth building around

In all of these, the pattern is the same: send the PDF as a document block, pair it with a tool schema, and validate the returned JSON before writing it to your database.

Scaling PDF extraction beyond a prototype

A single curl call is easy to get working. Running this reliably in production — with retries, streaming for long documents, per-team usage visibility, and API keys you can rotate without touching your Anthropic account — is a different problem.

This is where SubToAPI fits. It turns your existing Claude access into a standard HTTPS API with application-level keys (sub_live_...), so you can issue a separate key per service or environment that's doing PDF extraction, see exactly how many tokens each one burns, and revoke a key instantly if something misbehaves — without rotating your main Anthropic credentials.

const res = await fetch("https://api.subtoapi.app/v1/messages", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "claude-sonnet-4-5",
    max_tokens: 1024,
    messages: [{
      role: "user",
      content: [
        { type: "document", source: { type: "base64", media_type: "application/pdf", data: pdfBase64 } },
        { type: "text", text: "Extract the fields defined by the extract_invoice_fields tool." },
      ],
    }],
    tools: [ /* your extraction tool schema */ ],
  }),
});

Streaming (see /docs/streaming) is useful for long-document summarization where you want tokens as they're generated rather than waiting for a full response, and tool use (/docs/tools) is what makes extraction output predictable enough to insert directly into a database. Full request shapes are in /docs/messages, and /docs/quickstart covers getting your first key. Plans start with a free trial at /signup and scale by seat — see /pricing.

Limitations to plan for

PDF extraction via Claude isn't magic. Heavily handwritten documents, very low-resolution scans, and PDFs with unusual encodings can reduce accuracy. Always validate extracted fields (amount formats, date formats) before trusting them downstream, and consider a confidence check — e.g., asking the model to flag fields it wasn't sure about — for anything feeding financial or legal systems.

questions

Does Claude need OCR software before reading a PDF? No. The Messages API accepts PDFs as a native document content block. Claude reads the text layer directly and uses vision for scanned pages or embedded images — no separate OCR step is required.

Can I get structured JSON back instead of a text summary? Yes, by defining a tool with an input_schema and forcing tool_choice. Claude returns a tool call matching your schema instead of prose, which is the reliable way to build an extraction pipeline.

What's the best way to run this in production with usage tracking? Wrap your Claude access with an API layer that issues separate keys per service and reports token usage per key. SubToAPI does this out of the box — see /docs/quickstart to set it up.

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 →