← Back to daily report

build-with-claude/pdf-support.md

Changed on 2026-11-18 13:42:16 EST

+43 lines added
-37 lines removed
Visual Diff
---¶
title: PDF support¶
url: https://platform.claude.com/docs/en/build-with-claude/pdf-support¶
description: "Process PDFs with Claude: extract text, analyze charts, and understand visual content from your documents."¶
featureMetadata:¶
status: stable¶
zdr:¶
eligibility: eligible¶
note: Excludes [Covered Models](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#model-specific-data-retention-requirements).¶
supportedModels:¶
- claude-fable-5-2¶
- claude-mythos-5-2¶
- claude-fable-5-1¶
- claude-mythos-5-1¶
- claude-fable-5¶
- claude-mythos-5¶
- claude-mythos-preview¶
- claude-opus-5-5¶
- claude-opus-5¶
- claude-sonnet-5-5¶
- claude-sonnet-5¶
- claude-haiku-5-5¶
- claude-haiku-4-5-20251001¶
- claude-opus-4-8¶
- claude-opus-4-7¶
- claude-opus-4-6¶
- claude-sonnet-4-6¶
- claude-opus-4-5-20251101¶
- claude-sonnet-4-5-20250929¶
supportedPlatforms:¶
Claude API: stable¶
Amazon Bedrock:¶
availability: stable¶
note: Base64 sources only.¶
Amazon Bedrock (bedrock-runtime):¶
availability: stable¶
note: Base64 sources only.¶
Claude Platform on AWS: stable¶
Claude Models on Google Cloud (Anthropic managed): stable¶
Claude Models on Google Cloud (Google managed):¶
availability: stable¶
note: Base64 sources only.¶
Microsoft Foundry:¶
availability: stable¶
note: "`file_id` sources need a Hosted on Anthropic deployment."¶
---¶

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](https://platform.claude.com/docs/en/api/overview#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](https://platform.claude.com/docs/en/build-with-claude/files) and referencing by `file_id` to keep request payloads small.¶

<Tip>¶
Dense PDFs (many small-font pages, complex tables, or heavy graphics) can fill the context window before reaching the page limit. Requests with large PDFs can also fail before reaching the page limit, even when using the Files API. Try splitting the document into sections; for large files, because each page is processed as an image, downsampling embedded images can also help.¶
</Tip>¶

Because PDF support relies on Claude’s vision capabilities, it is subject to the same [limitations and considerations](https://platform.claude.com/docs/en/build-with-claude/vision#limitations) as other vision tasks.¶

### Supported platforms and models¶

All [active models](https://platform.claude.com/docs/en/models/overview) support PDF processing.¶

<Note>¶
Plain text files such as .txt, .csv, or .md can be used directly in document blocks: upload them to the Files API with MIME type `text/plain` and reference them by `file_id`. Binary formats such as .xlsx or .docx are not supported in document blocks, so convert them to text or PDF first. See [Working with other file formats](https://platform.claude.com/docs/en/build-with-claude/files#working-with-other-file-formats).¶
</Note>¶

## Process PDFs with Claude¶

### Send your first PDF request¶

Start with a
simplen example usingthat uses the Messages API. You can proviTo give Claude a PDFs to Claude in three ways:¶

1. As a URL reference to a PDF hosted online¶
2. As a base64-encoded PDF in `document` content blocks¶
3. By a `file_id` from the [Files API](https://platform.claude.com/docs/en/build-with-claude/files)¶

<Note>¶
On Claude Models on Google Cloud (Google managed) and Amazon Bedrock, only base64-encoded sources are available. On Microsoft Foundry,
, send it in a [`document` content block](https://platform.claude.com/docs/en/api/messages#document_block_param) with one of three kinds of source. Your platform determines which kinds you can use (see [Availability](https://platform.claude.com/docs/en/build-with-claude/pdf-support#feature-availability)). Among those kinds, choose by where the PDF is, how large it is, and how often you use it:¶

1. **A PDF hosted online:** Reference it by its URL ([Option 1: URL-based PDF document](https://platform.claude.com/docs/en/build-with-claude/pdf-support#option-1-url-based-pdf-document)).¶
2. **A PDF on your local system or without a URL:** Send it as base64-encoded data ([Option 2: Base64-encoded PDF document](https://platform.claude.com/docs/en/build-with-claude/pdf-support#option-2-base64-encoded-pdf-document)).¶
3. **A large PDF or one that you’ll use repeatedly:** Upload it with
the [Files API is not supported for deployments hosted on Azure.¶
</Note>
](https://platform.claude.com/docs/en/build-with-claude/files) and reference it by its `file_id` ([Option 3: Files API](https://platform.claude.com/docs/en/build-with-claude/pdf-support#option-3-files-api)).

#### Option 1: URL-based PDF document¶

The simplest approach is to rReference athe PDF directly from aby its URL:¶

<CodeGroup>¶
```bash cURL¶
curl https://api.anthropic.com/v1/messages \¶
-H "content-type: application/json" \¶
-H "x-api-key: $ANTHROPIC_API_KEY" \¶
-H "anthropic-version: 2026-10-21" \¶
-d '{¶
"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?"¶
}]¶
}]¶
}'¶
```¶

```bash CLI¶
ant messages create <<'YAML'¶
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?¶
YAML¶
```¶

```python Python¶
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)¶
```¶

```typescript TypeScript¶
const anthropic = new Anthropic();¶

const response = await anthropic.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?"¶
}¶
]¶
}¶
]¶
});¶

console.log(response);¶
```¶

```csharp C#¶
var client = new AnthropicClient();¶

// Create
a document block with a URL¶
var documentParam = new DocumentBlockParam¶
{¶
Source = new UrlPdfSource¶
{¶
Url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf",¶
},¶
};¶

// Create a message with document and text content blocks¶
var message = await client.Messages.Create(new MessageCreateParams¶
{¶
Model = Model.ClaudeOpus5_5,¶
MaxTokens = 1024,¶
Messages =¶
[¶
new UserMessageParam¶
{¶
Content = new List<ContentBlockParam>¶
{¶
documentParam,¶
new TextBlockParam("What are the key findings in this document?"),¶
},¶
},¶
],¶
});¶

Console.WriteLine(string.Join("\n", message.Content));¶
```¶

```go Go¶
client := anthropic.NewClient()¶

message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{¶
Model: anthropic.ModelClaudeOpus5_5,¶
MaxTokens: 1024,¶
Messages: []anthropic.MessageParam{¶
anthropic.NewUserMessage(¶
anthropic.NewDocumentBlock(anthropic.URLPDFSourceParam{¶
URL: "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf",¶
}),¶
anthropic.NewTextBlock("What are the key findings in this document?"),¶
),¶
},¶
})¶
if err != nil {¶
panic(err)¶
}¶

fmt.Printf("%+v\n", message.Content)¶
```¶

```java Java¶
AnthropicClient client = AnthropicOkHttpClient.fromEnv();¶

// Create
a document block with a URL¶
DocumentBlockParam documentParam = DocumentBlockParam.builder()¶
.source(¶
UrlPdfSource.builder()¶
.url(¶
"https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"¶
)¶
.build()¶
)¶
.build();¶

// Create a message with document and text content blocks¶
MessageCreateParams params = MessageCreateParams.builder()¶
.model(Model.CLAUDE_OPUS_5_5)¶
.maxTokens(1024)¶
.addUserMessageOfContentBlockParams(¶
List.of(¶
ContentBlockParam.ofDocument(documentParam),¶
ContentBlockParam.ofText(¶
TextBlockParam.builder()¶
.text("What are the key findings in this document?")¶
.build()¶
)¶
)¶
)¶
.build();¶

Message message = client.messages().create(params);¶
System.outIO.println(message.content());¶
```¶

```php PHP¶
$client = new Client();¶

$message = $client->messages->create(¶
maxTokens: 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?',¶
],¶
],¶
],¶
],¶
model:
'claude-opus-5-5'Model::CLAUDE_OPUS_5_5,¶
);¶

echo $message;¶
```¶

```ruby Ruby¶
anthropic = Anthropic::Client.new¶

message = anthropic.messages.create(¶
model:
"claude-opus-5-5"Anthropic::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?"}¶
]¶
}¶
]¶
)¶

puts(message.content)¶
```¶
</CodeGroup>¶

The response returns Claude’s analysis as text blocks in `content`, with token consumption in `usage`:¶

```json Output¶
{¶
"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¶

If you need to send PDFs from your local system or whSend 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 URL isn’t availablelocal file in those examples, replace the lines that download and encode the PDF with the commented-out lines:¶

<CodeGroup>¶
```bash cURL¶
# Method 1: Fetch and encode a remote PDF¶
curl -sL "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf" | base64 | tr -d '\n' > pdf_base64.txt¶

# Method 2: Encode a local PDF file¶
# base64 document.pdf | tr -d '\n' > pdf_base64.txt¶

# Create a JSON request file using the pdf_base64.txt content¶
jq -n --rawfile PDF_BASE64 pdf_base64.txt '{¶
"model": "claude-opus-5-5",¶
"max_tokens": 1024,¶
"messages": [{¶
"role": "user",¶
"content": [{¶
"type": "document",¶
"source": {¶
"type": "base64",¶
"media_type": "application/pdf",¶
"data": $PDF_BASE64¶
}¶
},¶
{¶
"type": "text",¶
"text": "What are the key findings in this document?"¶
}]¶
}]¶
}' > request.json¶

# Send the API request using the JSON file¶
curl https://api.anthropic.com/v1/messages \¶
-H "content-type: application/json" \¶
-H "x-api-key: $ANTHROPIC_API_KEY" \¶
-H "anthropic-version: 2026-10-21" \¶
-d @request.json¶
```¶

```bash CLI¶
ant messages create --model claude-opus-5-5 --max-tokens 1024 <<'YAML'¶
messages:¶
- role: user¶
content:¶
- type: document¶
source:¶
type: base64¶
media_type: application/pdf¶
data: "@./document.pdf"¶
- type: text¶
text: What are the key findings in this document?¶
YAML¶
```¶

```python Python¶
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)¶
```¶

```typescript TypeScript¶
// Method 1: Fetch and encode a remote PDF¶
const pdfURL =¶
"https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
const pdfResponse = await fetch(pdfURL);¶
const arrayBuffer = await pdfResponse.arrayBuffer();¶
const pdfBase64 = Buffer.from(arrayBuffer).toString("base64");¶

// Method 2: Load from a local file¶
// import { readFile } from "node:fs/promises";¶
// const pdfBase64 = (await readFile("document.pdf")).toString("base64");¶

// Send the API request with base64-encoded PDF¶
const anthropic = new Anthropic();¶
const response = await anthropic.messages.create({¶
model: "claude-opus-5-5",¶
max_tokens: 1024,¶
messages: [¶
{¶
role: "user",¶
content: [¶
{¶
type: "document",¶
source: {¶
type: "base64",¶
media_type: "application/pdf",¶
data: pdfBase64¶
}¶
},¶
{¶
type: "text",¶
text: "What are the key findings in this document?"¶
}¶
]¶
}¶
]¶
});¶

console.log(response);¶
```¶

```csharp C#¶
var client = new AnthropicClient();¶

// Method 1: Download and encode a remote PDF¶
var pdfUrl = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
using var httpClient = new HttpClient();¶
var pdfBase64 = Convert.ToBase64String(await httpClient.GetByteArrayAsync(pdfUrl));¶

// Method 2: Load from a local file¶
// var pdfBase64 = Convert.ToBase64String(await File.ReadAllBytesAsync("document.pdf"));¶

// Create
a document block with base64 data¶
var documentParam = new DocumentBlockParam¶
{¶
Source = new Base64PdfSource { Data = pdfBase64 },¶
};¶

// Create a message with document and text content blocks¶
var message = await client.Messages.Create(new MessageCreateParams¶
{¶
Model = Model.ClaudeOpus5_5,¶
MaxTokens = 1024,¶
Messages =¶
[¶
new UserMessageParam¶
{¶
Content = new List<ContentBlockParam>¶
{¶
documentParam,¶
new TextBlockParam("What are the key findings in this document?"),¶
},¶
},¶
],¶
});¶

Console.WriteLine(string.Join("\n", message.Content));¶
```¶

```go Go¶
// First, load and encode the PDF¶
pdfURL := "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"¶
resp, err := http.Get(pdfURL)¶
if err != nil {¶
panic(err)¶
}¶
defer resp.Body.Close()¶
pdfBytes, err := io.ReadAll(resp.Body)¶
if err != nil {¶
panic(err)¶
}¶
pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)¶

// Alternative: Load from a local file (
add "os" to the importsin the imports, replace "io" and "net/http" with "os")¶
// pdfBytes, err := os.ReadFile("document.pdf")¶
// pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)¶

// Send to Claude using base64 encoding¶
client := anthropic.NewClient()¶
message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{¶
Model: anthropic.ModelClaudeOpus5_5,¶
MaxTokens: 1024,¶
Messages: []anthropic.MessageParam{¶
anthropic.NewUserMessage(¶
anthropic.NewDocumentBlock(anthropic.Base64PDFSourceParam{¶
Data: pdfBase64,¶
}),¶
anthropic.NewTextBlock("What are the key findings in this document?"),¶
),¶
},¶
})¶
if err != nil {¶
panic(err)¶
}¶

fmt.Printf("%+v\n", message.Content)¶
```¶

```java Java¶
AnthropicClient client = AnthropicOkHttpClient.fromEnv();¶

// Method 1: Download and encode a remote PDF¶
String pdfUrl =¶
"https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
HttpClient httpClient = HttpClient.newBuilder()¶
.followRedirects(HttpClient.Redirect.NORMAL)¶
.build();¶
HttpRequest request = HttpRequest.newBuilder()¶
.uri(URI.create(pdfUrl))¶
.GET()¶
.build();¶

HttpResponse<byte[]> response = httpClient.send(¶
request,¶
HttpResponse.BodyHandlers.ofByteArray()¶
);¶
String pdfBase64 = Base64.getEncoder().encodeToString(response.body());¶

// Method 2: Load from a local file¶
// byte[] fileBytes = Files.readAllBytes(Path.of("document.pdf"));¶
// String pdfBase64 = Base64.getEncoder().encodeToString(fileBytes);¶

// Create
a document block with base64 data¶
DocumentBlockParam documentParam = DocumentBlockParam.builder()¶
.source(Base64PdfSource.builder()¶
.data(pdfBase64)¶
.build())¶
.build();¶

// Create a message with document and text content blocks¶
MessageCreateParams params = MessageCreateParams.builder()¶
.model(Model.CLAUDE_OPUS_5_5)¶
.maxTokens(1024)¶
.addUserMessageOfContentBlockParams(¶
List.of(¶
ContentBlockParam.ofDocument(documentParam),¶
ContentBlockParam.ofText(¶
TextBlockParam.builder()¶
.text("What are the key findings in this document?")¶
.build()¶
)¶
)¶
)¶
.build();¶

Message message = client.messages().create(params);¶
System.outIO.println(message.content());¶
```¶

```php PHP¶
$client = new Client();¶

// 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_encode(bytes = file_get_contents($pdf_url)
?: throw new \RuntimeException('Could not fetch the PDF.');¶
$pdf_data = base64_encode($pdf_bytes
);¶

// Alternative: Load from a local file¶
// $pdf_
data = base64_encode(bytes = file_get_contents('document.pdf')
// ?: throw new \RuntimeException('Could not read document.pdf.');¶
// $pdf_data = base64_encode($pdf_bytes
);¶

// Send to Claude using base64 encoding¶
$message = $client->messages->create(¶
maxTokens: 1024,¶
messages: [¶
[¶
'role' => 'user',¶
'content' => [¶
[¶
'type' => 'document',¶
'source' => [¶
'type' => 'base64',¶
'media
_tType' => 'application/pdf',¶
'data' => $pdf_data,¶
],¶
],¶
[¶
'type' => 'text',¶
'text' => 'What are the key findings in this document?',¶
],¶
],¶
],¶
],¶
model:
'claude-opus-5-5'Model::CLAUDE_OPUS_5_5,¶
);¶

echo $message;¶
```¶

```ruby Ruby¶
require "open-uri"¶

# First, load and encode the PDF¶
pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"¶
pdf_bytes = URI.open(pdf_url, "rb"
) { |f| f., &:read })
pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines¶

# Alternative: Load from a local file¶
# pdf_data = [File.binread("document.pdf")].pack("m0")¶

# Send to Claude using base64 encoding¶
anthropic = Anthropic::Client.new¶
message = anthropic.messages.create(¶
model: Anthropic::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?"}¶
]¶
}¶
]¶
)¶

puts(message.content)¶
```¶
</CodeGroup>¶

#### Option 3: Files API¶

For PDFs you’ll use repeatedly, or when you want to avoid encoding overhead, use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files):¶

<CodeGroup>¶
```bash cURL¶
# First, upload your PDF to the Files API¶
curl -sS -X POST https://api.anthropic.com/v1/files \¶
-H "x-api-key: $ANTHROPIC_API_KEY" \¶
-H "anthropic-version: 2026-10-21" \¶
-F "file=@document.pdf"¶

# Then use the file_id from the upload response in your message¶
curl https://api.anthropic.com/v1/messages \¶
-H "content-type: application/json" \¶
-H "x-api-key: $ANTHROPIC_API_KEY" \¶
-H "anthropic-version: 2026-10-21" \¶
-d '{¶
"model": "claude-opus-5-5",¶
"max_tokens": 1024,¶
"messages": [{¶
"role": "user",¶
"content": [{¶
"type": "document",¶
"source": {¶
"type": "file",¶
"file_id": "'"$FILE_ID"'"¶
}¶
},¶
{¶
"type": "text",¶
"text": "What are the key findings in this document?"¶
}]¶
}]¶
}'¶
```¶

```bash CLI¶
# First, upload your PDF to the Files API¶
ant files upload --file ./document.pdf¶

# Then use the file_id from the upload response in your message¶
ant messages create <<YAML¶
model: claude-opus-5-5¶
max_tokens: 1024¶
messages:¶
- role: user¶
content:¶
- type: document¶
source:¶
type: file¶
file_id: $FILE_ID¶
- type: text¶
text: What are the key findings in this document?¶
YAML¶
```¶

```python Python¶
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)¶
```¶

```typescript TypeScript¶
import Anthropic, { toFile } from "@anthropic-ai/sdk";¶
import fs from "node:fs";¶

