Summarize a PDF
POST /api/pdf-summarizeFetch a PDF from a URL, extract its text, and return a concise AI-generated summary - factual, no information added beyond what's in the document. Send POST /api/pdf-summarize with the required field url and pay $0.030 per call over x402 or MPP (there is no free tier). It returns a JSON object with url, pages, wordCount, summary, summaryWordCount and 2 more.
Body: {"url":"https://…/file.pdf","maxWords":200?}. Uses the same OpenAI-compatible gateway as /v1/chat/completions internally; the model that actually served is disclosed in the response.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | yes | Public http(s) URL of a PDF Also accepted as link, uri, href, page. |
maxWords | number | no | Target summary length in words, 50-500 (default 200) |
Example request
curl -i -X POST https://agent402.tools/api/pdf-summarize \
-H "Content-Type: application/json" \
-d '{"url":"https://bitcoin.org/bitcoin.pdf","maxWords":150}'
Without payment this returns HTTP 402 Payment Required with the exact price for pdf-summarize; any x402 v2 or MPP client pays it and retries.
Example response
{
"url": "https://bitcoin.org/bitcoin.pdf",
"pages": 9,
"wordCount": 3604,
"summary": "The paper proposes a peer-to-peer electronic cash system that lets online payments move directly between parties without a financial institution, using a proof-of-work chain as a timestamp server to prevent double-spending…",
"summaryWordCount": 148,
"model": "openai/gpt-4o-mini",
"truncatedInput": false
}
| Field | Type | Always present | In the example |
|---|---|---|---|
url | string | yes | https://bitcoin.org/bitcoin.pdf |
pages | number | yes | 9 |
wordCount | number | yes | 3604 |
summary | string | yes | The paper proposes a peer-to-peer electronic cash system that lets online pay... |
summaryWordCount | number | yes | 148 |
model | string | yes | openai/gpt-4o-mini |
truncatedInput | boolean | yes | false |
From an MCP client
catalog.call {
"slug": "pdf-summarize",
"params": {
"url": "https://bitcoin.org/bitcoin.pdf",
"maxWords": 150
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for pdf-summarize; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
urlis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged: settlement is cancelled when the tool fails.
- Wallet-only: this tool runs a model, so it has no proof-of-work tier. A prepaid card-credits key (
Authorization: Bearer a402_...) also pays it. - Model-backed: the answer is generated by a model, so the same input can produce different wording.
- A
GETorHEADto /api/pdf-summarize returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again.
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/pdf-summarize", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"url": "https://bitcoin.org/bitcoin.pdf",
"maxWords": 150
}),
});
Part of these workflows
Summarize a PDF is one step in this skill pack, each sold as a single call:
- Document brief - Metadata, an AI-written summary, and a preview of the opening pages of a PDF - understand what a document says without reading the whole thing. The catalog's first AI-summarization pack, complementary to document-intel's deterministic format extraction (no AI, no summarization there).
Related tools
PDF to text
POST /api/pdfFetch a PDF from a URL and extract its text content. Returns page count, document info, and the full text (up to 20MB PD…
Images to PDF
POST /api/images-to-pdfCombine PNG/JPEG images into a single PDF, one image per page. Body: {"urls":["https://…/1.png","https://…/2.jpg"]}. Ret…
Extract / split PDF pages
POST /api/pdf-extract-pagesPull a subset of pages into a new PDF (split). Body: {"url":"https://…/file.pdf","pages":"1-3,5"}. Returns the new PDF a…
PDF info
POST /api/pdf-infoInspect a PDF without downloading the whole thing into your model: page count, title, author, subject, creator, producer…
Merge PDFs
POST /api/pdf-mergeCombine several PDFs into one, in order. Body: {"urls":["https://…/a.pdf","https://…/b.pdf"]}. Returns the merged PDF as…
Rotate PDF
POST /api/pdf-rotateRotate pages by 90/180/270°. Body: {"url":"https://…/file.pdf","degrees":90,"pages":"1-3"?}. Omit "pages" to rotate all.…