PDF.chat API

Upload a PDF and chat with it from your own app — ask questions and get answers cited to the page, in 100+ languages. Metered per page, no surprises.

Overview

The PDF.chat API is a small REST interface. First you POST a document to ingest it and get back a job with the document's text and a per-page breakdown (text, bounding boxes, confidence). Then you POST questions against that job and get answers grounded in the document, each citing the page it came from. Jobs of 5 pages or fewer return inline; larger jobs return immediately with a pending status that you poll until done.

  • Base URL: https://pdf.chat
  • Documents in: PDF, plus Word, PowerPoint, text, and images (PNG, JPG, WEBP, GIF, BMP, TIFF)
  • Chat out: answers with page citations; transcripts via the history endpoint
  • Processed text out: txt, md, docx, pdf, csv, json
  • Reading engines: cpu (fast, printed docs) and vlm (premium AI, handwriting, complex layout, math)

Authentication

Authenticate with your API token (find it on your account page) as a Bearer header:

Authorization: Bearer YOUR_API_TOKEN

You can also pass ?api_token=… as a query parameter. Usage is metered against your account's page balance.

Submit a document

POST /api/v1/ocr/, multipart form upload.

curl -X POST https://pdf.chat/api/v1/ocr/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "file=@invoice.pdf" \
  -F "tier=vlm" \
  -F "language=auto"

Returns the job. For ≤5-page files it is already done with the text; larger files come back pending/processing, poll the status endpoint.

{
  "uuid": "9f2c1b7e4a...",
  "status": "done",
  "tier": "vlm",
  "language": "auto",
  "page_count": 1,
  "mean_confidence": 0.98,
  "text": "INVOICE\nAcme Corp\nTotal: 215.00 USD",
  "markdown": "# INVOICE\n\n**Acme Corp** ...",
  "pages": [ { "index": 0, "text": "...", "blocks": [ { "text": "...", "bbox": [x0,y0,x1,y1], "confidence": 0.98 } ] } ]
}

Get a result

GET /api/v1/ocr/<uuid>/, poll until status is done or failed.

curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Download a format

GET /api/v1/ocr/<uuid>/download/?format=md, export the result. format is one of txt, md, docx, pdf, csv, json.

curl -L "https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../download/?format=docx" \
  -H "Authorization: Bearer YOUR_API_TOKEN" -o result.docx

Chat with a document

Ask questions about a finished job. Answers are grounded only in the extracted text and cite the source page. Requires an account token, the chat feature is account-gated.

POST /api/v1/chat/<uuid>/, JSON body {"message": "your question"}.

curl -X POST https://pdf.chat/api/v1/chat/9f2c1b7e4a.../ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message": "What is the invoice total and due date?"}'

Returns the assistant message with its answer and a list of cited pages:

{"conversation": "a1b2…", "message": {
   "role": "assistant",
   "content": "The total is $42, due on March 3 (p. 1).",
   "citations": [{"page": 1, "cited_text": "The invoice total is $42…", "document_id": "9f2c1b7e4a…"}]
}}

GET /api/v1/chat/<uuid>/history/, fetch the full conversation transcript for a job.

Code examples

import requests, time

BASE = "https://pdf.chat/api/v1"
H = {"Authorization": "Bearer YOUR_API_TOKEN"}

# 1. Upload a PDF
with open("contract.pdf", "rb") as f:
    job = requests.post(BASE + "/ocr/", headers=H, files={"file": f}).json()

# 2. Wait until it's ready to chat
while job["status"] in ("pending", "processing"):
    time.sleep(2)
    job = requests.get(f"{BASE}/ocr/{job['uuid']}/", headers=H).json()

# 3. Ask questions — every answer is cited to the page
ans = requests.post(f"{BASE}/chat/{job['uuid']}/", headers=H,
    json={"message": "What is the termination notice period?"}).json()
print(ans["message"]["content"])
print(ans["message"]["citations"])
import fs from "fs";