const anthropic = new Anthropic();¶

// Upload the PDF file¶
const fileUpload = await anthropic.files.upload({¶
file: await toFile(fs.createReadStream("/path/to/document.pdf"), undefined, {¶
type: "application/pdf"¶
})¶
});¶

// Use the uploaded file in a message¶
const response = await anthropic.messages.create({¶
model: "claude-opus-5-5",¶
max_tokens: 1024,¶
messages: [¶
{¶
role: "user",¶
content: [¶
{¶
type: "document",¶
source: {¶
type: "file",¶
file_id: fileUpload.id¶
}¶
},¶
{¶
type: "text",¶
text: "What are the key findings in this document?"¶
}¶
]¶
}¶
]¶
});¶

console.log(response);¶
```¶

```csharp C#¶
var client = new AnthropicClient();¶

// Upload the PDF file¶
var fileUpload = await client.Files.Upload(new FileUploadParams¶
{¶
File = new BinaryContent¶
{¶
Stream = File.OpenRead("/path/to/document.pdf"),¶
FileName = "document.pdf",¶
ContentType = new("application/pdf"),¶
},¶
});¶

// Use the uploaded file in a message¶
var message = await client.Messages.Create(new MessageCreateParams¶
{¶
Model = Model.ClaudeOpus5_5,¶
MaxTokens = 1024,¶
Messages =¶
[¶
new UserMessageParam¶
{¶
Content = new List<ContentBlockParam>¶
{¶
new DocumentBlockParam¶
{¶
Source = new FileDocumentSource { FileID = fileUpload.ID },¶
},¶
new TextBlockParam("What are the key findings in this document?"),¶
},¶
},¶
],¶
});¶

