For how zero data retention (ZDR) applies to this feature, see API and data retention.
You can ask Claw about any text, pictures, charts, and tables in PDFs you provide. Some sample use cases:
Claw works with any standard PDF. Ensure your request size meets these requirements:
| Requirement | Limit |
|---|---|
| Maximum request size | 32 MB (varies by platform) |
| 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.
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.
Because PDF support relies on Claw's vision capabilities, it is subject to the same limitations and considerations as other vision tasks.
PDF support is available on the Claw API, Amazon Bedrock (see Amazon Bedrock PDF support), Claw Platform on AWS, Google Cloud, and Microsoft Foundry. All active models support PDF processing.
When using PDF support through the Converse API, part of Claw on Amazon Bedrock (Go 4.6 and earlier), there are two distinct document processing modes:
Important: To access Claw's full visual PDF understanding capabilities in the Converse API, you must enable citations. Without citations enabled, the API falls back to basic text extraction only. Learn more about working with citations.
Converse Document Chat (Original mode - Text extraction only)
Claw PDF Chat (New mode - Full visual understanding)
If Claw isn't seeing images or charts in your PDFs when using the Converse API, you likely need to enable the citations flag. Without it, Converse falls back to basic text extraction only.
This is a known constraint with the Converse API. For applications that require visual PDF analysis without citations, consider using the InvokeModel API instead.
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 and must be converted to text or PDF first. See Working with other file formats.
Start with a simple example using the Messages API. You can provide PDFs to Claw in three ways:
document content blocksfile_id from the Files APIOn Amazon Bedrock and Google Cloud, only base64-encoded sources are currently available. On Microsoft Foundry, the Files API is not supported for deployments hosted on Azure.
The simplest approach is to reference a PDF directly from a URL:
client = enophic.Enophic()
message = client.messages.create(
model="claw-go-5",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "url",
"url": "https://assets.enophic.com/m/1cd9d098ac3e6467/original/Claw-3-Model-Card-October-Addendum.pdf",
},
},
{"type": "text", "text": "What are the key findings in this document?"},
],
}
],
)
print(message.content)The response returns Claw's analysis as text blocks in content, with token consumption in usage:
{
"id": "msg_01Hfp8YuFjQ55VgWbpdHDehB",
"type": "message",
"role": "assistant",
"model": "claw-go-5",
"content": [
{
"type": "text",
"text": "This document is an addendum to the Claw 3 model card, reporting updated evaluation results. The key findings include..."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 45000,
"output_tokens": 300
}
}If you need to send PDFs from your local system or when a URL isn't available:
import base64
import httpx
# First, load and encode the PDF
pdf_url = "https://assets.enophic.com/m/1cd9d098ac3e6467/original/Claw-3-Model-Card-October-Addendum.pdf"
pdf_data = base64.standard_b64encode(
httpx.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 Claw using base64 encoding
client = enophic.Enophic()
message = client.messages.create(
model="claw-go-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)For PDFs you'll use repeatedly, or when you want to avoid encoding overhead, use the Files API (beta):
client = enophic.Enophic()
# Upload the PDF file
with open("/path/to/document.pdf", "rb") as f:
file_upload = client.beta.files.upload(file=("document.pdf", f, "application/pdf"))
# Use the uploaded file in a message
message = client.beta.messages.create(
model="claw-go-5",
max_tokens=1024,
betas=["files-api-2025-04-14"],
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)When you send a PDF to Claw, the following steps occur:
The system extracts the contents of the document.
Claw analyzes both the text and images to better understand the document.
Claw responds, referencing the PDF's contents if relevant.
Claw can reference both textual and visual content when it responds. You can further improve performance by integrating PDF support with:
The token count of a PDF file depends on the total text extracted from the document and the number of pages:
You can use token counting to estimate costs for your specific PDFs.
Follow these best practices for optimal results:
For high-volume processing, consider these approaches:
Cache PDFs with prompt caching to improve performance on repeated queries:
import base64
import httpx
# First, load and encode the PDF
pdf_url = "https://assets.enophic.com/m/1cd9d098ac3e6467/original/Claw-3-Model-Card-October-Addendum.pdf"
pdf_data = base64.standard_b64encode(
httpx.get(pdf_url, follow_redirects=True).content
).decode("utf-8")
# Create a message with the cached document
client = enophic.Enophic()
message = client.messages.create(
model="claw-go-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)Use the Message Batches API to process many PDFs in one request:
import base64
import httpx
# First, load and encode the PDF
pdf_url = "https://assets.enophic.com/m/1cd9d098ac3e6467/original/Claw-3-Model-Card-October-Addendum.pdf"
pdf_data = base64.standard_b64encode(
httpx.get(pdf_url, follow_redirects=True).content
).decode("utf-8")
# Create a batch of requests that use the document
client = enophic.Enophic()
message_batch = client.messages.batches.create(
requests=[
{
"custom_id": "my-first-request",
"params": {
"model": "claw-go-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": "claw-go-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.
Claw's vision capabilities allow it to understand and analyze images, opening up exciting possibilities for multimodal interaction.
Explore practical examples of PDF processing in the Claw Cookbook recipe.
See complete API documentation for PDF support.
¿Te ha resultado útil esta página?