const BASE = "https://pdf.chat/api/v1";
const H = { Authorization: "Bearer YOUR_API_TOKEN" };

// 1. Upload a PDF
const form = new FormData();
form.append("file", new Blob([fs.readFileSync("contract.pdf")]), "contract.pdf");
let job = await (await fetch(`${BASE}/ocr/`, { method: "POST", headers: H, body: form })).json();

// 2. Wait until it's ready to chat
while (["pending", "processing"].includes(job.status)) {
  await new Promise(r => setTimeout(r, 2000));
  job = await (await fetch(`${BASE}/ocr/${job.uuid}/`, { headers: H })).json();
}

// 3. Ask questions — every answer is cited to the page
const ans = await (await fetch(`${BASE}/chat/${job.uuid}/`, {
  method: "POST", headers: { ...H, "Content-Type": "application/json" },
  body: JSON.stringify({ message: "What is the termination notice period?" })
})).json();
console.log(ans.message.content, ans.message.citations);
# 1. Upload a PDF
curl -X POST https://pdf.chat/api/v1/ocr/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "file=@contract.pdf"

# 2. Ask questions (use the uuid from step 1) — answers cited to the page
curl -X POST https://pdf.chat/api/v1/chat/UUID/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message": "What is the termination notice period?"}'

Parameters

FieldTypeDescription
filefileRequired. The image or PDF to process.
tierstringcpu (default, fast/printed) or vlm (premium AI: handwriting, layout, math).
languagestringauto (default) or a language code (en, ch, ja, ar, …).
toolstringOptional tool slug (e.g. summarize-pdf, ask-pdf) to pre-frame the chat for that task.

Errors & limits

CodeMeaning
400No file, unsupported type, or file too large.
401Missing or invalid API token.
402Out of pages, daily/monthly free limit reached, or no credits. The body includes used/cap.
404Job UUID not found.
409Download requested before the job finished.

Each page processed costs credits (1/page on the fast tier, more on premium). Paid plans raise per-file page caps and add priority. See pricing.

Frequently asked questions

Create a free account and open your account page, your token is shown there with a copy button.

Yes, files of 5 pages or fewer return the full result inline in the POST response, so no polling is needed for most images and short PDFs.

Over 100, including Latin, CJK, Arabic, Cyrillic and Indic scripts. Use language=auto to detect, or pass a specific code.

Uploads are processed only to answer your questions and deleted automatically. We never sell, share, or train on your documents.

Usage is metered per page against your account balance: anonymous calls get a per-IP daily allowance, free accounts a monthly bucket, and paid plans use purchased credits with higher per-file page caps and priority. When you run out you get a 402 with used and cap in the body.

You can send PNG, JPG, WEBP, GIF, BMP, TIFF, and multi-page PDF. Results download as txt, md, docx, pdf (searchable), csv, or json via the download endpoint's format parameter.

400 is a missing file, unsupported type, or file too large; 401 a missing or invalid token; 402 out of pages; 404 an unknown job UUID; and 409 a download requested before the job finished. Error bodies include a short message.

A job object with status, tier, language, page_count, and mean_confidence, plus the full text and markdown. The pages array breaks each page into blocks with their text, bounding box (bbox), and per-block confidence.

Use cpu (the default) for fast, low-cost recognition of clean printed documents. Use vlm, the premium AI engine, for handwriting, complex or multi-column layouts, math, and translation, where it is far more accurate.

Pass tool with a slug (for example summarize-pdf or ask-pdf) to pre-frame the chat for that task, so the assistant is tuned to summarize or answer questions about the document.

Files of 5 pages or fewer return inline in the POST response. Larger files come back immediately as pending or processing, and you poll GET /api/v1/ocr/<uuid>/ until status is done or failed. Paid plans raise the per-file page cap.

The API is plain REST over HTTPS, so it works from any language with an HTTP client, see the Python, Node.js, and cURL examples above. There is no SDK to install; a few lines of standard HTTP code are all you need.