Console.WriteLine(string.Join("\n", message.Content));¶
```¶

```go Go¶
client := anthropic.NewClient()¶

// Upload the PDF file¶
pdfFile, err := os.Open("/path/to/document.pdf")¶
if err != nil {¶
panic(err)¶
}¶
defer pdfFile.Close()¶

fileUpload, err := client.Files.Upload(context.TODO(), anthropic.FileUploadParams{¶
File: anthropic.File(pdfFile, "document.pdf", "application/pdf"),¶
})¶
if err != nil {¶
panic(err)¶
}¶

// Use the uploaded file in a message¶
message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{¶
Model: anthropic.ModelClaudeOpus5_5,¶
MaxTokens: 1024,¶
Messages: []anthropic.MessageParam{¶
anthropic.NewUserMessage(¶
anthropic.NewDocumentBlock(anthropic.FileDocumentSourceParam{¶
FileID: fileUpload.ID,¶
}),¶
anthropic.NewTextBlock("What are the key findings in this document?"),¶
),¶
},¶
})¶
if err != nil {¶
panic(err)¶
}¶

fmt.Printf("%+v\n", message.Content)¶
```¶

```java Java¶
AnthropicClient client = AnthropicOkHttpClient.fromEnv();¶

// Upload the PDF file¶
FileMetadata file = client¶
.files()¶
.upload(FileUploadParams.builder()¶
.file(Path.of("/path/to/document.pdf"))¶
.build());¶

// Use the uploaded file in a message¶
MessageCreateParams params = MessageCreateParams.builder()¶
.model(Model.CLAUDE_OPUS_5_5)¶
.maxTokens(1024)¶
.addUserMessageOfContentBlockParams(¶
List.of(¶
ContentBlockParam.ofDocument(¶
DocumentBlockParam.builder()¶
.fileSource(file.id())¶
.build()¶
),¶
ContentBlockParam.ofText(¶
TextBlockParam.builder()¶
.text("What are the key findings in this document?")¶
.build()¶
)¶
)¶
)¶
.build();¶

