PDF support
Process PDFs with Claude: extract text, analyze charts, and understand visual content from your documents.
You can ask Claude about any text, pictures, charts, and tables in PDFs you provide. Some sample use cases:
- Analyzing financial reports and understanding charts/tables
- Extracting key information from legal documents
- Helping with document translation
- Converting document information into structured formats
Before you start
Check PDF requirements
Claude works with any standard PDF. Ensure your request size meets these requirements:
| Requirement | Limit |
|---|---|
| Maximum request size | 128 MB on the first-party Claude API (varies by platform; see request size limits) |
| Maximum pages per request | 600 (100 when the request’s context window is under 1M tokens) |
| Format | Standard PDF (no passwords/encryption) |
Both limits are on the entire request payload, including any other content sent alongside PDFs. For large PDFs, consider uploading with the Files API and referencing by file_id to keep request payloads small.
Because PDF support relies on Claude’s vision capabilities, it is subject to the same limitations and considerations as other vision tasks.
Supported platforms and models
All active models support PDF processing.
Process PDFs with Claude
Send your first PDF request
Start with an example that uses the Messages API. To give Claude a PDF, send it in a document content blockPreview with links to the API reference available — press Tab until focus enters the card, Escape to return. with one of three kinds of source. Your platform determines which kinds you can use (see Availability). Among those kinds, choose by where the PDF is, how large it is, and how often you use it:
- A PDF hosted online: Reference it by its URL (Option 1: URL-based PDF document).
- A PDF on your local system or without a URL: Send it as base64-encoded data (Option 2: Base64-encoded PDF document).
- A large PDF or one that you’ll use repeatedly: Upload it with the Files API and reference it by its
file_id(Option 3: Files API).
Option 1: URL-based PDF document
Reference the PDF by its URL:
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "url",
"url": "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf",
},
},
{"type": "text", "text": "What are the key findings in this document?"},
],
}
],
)
print(message.content)The response returns Claude’s analysis as text blocks in content, with token consumption in usage:
{
"id": "msg_01Hfp8YuFjQ55VgWbpdHDehB",
"type": "message",
"role": "assistant",
"model": "claude-opus-5-5",
"content": [
{
"type": "text",
"text": "This document is an addendum to the Claude 3 model card, reporting updated evaluation results. The key findings include..."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 45000,
"output_tokens": 300
}
}Option 2: Base64-encoded PDF document
Send the PDF as base64-encoded data in the request itself. Most of the following examples download a sample PDF and encode it, so they need no local file. To send a local file in those examples, replace the lines that download and encode the PDF with the commented-out lines:
import base64
import httpx2
# First, load and encode the PDF
pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
pdf_data = base64.standard_b64encode(
httpx2.get(pdf_url, follow_redirects=True).content
).decode("utf-8")
# Alternative: Load from a local file
# with open("document.pdf", "rb") as f:
# pdf_data = base64.standard_b64encode(f.read()).decode("utf-8")
# Send to Claude using base64 encoding
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{"type": "text", "text": "What are the key findings in this document?"},
],
}
],
)
print(message.content)Option 3: Files API
For PDFs you’ll use repeatedly, or when you want to avoid encoding overhead, use the Files API:
client = anthropic.Anthropic()
# Upload the PDF file
with open("/path/to/document.pdf", "rb") as f:
file_upload = client.files.upload(file=("document.pdf", f, "application/pdf"))
# Use the uploaded file in a message
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "document",
"source": {"type": "file", "file_id": file_upload.id},
},
{"type": "text", "text": "What are the key findings in this document?"},
],
}
],
)
print(message.content)How PDF support works
When you send a PDF to Claude, the following steps occur:
The system extracts the contents of the document.
- The system converts each page of the document into an image.
- The system extracts the text from each page and provides it alongside that page’s image.
Claude analyzes both the text and images.
- Claude receives each document as a combination of text and images.
- Because Claude receives an image of each page, you can ask for insights on visual elements of a PDF, such as charts, diagrams, and other non-textual content.
Claude uses the PDF’s contents in its response if relevant.
Claude can draw on both textual and visual content in its response.
Estimate your costs
The token count of a PDF file depends on the total text extracted from the document and the number of pages:
- Text token costs: Each page typically uses 1,500–3,000 tokens depending on content density. Standard API pricing applies with no additional PDF fees.
- Image token costs: Each page’s image uses at most 1,568 visual tokens on every model because the API fits page images within the Standard resolution tier’s limits. For how to count an image’s visual tokens, see Resolution and token cost.
You can use token counting to estimate costs for your specific PDFs.
Optimize PDF processing
You can combine PDF support with other features:
- Use prompt caching to improve performance for repeated analysis.
- Process document batches to handle documents at high volume.
- Use tools to have Claude extract specific information from documents for use as tool inputs.
Improve performance
Follow these best practices for optimal results:
- Place PDFs before text in your requests
- Use standard fonts
- Ensure text is clear and legible
- Rotate pages to proper upright orientation
- Use logical page numbers (from PDF viewer) in prompts
- Split large PDFs into chunks when needed
- Enable prompt caching for repeated analysis
Scale your implementation
For high-volume processing, consider these approaches:
Use prompt caching
Cache PDFs with prompt caching to improve performance on repeated queries:
import base64
import httpx2
# First, load and encode the PDF
pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
pdf_data = base64.standard_b64encode(
httpx2.get(pdf_url, follow_redirects=True).content
).decode("utf-8")
# Create a message with the cached document
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
"cache_control": {"type": "ephemeral"},
},
{
"type": "text",
"text": "Which model has the highest human preference win rates across each use-case?",
},
],
}
],
)
print(message.content)Process document batches
Use the Message Batches API to process many PDFs in one request:
import base64
import httpx2
# First, load and encode the PDF
pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
pdf_data = base64.standard_b64encode(
httpx2.get(pdf_url, follow_redirects=True).content
).decode("utf-8")
# Create a batch of requests that use the document
client = anthropic.Anthropic()
message_batch = client.messages.batches.create(
requests=[
{
"custom_id": "my-first-request",
"params": {
"model": "claude-opus-5-5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{
"type": "text",
"text": "Which model has the highest human preference win rates across each use-case?",
},
],
}
],
},
},
{
"custom_id": "my-second-request",
"params": {
"model": "claude-opus-5-5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{
"type": "text",
"text": "Extract 5 key insights from this document.",
},
],
}
],
},
},
]
)
print(message_batch)Batches process asynchronously. To check progress and retrieve results once processing ends, see Batch processing.
Next steps
Learn how to count an image’s visual tokens and which limitations PDFs share with other vision tasks.
Explore practical examples of PDF processing in the Claude Cookbook recipe.
See complete API documentation for PDF support.
Availability
Claude API
- APIs
- Messages API
- Managed Agents
- Models
- All models
Amazon Bedrock
- API
- Messages API
- Models
- All models
- Note
Base64 sources only.
Amazon Bedrock (bedrock-runtime)
- API
- Messages API
- Models
- All models
- Note
Base64 sources only.
Claude Platform on AWS
- APIs
- Messages API
- Managed Agents
- Models
- All models
Claude Models on Google Cloud (Anthropic managed)
- APIs
- Messages API
- Managed Agents
- Models
- All models
Claude Models on Google Cloud (Google managed)
- API
- Messages API
- Models
- All models
- Note
Base64 sources only.
Microsoft Foundry
- API
- Messages API
- Models
- All models
- Note
file_idsources need a Hosted on Anthropic deployment.
Data handling
Data handling overviewApplicable endpoints
/v1/messages
Excludes Covered Models
HIPAA eligibility applies to PDFs sent inline through the Messages API, not through the Files API.
Was this page helpful?