PDF.chat API
Upload PDF lan chat karo iku saka aplikasi dhewe - takon pitakonan lan njaluk jawaban sing dikutip menyang kaca, ing 100+ basa. Metered saben kaca, ora kaget.
Kaca
PDF.chat API iku antarmuka REST cilik. Sadurungé sampeyan POST Dokumen POST pitakonan kalawan tugas punika lan pikantuk jawaban ingkang dipundasaraken ing dokumen, saben nyathet kaca ingkang dipundamel. tugas5lampiran utawi kirang bali ing baris; tugas ingkang ageng bali langsung kaliyan pending status kang sampeyan poll nganti done.
- URL Dasar:
https://pdf.chat - Dokumen ing: PDF, plus Word, PowerPoint, teks, lan gambar (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat saka: jawaban karo citra halaman; transkripsi liwat titik pungkasan sajarah
- Teks kang diproses:
txt,md,docx,pdf,csv,json - Baca mesin:
cpu(dokumèn cekak, cetak) lanvlm(AI premium, tulisan tangan, tata letak kompleks, matematika)
Keterangan
Otentikasi karo Token API (ngundhuh ing komputermu) kaca akun) minangka bagéan ndhuwur Bearer:
Authorization: Bearer YOUR_API_TOKEN
Sampeyan uga bisa ngetik ?api_token=… minangka parameter pitakonan. Panggunané diukur déning saldo kaca akunmu.
Nyawiji dokumen
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"
Kembalikan tugas. Kanggo file ≤5- kaca iku wis ana done karo teks; file sing luwih gedhé teka manèh 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 } ] } ]
}
Nampilaké asil
GET /api/v1/ocr/<uuid>/, pitakon nganti status iku done utawa failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
Muter-muter format
GET /api/v1/ocr/<uuid>/download/?format=md, Eksport hasil format iku salah siji saka 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 karo dokumen
Takon pitakonan bab tugas kang wis rampung. Jawaban mung didasaraké ing teks kang diekstraksi lan ngutip kaca sumber. Dibutuhaké token akun, fitur chat iku akun-gated.
POST /api/v1/chat/<uuid>/, Jajar {"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?"}'
Kembalikan pesan asisten karo jawabané lan dhaptar kaca sing dikutip:
{"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/, nyekel transkripsi pawarta lengkap kanggo tugas.
Conto kode
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èter
| Lapangan | Tipe | Keterangan |
|---|---|---|
file | file | Diperlukan Gambar utawa PDF kanggo diproses. |
tier | string | cpu (piranti pigura, cepet/dicetak) utawa vlm (Premium AI: tulisan tangan, tata letak, matematika). |
language | string | auto (piranti pigura) utawa kodhe basa (en, ch, ja, ar(Inggris) |
tool | string | Ing basa Jawa, tembung gawéan (e.g. summarize-pdf, ask-pdf) to pre-frame the chat for that task. |
Kesalahan lan wates
| Kode | Arti |
|---|---|
400 | Ora ana file, jinis file ora didhukung, utawa file banget gedhé. |
401 | Kekurangan utawa ora valid API token. |
402 | Luwih saka kaca, watesan gratis saben dina/wulan wis tekan, utawa ora ana kredit. Tubuh kalebu used/cap. |
404 | UUID tugas ora kapanggih. |
409 | Muter- muter dijaluk sadurunge tugas rampung. |
Saben kaca kang diproses regane kredit (1/kaca ing tingkat cepet, luwih ing premium). Rencana bayaran nambahi watesan kaca saben file lan nambahi prioritas. Lihat pricing.
Takon kang asring diajukake
language=auto kanggo ndeteksi, utawa nyedhiyani kode kang spesifik.