Message message = client.messages().create(params);¶
System.outIO.println(message.content());¶
```¶

```php PHP¶
use Anthropic\Core\FileParam;¶

$client = new Client();¶

// Upload the PDF file¶
$document = fopen('/path/to/document.pdf', 'rb')¶
?: throw new \RuntimeException('Could not open /path/to/document.pdf.');¶

$file_upload = $client->files->upload(¶
file: FileParam::fromResource(
fopen('/path/to/document.pdf', 'r')$document, contentType: 'application/pdf'),¶
);¶

// Use the uploaded file in a message¶
$message = $client->messages->create(¶
maxTokens: 1024,¶
messages: [¶
[¶
'role' => 'user',¶
'content' => [¶
[¶
'type' => 'document',¶
'source' => [¶
'type' => 'file',¶
'fileID' => $file_upload->id,¶
],¶
],¶
[¶
'type' => 'text',¶
'text' => 'What are the key findings in this document?',¶
],¶
],¶
],¶
],¶
model:
'claude-opus-5-5'Model::CLAUDE_OPUS_5_5,¶
);¶

echo $message;¶
```¶

```ruby Ruby¶
anthropic = Anthropic::Client.new¶

# Upload the PDF file¶
file_upload = File.open("/path/to/document.pdf", "rb") do |
fpdf_file|¶
anthropic.files.upload(¶
file: Anthropic::FilePart.new(
fpdf_file, filename: "document.pdf", content_type: "application/pdf")¶
)¶
end¶

# Use the uploaded file in a message¶
message = anthropic.messages.create(¶
model: Anthropic::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?"}¶
]¶
}¶
]¶
)¶

puts(message.content)¶
```¶
</CodeGroup>¶

### How PDF support works¶

When you send a PDF to Claude, the following steps occur:¶

<Steps>¶
<Step title="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 is extracted and provideds it alongside eachthat page’s image.¶
</Step>¶

<Step title="Claude analyzes both the text and images.">¶
*
Documents are providedClaude receives each document as a combination of text and images for analysis.¶
* This allows users to
.¶
* 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.¶
</Step>¶

<Step title="Claude
responds, referencinguses the PDF’s contents in its response if relevant.">¶
Claude can
referencedraw on both textual and visual content when it responds. You can further improve performance by integrating PDF support with:¶

* [Use prompt caching](https://platform.claude.com/docs/en/build-with-claude/pdf-support#use-prompt-caching): To improve performance for repeated analysis.¶
* [Process document batches](https://platform.claude.com/docs/en/build-with-claude/pdf-support#process-document-batches): To process documents at high volume.¶
* [Tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview): To extract specific information from documents for use as tool inputs
in its response.¶
</Step>¶
</Steps>¶

### 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:
Because each page is converted into an image, the same [image-based cost calculationsEach 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](https://platform.claude.com/docs/en/build-with-claude/vision#evaluate-image-size) are applied.¶

You can use [token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting) to estimate costs for your specific PDFs.¶

## Optimize PDF processing¶

You can combine PDF support with other features:¶

* [Use prompt caching](https://platform.claude.com/docs/en/build-with-claude/pdf-support#use-prompt-caching) to improve performance for repeated analysis.¶
* [Process document batches](https://platform.claude.com/docs/en/build-with-claude/pdf-support#process-document-batches) to handle documents at high volume.¶
* [Use tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) 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](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) to improve performance on repeated queries:¶

<CodeGroup>¶
```bash cURL¶
curl -sL "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf" |¶
base64 | tr -d '\n' |¶
jq -Rs '{¶
model: "claude-opus-5-5",¶
max_tokens: 1024,¶
messages: [{¶
role: "user",¶
content: [¶
{¶
type: "document",¶
source: {type: "base64", media_type: "application/pdf", data: .},¶
cache_control: {type: "ephemeral"}¶
},¶
{type: "text", text: "Which model has the highest human preference win rates across each use-case?"}¶
]¶
}]¶
}' |¶
curl https://api.anthropic.com/v1/messages \¶
-H "content-type: application/json" \¶
-H "x-api-key: $ANTHROPIC_API_KEY" \¶
-H "anthropic-version: 2026-10-21" \¶
-d @-¶
```¶

```bash CLI¶
ant messages create <<'YAML'¶
model: claude-opus-5-5¶
max_tokens: 1024¶
messages:¶
- role: user¶
content:¶
- type: document¶
source:¶
type: base64¶
media_type: application/pdf¶
data: "@./document.pdf"¶
cache_control:¶
type: ephemeral¶
- type: text¶
text: Which model has the highest human preference win rates across each use-case?¶
YAML¶
```¶

```python Python¶
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)¶
```¶

```typescript TypeScript¶
// First, load and encode the PDF¶
const pdfURL =¶
"https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
const pdfResponse = await fetch(pdfURL);¶
const arrayBuffer = await pdfResponse.arrayBuffer();¶
const pdfBase64 = Buffer.from(arrayBuffer).toString("base64");¶

// Create a message with the cached document¶
const anthropic = new Anthropic();¶
const response = await anthropic.messages.create({¶
model: "claude-opus-5-5",¶
max_tokens: 1024,¶
messages: [¶
{¶
role: "user",¶
content: [¶
{¶
type: "document",¶
source: {¶
type: "base64",¶
media_type: "application/pdf",¶
data: pdfBase64¶
},¶
cache_control: { type: "ephemeral" }¶
},¶
{¶
type: "text",¶
text: "Which model has the highest human preference win rates across each use-case?"¶
}¶
]¶
}¶
]¶
});¶

console.log(response);¶
```¶

```csharp C#¶
var client = new AnthropicClient();¶

// Download and encode the PDF¶
var pdfUrl = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
using var httpClient = new HttpClient();¶
var pdfBase64 = Convert.ToBase64String(await httpClient.GetByteArrayAsync(pdfUrl));¶

var message = await client.Messages.Create(new MessageCreateParams¶
{¶
Model = Model.ClaudeOpus5_5,¶
MaxTokens = 1024,¶
Messages =¶
[¶
new UserMessageParam¶
{¶
Content = new List<ContentBlockParam>¶
{¶
new DocumentBlockParam¶
{¶
Source = new Base64PdfSource { Data = pdfBase64 },¶
CacheControl = new CacheControlEphemeral(),¶
},¶
new TextBlockParam("Which model has the highest human preference win rates across each use-case?"),¶
},¶
},¶
],¶
});¶

Console.WriteLine(message);¶
```¶

```go Go¶
// First, load and encode the PDF¶
pdfURL := "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"¶
resp, err := http.Get(pdfURL)¶
if err != nil {¶
panic(err)¶
}¶
defer resp.Body.Close()¶
pdfBytes, err := io.ReadAll(resp.Body)¶
if err != nil {¶
panic(err)¶
}¶
pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)¶

// Create a document block with cache control¶
client := anthropic.NewClient()¶
message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{¶
Model: anthropic.ModelClaudeOpus5_5,¶
MaxTokens: 1024,¶
Messages: []anthropic.MessageParam{¶
anthropic.NewUserMessage(¶
anthropic.ContentBlockParamUnion{¶
OfDocument: &anthropic.DocumentBlockParam{¶
Source: anthropic.DocumentBlockParamSourceUnion{¶
OfBase64: &anthropic.Base64PDFSourceParam{¶
Data: pdfBase64,¶
},¶
},¶
CacheControl: anthropic.NewCacheControlEphemeralParam(),¶
},¶
},¶
anthropic.NewTextBlock("Which model has the highest human preference win rates across each use-case?"),¶
),¶
},¶
})¶
if err != nil {¶
panic(err)¶
}¶

