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) andvlm(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
| Field | Type | Description |
|---|---|---|
file | file | Required. The image or PDF to process. |
tier | string | cpu (default, fast/printed) or vlm (premium AI: handwriting, layout, math). |
language | string | auto (default) or a language code (en, ch, ja, ar, …). |
tool | string | Optional tool slug (e.g. summarize-pdf, ask-pdf) to pre-frame the chat for that task. |
Errors & limits
| Code | Meaning |
|---|---|
400 | No file, unsupported type, or file too large. |
401 | Missing or invalid API token. |
402 | Out of pages, daily/monthly free limit reached, or no credits. The body includes used/cap. |
404 | Job UUID not found. |
409 | Download 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
language=auto to detect, or pass a specific code.