Extract text from PDFs for your LLM/RAG pipeline with one HTTP call

2026-10-15来源 dev.to PythonEnglish

Most RAG tutorials skip the boring part: getting clean text out of PDFs on a server with no native dependencies. DocKit does it over HTTP. You pass a URL or upload the file, and you get the text back, page by page.

From a URL

import requests H = {"X-RapidAPI-Key": KEY, "X-RapidAPI-Host": "dockit-pdf-text-extraction-markdown-to-pdf.p.rapidapi.com"} r = requests.get("https://dockit-pdf-text-extraction-markdown-to-pdf.p.rapidapi.com/pdf/text", params={"url": "https://example.com/report.pdf"}, headers=H) data = r.json() chunks = data["page_texts"] # one string per page, ready for chunking + embeddings print(data["pages"], data["words"]) 

Upload a file

requests.post(".../pdf/text", headers=H, files={"file": open("invoice.pdf", "rb")}) 

The other direction: Markdown → PDF

pdf = requests.post(".../markdown-to-pdf", headers=H, json={"text": "# Invoice\n\n**Total:** £120", "title": "Invoice"}).content open("invoice.pdf", "wb").write(pdf) 

Handy for invoices, reports and exporting LLM output. Add ?format=base64 to get JSON instead of bytes.

Limits: 10 MB per PDF, 200 pages. Free tier: 100 calls/month. DocKit on RapidAPI

原文:https://www.a8q9.cn/en/article/extract-text-from-pdfs-for-your-llm-rag-pipeline-with-one-http-call-d02899.html

相关文章