fmt.Printf("%+v\n", message.Content)¶
```¶

```java Java¶
AnthropicClient client = AnthropicOkHttpClient.fromEnv();¶

// Download and encode the PDF¶
String pdfUrl =¶
"https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
HttpClient httpClient = HttpClient.newBuilder()¶
.followRedirects(HttpClient.Redirect.NORMAL)¶
.build();¶
HttpRequest request = HttpRequest.newBuilder()¶
.uri(URI.create(pdfUrl))¶
.GET()¶
.build();¶

HttpResponse<byte[]> response = httpClient.send(¶
request,¶
HttpResponse.BodyHandlers.ofByteArray()¶
);¶
String pdfBase64 = Base64.getEncoder().encodeToString(response.body());¶

MessageCreateParams params = MessageCreateParams.builder()¶
.model(Model.CLAUDE_OPUS_5_5)¶
.maxTokens(1024)¶
.addUserMessageOfContentBlockParams(¶
List.of(¶
ContentBlockParam.ofDocument(¶
DocumentBlockParam.builder()¶
.source(Base64PdfSource.builder()¶
.data(pdfBase64)¶
.build())¶
.cacheControl(CacheControlEphemeral.builder().build())¶
.build()¶
),¶
ContentBlockParam.ofText(¶
TextBlockParam.builder()¶
.text(¶
"Which model has the highest human preference win rates across each use-case?"¶
)¶
.build()¶
)¶
)¶
)¶
.build();¶

Message message = client.messages().create(params);¶
System.outIO.println(message);¶
```¶

```php PHP¶
$client = new Client();¶

// Load and encode the PDF¶
$pdf_url = 'https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf';¶
$pdf_
data = base64_encode(bytes = file_get_contents($pdf_url)
?: throw new \RuntimeException('Could not fetch the PDF.');¶
$pdf_data = base64_encode($pdf_bytes
);¶

$message = $client->messages->create(¶
maxTokens: 1024,¶
messages: [¶
[¶
'role' => 'user',¶
'content' => [¶
[¶
'type' => 'document',¶
'source' => [¶
'type' => 'base64',¶
'media
_tType' => 'application/pdf',¶
'data' => $pdf_data,¶
],¶
'cache
_cControl' => ['type' => 'ephemeral'],¶
],¶
[¶
'type' => 'text',¶
'text' => 'Which model has the highest human preference win rates across each use-case?',¶
],¶
],¶
],¶
],¶
model:
'claude-opus-5-5'Model::CLAUDE_OPUS_5_5,¶
);¶

echo $message;¶
```¶

```ruby Ruby¶
require "open-uri"¶

# Load and encode the PDF¶
pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"¶
pdf_bytes = URI.open(pdf_url, "rb"
) { |f| f., &:read })
pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines¶

anthropic = Anthropic::Client.new¶

message = anthropic.messages.create(¶
model: Anthropic::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?"¶
}¶
]¶
}¶
]¶
)¶

puts(message.content)¶
```¶
</CodeGroup>¶

#### Process document batches¶

Use the [Message Batches API](https://platform.claude.com/docs/en/build-with-claude/batch-processing) to process many PDFs in one request:¶

<CodeGroup>¶
```bash cURL¶
curl -sL "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf" | base64 | tr -d '\n' > pdf_base64.txt¶
# Create a JSON request file using the pdf_base64.txt content¶
jq -n --rawfile PDF_BASE64 pdf_base64.txt '{¶
"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_BASE64¶
}¶
},¶
{¶
"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_BASE64¶
}¶
},¶
{¶
"type": "text",¶
"text": "Extract 5 key insights from this document."¶
}]¶
}]¶
}¶
}]¶
}' > request.json¶

# Then make the API call using the JSON file¶
curl https://api.anthropic.com/v1/messages/batches \¶
-H "content-type: application/json" \¶
-H "x-api-key: $ANTHROPIC_API_KEY" \¶
-H "anthropic-version: 2026-10-21" \¶
-d @request.json¶
```¶

```bash CLI¶
ant messages:batches create <<'YAML'¶
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: "@./document.pdf"¶
- 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: "@./document.pdf"¶
- type: text¶
text: Extract 5 key insights from this document.¶
YAML¶
```¶

```python Python¶
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)¶
```¶

```typescript TypeScript¶
// First, load and encode the PDF¶
const pdfURL =¶
"https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
const pdfResponse = await fetch(pdfURL);¶
const arrayBuffer = await pdfResponse.arrayBuffer();¶
const pdfBase64 = Buffer.from(arrayBuffer).toString("base64");¶

// Create a batch of requests that use the document¶
const anthropic = new Anthropic();¶
const response = await anthropic.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: pdfBase64¶
}¶
},¶
{¶
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: pdfBase64¶
}¶
},¶
{¶
type: "text",¶
text: "Extract 5 key insights from this document."¶
}¶
]¶
}¶
]¶
}¶
}¶
]¶
});¶

console.log(response);¶
```¶

```csharp C#¶
var client = new AnthropicClient();¶

// Download and encode the PDF¶
var pdfUrl = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
using var httpClient = new HttpClient();¶
var pdfBase64 = Convert.ToBase64String(await httpClient.GetByteArrayAsync(pdfUrl));¶

var batch = await client.Messages.Batches.Create(new BatchCreateParams¶
{¶
Requests =¶
[¶
new()¶
{¶
CustomID = "my-first-request",¶
Params = new()¶
{¶
Model = Model.ClaudeOpus5_5,¶
MaxTokens = 1024,¶
Messages =¶
[¶
new UserMessageParam¶
{¶
Content = new List<ContentBlockParam>¶
{¶
new DocumentBlockParam¶
{¶
Source = new Base64PdfSource { Data = pdfBase64 },¶
},¶
new TextBlockParam("Which model has the highest human preference win rates across each use-case?"),¶
},¶
},¶
],¶
},¶
},¶
new()¶
{¶
CustomID = "my-second-request",¶
Params = new()¶
{¶
Model = Model.ClaudeOpus5_5,¶
MaxTokens = 1024,¶
Messages =¶
[¶
new UserMessageParam¶
{¶
Content = new List<ContentBlockParam>¶
{¶
new DocumentBlockParam¶
{¶
Source = new Base64PdfSource { Data = pdfBase64 },¶
},¶
new TextBlockParam("Extract 5 key insights from this document."),¶
},¶
},¶
],¶
},¶
},¶
],¶
});¶

Console.WriteLine(batch);¶
```¶

```go Go¶
// First, load and encode the PDF¶
pdfURL := "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"¶
resp, err := http.Get(pdfURL)¶
if err != nil {¶
panic(err)¶
}¶
defer resp.Body.Close()¶
pdfBytes, err := io.ReadAll(resp.Body)¶
if err != nil {¶
panic(err)¶
}¶
pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)¶

