PDF.chat mga artikulo.
I-upload ang isang PDF at chat na may ito mula sa iyong sariling app - magtanong ng mga katanungan at makakuha ng mga sagot na nabanggit sa pahina, sa 100+ wika. Metered bawat pahina, walang sorpresa.
Pangkalahatang-ideya
Ang PDF.chat API ay isang maliit na REST interface. Una mo POST isang dokumento upang ingest ito at makakuha ng bumalik ng isang trabaho sa teksto ng dokumento at isang bawat-page breakdown (text, bounding kahon, kumpiyansa). Pagkatapos ay ikaw POST mga katanungan laban sa trabaho na at makakuha ng mga sagot nakabatay sa lupa sa dokumento, ang bawat pagbibigay ng pahiwatig ng pahina ito ay nagmula sa. Mga trabaho ng5mga pahina o mas kaunti bumalik inline; mas malaki trabaho bumalik kaagad na may isang pending katayuan na iyong poll hanggang done.
- Base URL:
https://pdf.chat - Mga dokumento sa: Ang mga file na ito ay maaaring i-convert sa iba't ibang format tulad ng PNG, JPG, GIF, BMP, TIFF, atbp.
- Chat out ng: sagot na may mga pahina ng mga pangungusap; transcripts sa pamamagitan ng kasaysayan endpoint
- Pinagproseso teksto out:
txt,md,docx,pdf,csv,json - Pagbasa engine:
cpu(mabilis, naka-print na mga dokumento) atvlm(premium AI, pagsulat ng kamay, kumplikadong layout, matematika)
Pag-authenticate
Mag-authenticate gamit ang iyong API token (mahanap ito sa iyong pahina ng account) bilang isang may-ari header:
Authorization: Bearer YOUR_API_TOKEN
Maaari mo ring pumasa ?api_token=… Ang paggamit ay sinusukat laban sa balanse ng pahina ng iyong account.
Mag-submit ng isang dokumento
POST /api/v1/ocr/, multipart form mag-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"
Bumalik ang trabaho. Para sa ≤5-page na mga file ito ay na done sa teksto; mas malalaking mga file bumalik pending/processingAng mga ito ay tinatawag na 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 } ] } ]
}
Kumuha ng isang resulta
GET /api/v1/ocr/<uuid>/, poll hanggang status ay done o failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
I-download ang isang format
GET /api/v1/ocr/<uuid>/download/?format=md, mag-export ng resulta. format ay isa sa mga 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 na may isang dokumento
Magtanong ng mga katanungan tungkol sa isang tapos na trabaho. Ang mga sagot ay nakabatay lamang sa mga na-extract na teksto at banggitin ang source page. Kinakailangan ng isang account token, ang chat tampok ay account-gated.
POST /api/v1/chat/<uuid>/, Ang 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?"}'
Bumalik ang assistant mensahe na may sagot nito at isang listahan ng mga nabanggit na mga pahina:
{"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/, kumuha ng buong transcript ng pag-uusap para sa isang trabaho.
Mga halimbawa ng code
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?"}'
Parameter
| Patlang | Uri | Paglalarawan |
|---|---|---|
file | file | Kinakailangan. Ang imahe o PDF na proseso. |
tier | string | cpu (default, mabilis / naka-print) o vlm (Premium AI: pagsulat ng kamay, layout, matematika). |
language | string | auto (default) o isang code ng wika (en, ch, ja, ar(Ito ay...) |
tool | string | Ang mga ito ay: Ang mga selula ng tao (e.g. summarize-pdf, ask-pdf) to pre-frame the chat for that task. |
Error & limitasyon
| Code | Kahulugan |
|---|---|
400 | Walang file, hindi suportadong uri, o file masyadong malaki. |
401 | Ang mga ito ay hindi nakikita o hindi nakikita ng mata. |
402 | Out ng mga pahina, araw-araw / buwanang libreng limitasyon naabot, o walang credits. Ang katawan ay kasama used/cap. |
404 | Ang trabaho UUID ay hindi natagpuan. |
409 | Download hiniling bago ang trabaho natapos. |
Ang bawat pahina naproseso gastos credits (1 / pahina sa mabilis na tier, higit pa sa premium). Paid plano itaas per-file pahina caps at magdagdag ng prayoridad. Tingnan Pagpepresyo.
Mga madalas itanong na katanungan
language=auto upang matukoy, o pumasa sa isang tiyak na code.