PDF.chat API
Upload yon PDF ak chat ak li soti nan app ou — mande kesyon ak jwenn repons ki cité a paj la, nan 100 + lang. Mèt pa paj, pa gen okenn surpris.
Aperçu
PDF.chat API a se yon ti entèfas REST. An premye ou POST Lè w ap itilize yon dokiman pou w enpòte l, ou ka jwenn yon travay ak tèks dokiman an ak yon dezas pou chak paj (tèks, bokit limit, konfidansyalite). POST Ou ka poze kesyon kont travay la epi jwenn repons ki baze sou dokiman an, chak citation paj li te soti nan. Travay nan 5 paj oswa mwens tounen inline; pi gwo travay tounen imedyatman ak yon pending estati ke ou sondaj jiskaske done.
- URL baz:
https://pdf.chat - Dokiman nan: PDF, plis Word, PowerPoint, tèks, ak imaj (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Out Chat: answers with page citations; transcripts via the history endpoint
- Tèks processé deyò:
txt,md,docx,pdf,csv,json - Motè lekti:
cpu(dokumantasyon rapid, enprime) akvlm(AI prim, ekri an lèt detache, layout komplekse, matematik)
Auth
Authentifier avec votre mot de passe API token (Jwenn li sou sit entènèt ou) Kont) kòm yon entwodiksyon:
Authorization: Bearer YOUR_API_TOKEN
Ou ka tou pase ?api_token=… . Using se mezire kont balans paj kont ou a.
Soumèt yon dokiman
POST /api/v1/ocr/, Enpòte fòm multipart.
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"
Retounen travay la. Pou fichye ≤5- paj li deja fè done ak tèks la; pi gwo dosye yo vini tounen pending/processing, sondaj pwent bout status.
{
"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 } ] } ]
}
Obtenn yon rezilta
GET /api/v1/ocr/<uuid>/, sondaj jiskaske status se done or failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
Telechaje yon fòma
GET /api/v1/ocr/<uuid>/download/?format=md, Eksporte rezilta a. format se youn nan 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 ak yon dokiman
Mande kesyon sou yon travay fini. Repons yo baze sèlman sou tèks ekstraksyon an epi yo site paj sous la. Mande yon kont, karakteristik chat a se kont-gated.
POST /api/v1/chat/<uuid>/, kò JSON {"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?"}'
Retounen mesaj asistan an ak repons li ak yon lis paj ki citée:
{"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/, Fòk ou fèmen fenèt la pou w ka wè konvèsasyon an.
Ekzanp kòd
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?"}'
Paramèt
| Fòma | Tipe | Detay |
|---|---|---|
file | file | Required. imaj la oswa PDF pou pwosesis. |
tier | string | cpu (pa default, rapid/imprime) oswa vlm (AI prim: ekri an lèt detache, layout, matematik). |
language | string | auto (pa default) oswa yon kòd lang (en, ch, ja, ar, …). |
tool | string | Slug zouti optional (e. g. summarize-pdf, ask-pdf) pou pre-frame chat pou sa a travay. |
Erè & limit
| Kòd | Signifikasyon |
|---|---|
400 | Pa gen okenn dosye, kalite pa sipòte, oswa dosye a twò gwo. |
401 | Mank yon token API oswa li pa valid. |
402 | Pa gen paj, limit gratis jounen/menyèl la rive, oswa pa gen kredi. used/cap. |
404 | UUID travay la pa jwenn. |
409 | Enstalasyon |
Tout paj ki trete koute kredi (1/pajè sou nivo rapid, plis sou prim). Plan ki peye ogmante chak paj dosye kap ak ajoute priyorite. Pri.
Kesyon ki poze souvan
language=auto pou deteksyon, oswa pase yon kòd espesifik.