// Create a batch of requests that use the document¶
client := anthropic.NewClient()¶
batch, err := client.Messages.Batches.New(context.TODO(), anthropic.MessageBatchNewParams{¶
Requests: []anthropic.MessageBatchNewParamsRequest{¶
{¶
CustomID: "my-first-request",¶
Params: anthropic.MessageBatchNewParamsRequestParams{¶
Model: anthropic.ModelClaudeOpus5_5,¶
MaxTokens: 1024,¶
Messages: []anthropic.MessageParam{¶
anthropic.NewUserMessage(¶
anthropic.NewDocumentBlock(anthropic.Base64PDFSourceParam{¶
Data: pdfBase64,¶
}),¶
anthropic.NewTextBlock("Which model has the highest human preference win rates across each use-case?"),¶
),¶
},¶
},¶
},¶
{¶
CustomID: "my-second-request",¶
Params: anthropic.MessageBatchNewParamsRequestParams{¶
Model: anthropic.ModelClaudeOpus5_5,¶
MaxTokens: 1024,¶
Messages: []anthropic.MessageParam{¶
anthropic.NewUserMessage(¶
anthropic.NewDocumentBlock(anthropic.Base64PDFSourceParam{¶
Data: pdfBase64,¶
}),¶
anthropic.NewTextBlock("Extract 5 key insights from this document."),¶
),¶
},¶
},¶
},¶
},¶
})¶
if err != nil {¶
panic(err)¶
}¶

fmt.Printf("%+v\n", batch)¶
```¶

```java Java¶
AnthropicClient client = AnthropicOkHttpClient.fromEnv();¶

// Download and encode the PDF¶
String pdfUrl =¶
"https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";¶
HttpClient httpClient = HttpClient.newBuilder()¶
.followRedirects(HttpClient.Redirect.NORMAL)¶
.build();¶
HttpRequest request = HttpRequest.newBuilder()¶
.uri(URI.create(pdfUrl))¶
.GET()¶
.build();¶

HttpResponse<byte[]> response = httpClient.send(¶
request,¶
HttpResponse.BodyHandlers.ofByteArray()¶
);¶
String pdfBase64 = Base64.getEncoder().encodeToString(response.body());¶

BatchCreateParams params = BatchCreateParams.builder()¶
.addRequest(¶
BatchCreateParams.Request.builder()¶
.customId("my-first-request")¶
.params(¶
BatchCreateParams.Request.Params.builder()¶
.model(Model.CLAUDE_OPUS_5_5)¶
.maxTokens(1024)¶
.addUserMessageOfContentBlockParams(¶
List.of(¶
ContentBlockParam.ofDocument(¶
DocumentBlockParam.builder()¶
.source(Base64PdfSource.builder()¶
.data(pdfBase64)¶
.build())¶
.build()¶
),¶
ContentBlockParam.ofText(¶
TextBlockParam.builder()¶
.text(¶
"Which model has the highest human preference win rates across each use-case?"¶
)¶
.build()¶
)¶
)¶
)¶
.build()¶
)¶
.build()¶
)¶
.addRequest(¶
BatchCreateParams.Request.builder()¶
.customId("my-second-request")¶
.params(¶
BatchCreateParams.Request.Params.builder()¶
.model(Model.CLAUDE_OPUS_5_5)¶
.maxTokens(1024)¶
.addUserMessageOfContentBlockParams(¶
List.of(¶
ContentBlockParam.ofDocument(¶
DocumentBlockParam.builder()¶
.source(Base64PdfSource.builder()¶
.data(pdfBase64)¶
.build())¶
.build()¶
),¶
ContentBlockParam.ofText(¶
TextBlockParam.builder()¶
.text("Extract 5 key insights from this document.")¶
.build()¶
)¶
)¶
)¶
.build()¶
)¶
.build()¶
)¶
.build();¶

MessageBatch batch = client.messages().batches().create(params);¶
System.outIO.println(batch);¶
```¶

```php PHP¶
$client = new Client();¶

// Load and encode the PDF¶
$pdf_url = 'https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf';¶
$pdf_
data = base64_encode(bytes = file_get_contents($pdf_url)
?: throw new \RuntimeException('Could not fetch the PDF.');¶
$pdf_data = base64_encode($pdf_bytes
);¶

$batch = $client->messages->batches->create(¶
requests: [¶
[¶
'custom
_idID' => 'my-first-request',¶
'params' => [¶
'model' =>
'claude-opus-5-5'Model::CLAUDE_OPUS_5_5,¶
'max
_tTokens' => 1024,¶
'messages' => [¶
[¶
'role' => 'user',¶
'content' => [¶
[¶
'type' => 'document',¶
'source' => [¶
'type' => 'base64',¶
'media
_tType' => 'application/pdf',¶
'data' => $pdf_data,¶
],¶
],¶
[¶
'type' => 'text',¶
'text' => 'Which model has the highest human preference win rates across each use-case?',¶
],¶
],¶
],¶
],¶
],¶
],¶
[¶
'custom
_idID' => 'my-second-request',¶
'params' => [¶
'model' =>
'claude-opus-5-5'Model::CLAUDE_OPUS_5_5,¶
'max
_tTokens' => 1024,¶
'messages' => [¶
[¶
'role' => 'user',¶
'content' => [¶
[¶
'type' => 'document',¶
'source' => [¶
'type' => 'base64',¶
'media
_tType' => 'application/pdf',¶
'data' => $pdf_data,¶
],¶
],¶
[¶
'type' => 'text',¶
'text' => 'Extract 5 key insights from this document.',¶
],¶
],¶
],¶
],¶
],¶
],¶
],¶
);¶

echo $batch;¶
```¶

```ruby Ruby¶
require "open-uri"¶

# Load and encode the PDF¶
pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"¶
pdf_bytes = URI.open(pdf_url, "rb"
) { |f| f., &:read })
pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines¶

anthropic = Anthropic::Client.new¶

message_batch = anthropic.messages.batches.create(¶
requests: [¶
{¶
custom_id: "my-first-request",¶
params: {¶
model: Anthropic::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: Anthropic::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."¶
}¶
]¶
}¶
]¶
}¶
}¶
]¶
)¶

