PDF.chat API
Layisha phezulu iPDF kunye ne-chat nayo ukusuka kwi-app yakho — buza imibuzo kwaye ufumane izimpendulo ezichazwe kwiphepha, kwiilwimi ezingaphezu kwe-100. I-Metered kwiphepha ngalinye, akukho mngeni.
Iinkcukacha
I-PDF.chat API yindawo yothungelwano encinci ye-REST. POST uluhlu lweendawo ezifanelekileyo zokufaka i-imeyili. Umzekelo, ukuba ufaka i-imeyili kwi-imeyili ye-imeyili, POST Imisebenzi yephepha eli-5 okanye elincinci libuyela umva pending inkqubo ye- done.
- Isiseko se URL:
https://pdf.chat - Uxwebhu PDF, kunye ne-Word, i-PowerPoint, umbhalo, kunye nemifanekiso (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat ngaphandle: Iinkcukacha ze-imeyili ezifunyenwe
- Umbhalo oqhubekekayo ngaphandle:
txt,md,docx,pdf,csv,json - Iinjini zokufunda:
cpu(i-documents ekhawulezayo, eshicilelweyo)vlm(AI ephezulu, ukubhala ngesandla, ubeko olunzima, i-mathematics)
Uqinisekiso
Uqinisekiso I-API token (ifumaneke kwi-intanethi Iphepha le-akhawunti) njengesihloko soMthumeli:
Authorization: Bearer YOUR_API_TOKEN
Uyakwazi ?api_token=… njenge parameter yombuzo. Ukusetyenziswa kuqikelelwa kuthelekiswa nokungalingani kwephepha le-akhawunti yakho.
Uxwebhu olutsha
POST /api/v1/ocr/, i-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"
Ibuyisela umsebenzi. Iifayile zephepha ≤5 sele zikhona done Iifayile ezingaphezulu pending/processing, umbuzo kwimeko yendawo yesiphelo.
{
"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 } ] } ]
}
Fumana isiphumo
GET /api/v1/ocr/<uuid>/, i-poll status i-% 1 done okanye failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
Layisha ezantsi ifomati
GET /api/v1/ocr/<uuid>/download/?format=md, I-Excel format i-100% 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 ngoxwebhu
Buza imibuzo malunga nomsebenzi ogqityiweyo. Iimpendulo zibekwe kuphela kumbhalo okhuphiweyo kwaye zibhale iphepha lomthombo. Ifuna ikhadi letyala, i chat uphawu luyi akhawunti- ekhuselweyo.
POST /api/v1/chat/<uuid>/, Isiqu se-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?"}'
Ibuyisela umyalezo womncedisi nge impendulo yayo noluhlu lwamaphepha acatshulwa:
{"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/, i-%s
Iimizekelo zekhowudi
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?"}'
Iiparamitha
| Iindawo | Udidi | Iinketho ze projekti |
|---|---|---|
file | file | Ifunekayo. Umfanekiso okanye i-PDF ekufuneka iqhubekekiwe. |
tier | string | cpu (elingagqibekanga, elikhawulezayo/elishicilelwe) okanye vlm (AI ephezulu: ukubhala ngesandla, ubeko, i-matematics). |
language | string | auto (emiselweyo) okanye ikhowudi yeelwimi (en, ch, ja, ar, …). |
tool | string | Isixhobo esikhethiweyo esingenakukhethwa (umzekelo. summarize-pdf, ask-pdf) ukulungiselela ngaphambili i-chat kulo msebenzi. |
Imposiso & Umda
| Ikhowudi | Ithetha ntoni |
|---|---|
400 | Akukho fayili, uhlobo olungenaxhaswa, okanye ifayile enkulu kakhulu. |
401 | I-API elahlekile okanye engasebenziyo. |
402 | Iphepha eliphumayo, umda wosuku/wenyanga okhululekileyo ufikelelwe, okanye akukho tyala. Isiqu siquka used/cap. |
404 | Umsebenzi we UUID awufumanekanga. |
409 | Layishela phantsi egronjiweyo phambi komsebenzi ugqibile. |
Iphepha ngalinye eliqhubekekayo libiza i-credits (1/page kwinqanaba elikhawulezayo, ngaphezulu kwipremiyamu). Iinkqubo ezihlawulwayo zinyusa i-file nganye iphepha lokugqitha i-inshurensi.
Imibuzo ebuza rhoqo
language=auto ukuchonga, okanye ukudlulisa ikhowudi ekhethekileyo.