API 06 · Vercel + optional worker

PDF Parser

Parses PDFs up to 3 MiB in pure Rust: document metadata, per-page text, and JSON or Markdown output. Parsing runs on an isolated blocking thread with a 25-second limit; malformed files fail safely. Pages with almost no text are flagged as scanned; with `ocr: true`, their embedded JPEG images are sent to the worker for Tesseract OCR.

POST https://dev.itsozy.lol/api/v1/pdf/parse
Vercel + optional worker. Text and metadata extraction run on Vercel. OCR of scanned pages needs the optional worker; without it, `ocr_status` reports worker_unavailable and text pages are still returned.

Authentication

Send Authorization: Bearer ozy_… with an API key that includes the pdf permission (or *). Signed-in dashboard sessions work in the playground. Each call costs 10 units.

Parameters

NameTypeDescription
filemultipart fileoptionalThe PDF (or use data / url)
datastringoptionalBase64 PDF
urlstringoptionalPublic URL of a PDF
formatstringoptionaljson (default) or markdown
max_pagesintegeroptional1-200 (default 50)
ocrbooleanoptionalOCR scanned pages through the worker

Example request

curl -X POST https://dev.itsozy.lol/api/v1/pdf/parse \
  -H "Authorization: Bearer $OZY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", "format": "markdown"}'

Example response (illustrative)

{
  "markdown": "# dummy\n\n## Page 1\n\nDummy PDF file\n\n",
  "metadata": {
    "title": "dummy"
  },
  "ocr_status": "not_needed",
  "page_count": 1,
  "pages_returned": 1,
  "scanned_pages": 0,
  "version": "1.4"
}

Errors

Errors use one envelope: {"error": {"code": "…", "message": "…"}}.

StatusCodeMeaning
422pdf_unprocessableThe file is encrypted, malformed or could not be parsed safely
422pdf_timeoutParsing exceeded 25 seconds
400invalid_inputA parameter is missing or invalid
401unauthorizedNo valid API key or session
403permission_deniedThe key does not include this API's permission
429quota_exceededFree-tier quota reached (20 units/min, 100 units/day)
503database_unavailablePersistent storage is temporarily unavailable

Rate limits

20 units per minute and 100 units per day per account; outbound fetches to the same host are spaced at least one second apart. Exceeding a limit returns 429.