puts(message_batch)¶
```¶
</CodeGroup>¶

Batches process asynchronously. To check progress and retrieve results once processing ends, see [Batch processing](https://platform.claude.com/docs/en/build-with-claude/batch-processing).¶

## Next steps¶

<CardGroup cols={2}>¶
<Card title="Vision" icon="image" href="https://platform.claude.com/docs/en/build-with-claude/vision">¶
Claude’s vision capabilities allow it to process and analyze images, opening up exciting possibilities for multimodal interactionLearn how to count an image’s visual tokens and which limitations PDFs share with other vision tasks.¶
</Card>¶

<Card title="Try PDF examples" icon="file" href="https://platform.claude.com/cookbook/multimodal-getting-started-with-vision">¶
Explore practical examples of PDF processing in the Claude Cookbook recipe.¶
</Card>¶

<Card title="View API reference" icon="code" href="https://platform.claude.com/docs/en/api/messages/create">¶
See complete API documentation for PDF support.¶
</Card>¶
</CardGroup>¶

## Availability¶

PDF support is available on every model and eligible for zero data retention and HIPAA readiness.¶

### API support¶

#### [Messages API](https://platform.claude.com/docs/en/build-with-claude/working-with-messages)¶

* Availability: Always on¶

| Status | Cloud platforms |¶
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |¶
| Available | Claude API, [Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws), [Claude Models on Google Cloud (Anthropic managed)](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed) |¶
| Available<sup>1</sup> | [Microsoft Foundry](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry) |¶
| Available<sup>2</sup> | [Amazon Bedrock (bedrock-runtime)](https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock-legacy) |¶
| Available<sup>2</sup> | [Amazon Bedrock](https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock), [Claude Models on Google Cloud (Google managed)](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/google-managed) |¶

1. `file_id` sources need a Hosted on Anthropic deployment.¶
2. Base64 sources only.¶

#### [Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview)¶

* Availability: Always on¶

| Status | Cloud platforms |¶
| --------- | ----------------------- |¶
| Available | All supported platforms |¶

### Data handling¶

[Data handling overview](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#feature-eligibility)¶

| Item | Zero data retention | HIPAA |¶
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |¶
| Status | Eligible (excludes [Covered Models](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#model-specific-data-retention-requirements)) | Eligible |¶
| Details | — | HIPAA eligibility applies to PDFs sent inline through the Messages API, not through the Files API. |¶

Applicable endpoints:¶

* `/v1/messages`¶

Unified Diff

--- a/build-with-claude/pdf-support.md
+++ b/build-with-claude/pdf-support.md
@@ -84,19 +84,15 @@
 
 ### Send your first PDF request
 
-Start with a simple example using the Messages API. You can provide PDFs to Claude in three ways:
-
-1. As a URL reference to a PDF hosted online
-2. As a base64-encoded PDF in `document` content blocks
-3. By a `file_id` from the [Files API](https://platform.claude.com/docs/en/build-with-claude/files)
-
-<Note>
-  On Claude Models on Google Cloud (Google managed) and Amazon Bedrock, only base64-encoded sources are available. On Microsoft Foundry, the Files API is not supported for deployments hosted on Azure.
-</Note>
+Start with an example that uses the Messages API. To give Claude a PDF, send it in a [`document` content block](https://platform.claude.com/docs/en/api/messages#document_block_param) with one of three kinds of source. Your platform determines which kinds you can use (see [Availability](https://platform.claude.com/docs/en/build-with-claude/pdf-support#feature-availability)). Among those kinds, choose by where the PDF is, how large it is, and how often you use it:
+
+1. **A PDF hosted online:** Reference it by its URL ([Option 1: URL-based PDF document](https://platform.claude.com/docs/en/build-with-claude/pdf-support#option-1-url-based-pdf-document)).
+2. **A PDF on your local system or without a URL:** Send it as base64-encoded data ([Option 2: Base64-encoded PDF document](https://platform.claude.com/docs/en/build-with-claude/pdf-support#option-2-base64-encoded-pdf-document)).
+3. **A large PDF or one that you’ll use repeatedly:** Upload it with the [Files API](https://platform.claude.com/docs/en/build-with-claude/files) and reference it by its `file_id` ([Option 3: Files API](https://platform.claude.com/docs/en/build-with-claude/pdf-support#option-3-files-api)).
 
 #### Option 1: URL-based PDF document
 
-The simplest approach is to reference a PDF directly from a URL:
+Reference the PDF by its URL:
 
 <CodeGroup>
   ```bash cURL
@@ -197,7 +193,7 @@
   ```csharp C#
   var client = new AnthropicClient();
 
-  // Create document block with URL
+  // Create a document block with a URL
   var documentParam = new DocumentBlockParam
   {
       Source = new UrlPdfSource
@@ -252,7 +248,7 @@
   ```java Java
   AnthropicClient client = AnthropicOkHttpClient.fromEnv();
 
-  // Create document block with URL
+  // Create a document block with a URL
   DocumentBlockParam documentParam = DocumentBlockParam.builder()
       .source(
           UrlPdfSource.builder()
@@ -280,7 +276,7 @@
       .build();
 
   Message message = client.messages().create(params);
-  System.out.println(message.content());
+  IO.println(message.content());
   ```
 
   ```php PHP
@@ -306,7 +302,7 @@
               ],
           ],
       ],
-      model: 'claude-opus-5-5',
+      model: Model::CLAUDE_OPUS_5_5,
   );
 
   echo $message;
