Read a PDF with an API (or MCP)
Turn a PDF into clean text or markdown with a single API call — or a read_pdf tool your AI agent calls directly. Point it at a public URL or send base64 bytes; get back the extracted content, the page count, and a needsOcr flag for scanned documents. It's the other half of Docweave: the same API that generates PDFs now reads them too — priced per document, not per page.
One call: PDF → markdown
curl https://docweave.dev/api/v1/read \
-H "Authorization: Bearer dw_live_your_key" \
-H "Content-Type: application/json" \
-d '{
"source": { "type": "url", "url": "https://example.com/invoice.pdf" },
"options": { "format": "markdown" }
}'You get back:
{
"result": {
"content": "# Invoice INV-042\n\nBilled to: Acme Corp\n\nTotal: $1,280.00",
"format": "markdown",
"pageCount": 1,
"hasTextLayer": true,
"needsOcr": false
}
}What you can build
Feed documents to a RAG pipeline
Convert PDFs to clean markdown before chunking and embedding. Better structure in means fewer garbled chunks and more accurate retrieval out.
Extract invoices, receipts & contracts
Read an uploaded document's text, then let your model pull the fields you need — no bespoke parser to maintain.
Give an AI agent document I/O
With the MCP server your agent gets read_pdf next to generate_pdf — one tool to read a document, one to write one, both priced per document.
Read PDFs from your AI agent
Add the Docweave MCP server and your agent gets read_pdf alongside generate_pdf — the document I/O layer for agents: one tool to read a document, one to write one. See the docs for the full API.
FAQ
How do I read a PDF into text or markdown via an API?
POST to /api/v1/read with a source that is a public URL or base64 PDF bytes and an optional format (markdown or text). Docweave returns the extracted content, the page count, and a needsOcr flag. It's the mirror of the generate_pdf endpoint, priced per document.
What happens with a scanned (image-only) PDF?
Native extraction reads a PDF's embedded text layer. A scanned PDF has no text layer, so instead of returning empty or garbled text, Docweave returns needsOcr: true so your agent knows OCR is required rather than trusting bad output. An OCR tier is on the roadmap.
Can an AI agent read PDFs directly?
Yes. Add the Docweave MCP server (npx @docweave/mcp or the hosted endpoint) and your agent gets a read_pdf tool it can call with a URL or base64 — one tool call instead of HTTP plumbing, alongside generate_pdf for writing documents.
Is reading a URL safe?
Reading an arbitrary URL is an SSRF primitive, so Docweave guards it: the target is validated, redirects are re-checked on every hop, and only real PDFs (verified by their %PDF- header) are processed. base64 input is fetch-free and safe by construction.
Read and write PDFs from one API. Free to start — 50 documents/month, no card.
Get an API key