docs/tools/pdf.md
pdf analyzes one or more PDF documents and returns text. It uses native document input on Anthropic and Google models, and falls back to text/image extraction for every other provider.
The tool registers only when OpenClaw can resolve a PDF-capable model for the agent. Resolution order:
agents.defaults.pdfModel (explicit primary/fallbacks)agents.defaults.imageModel (explicit primary/fallbacks)Every fallback candidate is auth-checked before use, so a configured provider/model only counts if OpenClaw can authenticate that provider for the agent. If no usable model resolves, the pdf tool is not exposed.
Notes:
pdf and pdfs are merged and deduplicated before loading; at least one is required.pages is parsed as 1-based page numbers, deduped, sorted, and clamped to agents.defaults.pdfMaxPages (default 20). A range that matches no in-bounds pages errors before the model call.~ expansion)file:// URLhttp:// and https:// URLmedia://inbound/<id>Other URI schemes (for example ftp://) return details.error = "unsupported_pdf_reference". Remote http(s) URLs are rejected when the tool runs sandboxed. With workspace-only file policy enabled, local paths outside allowed roots are rejected; managed inbound refs and replayed paths under OpenClaw's inbound media store are still allowed.
Used for provider anthropic and google (the only providers that currently declare native PDF document support). Raw PDF bytes go directly to the provider API as a native document/inline-PDF part per file.
Limits:
pages is not supported; if set, the tool throws pages is not supported with native PDF providers.password is not supported; if set, the tool throws password is not supported with native PDF providers. Use a non-native model for encrypted PDFs.Used for every other provider.
agents.defaults.pdfMaxPages, default 20) via the bundled document-extract plugin, which uses the clawpdf package (PDFium WebAssembly) for text and image extraction.200 characters, render the same pages to PNG images. The render budget is 4,000,000 pixels total, shared across all pages needing images (allocated proportionally per remaining page, not per page), so text pages that already have enough text skip rendering entirely.Details:
password parameter.{
agents: {
defaults: {
pdfModel: {
primary: "anthropic/claude-opus-4-6",
fallbacks: ["openai/gpt-5.4-mini"],
},
pdfMaxBytesMb: 10,
pdfMaxPages: 20,
},
},
}
| Key | Default | Meaning |
|---|---|---|
agents.defaults.pdfModel | unset | Explicit primary/fallback PDF models; falls back to imageModel, then the session model. |
agents.defaults.pdfMaxBytesMb | 10 | Per-PDF size cap in MB. |
agents.defaults.pdfMaxPages | 20 | Max pages processed per PDF. |
See Configuration Reference for full field details.
The tool returns text in content[0].text and structured metadata in details.
Common details fields:
model: resolved model ref (provider/model)native: true for native provider mode, false for fallbackattempts: fallback attempts that failed before successPath fields:
details.pdfdetails.pdfs[] with pdf entriesrewrittenFrom| Condition | Result |
|---|---|
| No PDF input | Throws pdf required: provide a path or URL to a PDF document |
| More than 10 PDFs | details.error = "too_many_pdfs" |
| Unsupported reference scheme | details.error = "unsupported_pdf_reference" |
pages with a native provider | Throws pages is not supported with native PDF providers |
password with a native provider | Throws password is not supported with native PDF providers |
Single PDF:
{
"pdf": "/tmp/report.pdf",
"prompt": "Summarize this report in 5 bullets"
}
Multiple PDFs:
{
"pdfs": ["/tmp/q1.pdf", "/tmp/q2.pdf"],
"prompt": "Compare risks and timeline changes across both documents"
}
Page-filtered fallback model:
{
"pdf": "https://example.com/report.pdf",
"pages": "1-3,7",
"model": "openai/gpt-5.4-mini",
"prompt": "Extract only customer-impacting incidents"
}
Encrypted PDF with extraction fallback:
{
"pdf": "/tmp/locked.pdf",
"password": "example-password",
"model": "openai/gpt-5.4-mini",
"prompt": "Summarize this contract"
}