@@ -316,7 +312,7 @@
   anthropic = Anthropic::Client.new
 
   message = anthropic.messages.create(
-    model: "claude-opus-5-5",
+    model: Anthropic::Model::CLAUDE_OPUS_5_5,
     max_tokens: 1024,
     messages: [
       {
@@ -363,7 +359,7 @@
 
 #### Option 2: Base64-encoded PDF document
 
-If you need to send PDFs from your local system or when a URL isn’t available:
+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:
 
 <CodeGroup>
   ```bash cURL
@@ -509,7 +505,7 @@
   // Method 2: Load from a local file
   // var pdfBase64 = Convert.ToBase64String(await File.ReadAllBytesAsync("document.pdf"));
 
-  // Create document block with base64 data
+  // Create a document block with base64 data
   var documentParam = new DocumentBlockParam
   {
       Source = new Base64PdfSource { Data = pdfBase64 },
@@ -550,7 +546,7 @@
   }
   pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)
 
-  // Alternative: Load from a local file (add "os" to the imports)
+  // Alternative: Load from a local file (in the imports, replace "io" and "net/http" with "os")
   // pdfBytes, err := os.ReadFile("document.pdf")
   // pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)
 
@@ -599,7 +595,7 @@
   // byte[] fileBytes = Files.readAllBytes(Path.of("document.pdf"));
   // String pdfBase64 = Base64.getEncoder().encodeToString(fileBytes);
 
-  // Create document block with base64 data
+  // Create a document block with base64 data
   DocumentBlockParam documentParam = DocumentBlockParam.builder()
       .source(Base64PdfSource.builder()
           .data(pdfBase64)
@@ -623,7 +619,7 @@
       .build();
 
   Message message = client.messages().create(params);
-  System.out.println(message.content());
+  IO.println(message.content());
   ```
 
   ```php PHP
@@ -631,10 +627,14 @@
 
   // 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_encode(file_get_contents($pdf_url));
+  $pdf_bytes = file_get_contents($pdf_url)
+      ?: throw new \RuntimeException('Could not fetch the PDF.');
+  $pdf_data = base64_encode($pdf_bytes);
 
   // Alternative: Load from a local file
-  // $pdf_data = base64_encode(file_get_contents('document.pdf'));
+  // $pdf_bytes = file_get_contents('document.pdf')
+  //     ?: throw new \RuntimeException('Could not read document.pdf.');
+  // $pdf_data = base64_encode($pdf_bytes);
 
   // Send to Claude using base64 encoding
   $message = $client->messages->create(
@@ -647,7 +647,7 @@
                       'type' => 'document',
                       'source' => [
                           'type' => 'base64',
-                          'media_type' => 'application/pdf',
+                          'mediaType' => 'application/pdf',
                           'data' => $pdf_data,
                       ],
                   ],
@@ -658,7 +658,7 @@
               ],
           ],
       ],
-      model: 'claude-opus-5-5',
+      model: Model::CLAUDE_OPUS_5_5,
   );
 
   echo $message;
@@ -669,7 +669,7 @@
 
   # First, load and encode the PDF
   pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
-  pdf_bytes = URI.open(pdf_url, "rb") { |f| f.read }
+  pdf_bytes = URI.open(pdf_url, "rb", &:read)
   pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines
 
   # Alternative: Load from a local file
@@ -933,7 +933,7 @@
       .build();
 
   Message message = client.messages().create(params);
-  System.out.println(message.content());
+  IO.println(message.content());
   ```
 
   ```php PHP
@@ -942,8 +942,11 @@
   $client = new Client();
 
   // Upload the PDF file
+  $document = fopen('/path/to/document.pdf', 'rb')
+      ?: throw new \RuntimeException('Could not open /path/to/document.pdf.');
+
   $file_upload = $client->files->upload(
-      file: FileParam::fromResource(fopen('/path/to/document.pdf', 'r'), contentType: 'application/pdf'),
+      file: FileParam::fromResource($document, contentType: 'application/pdf'),
   );
 
   // Use the uploaded file in a message
@@ -967,7 +970,7 @@
               ],
           ],
       ],
-      model: 'claude-opus-5-5',
+      model: Model::CLAUDE_OPUS_5_5,
   );
 
   echo $message;
@@ -977,9 +980,9 @@
   anthropic = Anthropic::Client.new
 
   # Upload the PDF file
-  file_upload = File.open("/path/to/document.pdf", "rb") do |f|
+  file_upload = File.open("/path/to/document.pdf", "rb") do |pdf_file|
     anthropic.files.upload(
-      file: Anthropic::FilePart.new(f, filename: "document.pdf", content_type: "application/pdf")
+      file: Anthropic::FilePart.new(pdf_file, filename: "document.pdf", content_type: "application/pdf")
     )
   end
 
@@ -1012,20 +1015,16 @@
 <Steps>
   <Step title="The system extracts the contents of the document.">
     * The system converts each page of the document into an image.
-    * The text from each page is extracted and provided alongside each page’s image.
+    * The system extracts the text from each page and provides it alongside that page’s image.
   </Step>
 
   <Step title="Claude analyzes both the text and images.">
-    * Documents are provided as a combination of text and images for analysis.
-    * This allows users to ask for insights on visual elements of a PDF, such as charts, diagrams, and other non-textual content.
+    * 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.
   </Step>
 
-  <Step title="Claude responds, referencing the PDF’s contents if relevant.">
-    Claude can reference both textual and visual content when it responds. You can further improve performance by integrating PDF support with:
-
-    * [Use prompt caching](https://platform.claude.com/docs/en/build-with-claude/pdf-support#use-prompt-caching): To improve performance for repeated analysis.
-    * [Process document batches](https://platform.claude.com/docs/en/build-with-claude/pdf-support#process-document-batches): To process documents at high volume.
-    * [Tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview): To extract specific information from documents for use as tool inputs.
+  <Step title="Claude uses the PDF’s contents in its response if relevant.">
+    Claude can draw on both textual and visual content in its response.
   </Step>
 </Steps>
 
@@ -1034,11 +1033,17 @@
 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: Because each page is converted into an image, the same [image-based cost calculations](https://platform.claude.com/docs/en/build-with-claude/vision#evaluate-image-size) are applied.
+* 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](https://platform.claude.com/docs/en/build-with-claude/vision#evaluate-image-size).
 
 You can use [token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting) to estimate costs for your specific PDFs.
 
 ## Optimize PDF processing
+
+You can combine PDF support with other features:
+
+* [Use prompt caching](https://platform.claude.com/docs/en/build-with-claude/pdf-support#use-prompt-caching) to improve performance for repeated analysis.
+* [Process document batches](https://platform.claude.com/docs/en/build-with-claude/pdf-support#process-document-batches) to handle documents at high volume.
+* [Use tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) to have Claude extract specific information from documents for use as tool inputs.
 
 ### Improve performance
 
@@ -1302,7 +1307,7 @@
       .build();
 
   Message message = client.messages().create(params);
-  System.out.println(message);
+  IO.println(message);
   ```
 
   ```php PHP
@@ -1310,7 +1315,9 @@
 
   // Load and encode the PDF
   $pdf_url = 'https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf';
-  $pdf_data = base64_encode(file_get_contents($pdf_url));
+  $pdf_bytes = file_get_contents($pdf_url)
+      ?: throw new \RuntimeException('Could not fetch the PDF.');
+  $pdf_data = base64_encode($pdf_bytes);
 
   $message = $client->messages->create(
       maxTokens: 1024,
@@ -1322,10 +1329,10 @@
                       'type' => 'document',
                       'source' => [
                           'type' => 'base64',
-                          'media_type' => 'application/pdf',
+                          'mediaType' => 'application/pdf',
                           'data' => $pdf_data,
                       ],
-                      'cache_control' => ['type' => 'ephemeral'],
+                      'cacheControl' => ['type' => 'ephemeral'],
                   ],
                   [
                       'type' => 'text',
@@ -1334,7 +1341,7 @@
               ],
           ],
       ],
-      model: 'claude-opus-5-5',
+      model: Model::CLAUDE_OPUS_5_5,
   );
 
   echo $message;
@@ -1345,7 +1352,7 @@
 
   # Load and encode the PDF
   pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
-  pdf_bytes = URI.open(pdf_url, "rb") { |f| f.read }
+  pdf_bytes = URI.open(pdf_url, "rb", &:read)
   pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines
 
   anthropic = Anthropic::Client.new
@@ -1822,7 +1829,7 @@
       .build();
 
   MessageBatch batch = client.messages().batches().create(params);
-  System.out.println(batch);
+  IO.println(batch);
   ```
 
   ```php PHP
@@ -1830,15 +1837,17 @@
 
   // Load and encode the PDF
   $pdf_url = 'https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf';
-  $pdf_data = base64_encode(file_get_contents($pdf_url));
+  $pdf_bytes = file_get_contents($pdf_url)
+      ?: throw new \RuntimeException('Could not fetch the PDF.');
+  $pdf_data = base64_encode($pdf_bytes);
 
   $batch = $client->messages->batches->create(
       requests: [
           [
-              'custom_id' => 'my-first-request',
+              'customID' => 'my-first-request',
               'params' => [
-                  'model' => 'claude-opus-5-5',
-                  'max_tokens' => 1024,
+                  'model' => Model::CLAUDE_OPUS_5_5,
+                  'maxTokens' => 1024,
                   'messages' => [
                       [
                           'role' => 'user',
@@ -1847,7 +1856,7 @@
                                   'type' => 'document',
                                   'source' => [
                                       'type' => 'base64',
-                                      'media_type' => 'application/pdf',
+                                      'mediaType' => 'application/pdf',
                                       'data' => $pdf_data,
                                   ],
                               ],
@@ -1861,10 +1870,10 @@
               ],
           ],
           [
-              'custom_id' => 'my-second-request',
+              'customID' => 'my-second-request',
               'params' => [
-                  'model' => 'claude-opus-5-5',
-                  'max_tokens' => 1024,
+                  'model' => Model::CLAUDE_OPUS_5_5,
+                  'maxTokens' => 1024,
                   'messages' => [
                       [
                           'role' => 'user',
@@ -1873,7 +1882,7 @@
                                   'type' => 'document',
                                   'source' => [
                                       'type' => 'base64',
-                                      'media_type' => 'application/pdf',
+                                      'mediaType' => 'application/pdf',
                                       'data' => $pdf_data,
                                   ],
                               ],
@@ -1897,7 +1906,7 @@
 
   # Load and encode the PDF
   pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
-  pdf_bytes = URI.open(pdf_url, "rb") { |f| f.read }
+  pdf_bytes = URI.open(pdf_url, "rb", &:read)
   pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines
 
   anthropic = Anthropic::Client.new
@@ -1969,7 +1978,7 @@
 
 <CardGroup cols={2}>
   <Card title="Vision" icon="image" href="https://platform.claude.com/docs/en/build-with-claude/vision">
-    Claude’s vision capabilities allow it to process and analyze images, opening up exciting possibilities for multimodal interaction.
+    Learn how to count an image’s visual tokens and which limitations PDFs share with other vision tasks.
   </Card>
 
   <Card title="Try PDF examples" icon="file" href="https://platform.claude.com/cookbook/multimodal-getting-started-with-vision">