x402_pdf_extract
Extract text content from PDF documents via URL using PyMuPDF. Handles multi-page PDFs and returns extracted text, page count, and metadata with automatic USDC micropayments.
Instructions
Extract text content from a PDF document via URL. Price: $0.01 USDC per extraction.
Uses PyMuPDF for fast text extraction. Handles multi-page PDFs. Without X402_PRIVATE_KEY, only the free test endpoint is available.
Returns: extracted text, page count, and metadata.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pdf_url | Yes | URL of the PDF to extract text from |
Implementation Reference
- src/index.ts:317-354 (handler)The implementation of the `x402_pdf_extract` tool handler, which utilizes the `apiPost` helper to communicate with the PDF extraction API.
// ─── Tool: x402_pdf_extract ───────────────────────────────────────────────── server.tool( "x402_pdf_extract", `Extract text content from a PDF document via URL. Price: $0.01 USDC per extraction. Uses PyMuPDF for fast text extraction. Handles multi-page PDFs. Without X402_PRIVATE_KEY, only the free test endpoint is available. Returns: extracted text, page count, and metadata.`, { pdf_url: z.string().url().describe("URL of the PDF to extract text from"), }, async (params) => { const base = APIS.pdf.baseUrl; try { const usePaid = !!PRIVATE_KEY; const endpoint = usePaid ? "/extract" : "/test/extract"; const data = await apiPost( base, endpoint, { url: params.pdf_url }, usePaid ); return textResult({ mode: usePaid ? "paid" : "free_test", cost: usePaid ? "$0.01" : "free", ...data, }); } catch (err: any) { return errorResult(err.message); } } );