API PDF.chat
Whakataki i tētahi PDF me te chat me ia mai i tōna ake taupānga — whakautu i ngā pātai me te whiwhi whakautu i te pātaka, i ngā reo 100+. Ka whakawāteatia ia pātaka, kāore he whakamātautau.
Whakamāramatanga
Ko te API PDF.chat he whakawhitinga iti o te REST. Tuatahi koe POST He tuhinga tētahi tuhinga kia whakawātea ai, kia hoki mai ai te mahi me te kupu o te tuhinga me te whakawāteatanga i ia pātaka (tuhi, kāwai whakawhāiti, whakawhirinaki). POST Ka whakamātau te kaituhi ki ngā pātai ki taua mahi, ā, ka whiwhi whakautu i te take i roto i te tuhinga, ko ia e whakahua ana i te pātaka i puta mai ai. pending te tūnga e pā ana ki te pāpāho tae noa ki te done.
- URL taketake:
https://pdf.chat - Ko ngā tuhinga i roto: PDF, tae atu ki te Wā, PowerPoint, kupu, me ngā whakaahua (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat o waho: Ka whakautua ki ngā whakahuapānga me ngā whakahuapātanga o te pātaka; ngā tāruatanga mā te wāhi mutunga o te hītori
- Ka whakamātautia te kupu i waho:
txt,md,docx,pdf,csv,json - Ka pānui te pūkaha:
cpu(tere, ngā tuhinga tātai) mevlm(AI utu, tuhituhi, whakaritenga matatini, pāngarau)
Whakatuhi
Whakamau me tōna Ko te tohu API (Ki te kimia i runga i tōna Te pou ā-kōrero) hei pūmatua Taketake:
Authorization: Bearer YOUR_API_TOKEN
Ka taea hoki e koe te whakawhiti ?api_token=… Hei tohutoro uiui. Ka inetia te whakamahinga ki te taurite i te taumahatanga o te pātaka o tōna pūkete.
Whakahauhau i tētahi tuhinga
POST /api/v1/ocr/, Ka whakarewa te tātai maha.
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"
Ka hoki te mahi. Mō ngā pūranga ≤5-pātaka kua oti te mahi done me te kuputuhi; ka hoki mai ngā faila nui ake pending/processing, te pātai ki te wāhi mutunga o te tūnga.
{
"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 } ] } ]
}
Ka whiwhi hua
GET /api/v1/ocr/<uuid>/, Ka pātata ki te pātai status He done rānei failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
Whakahua i tētahi hanga
GET /api/v1/ocr/<uuid>/download/?format=md, Ka whakawātea te hua. format Ko tētahi o 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 me tētahi tuhinga
E pātai ana ki ngā pātai mo tētahi mahi oti. Ko ngā whakautu e whakatū ana anake i roto i te kupu whakawātea, ā, ka whakahuatia te pātaka pūtake. E hiahiatia ana he tohu kāwanatanga, he āhuahira chat te āhuahira kāwanatanga.
POST /api/v1/chat/<uuid>/, Te tinana 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?"}'
Ka hoki te karere āwhina ki tōna urupare me tētahi rārangi o ngā pātaka i whakahuatia:
{"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/, ki te whiwhi i te whakahua kōrero katoa mō tētahi mahi.
Ko ngā tauira waehere
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
| Taiwhenua | Kāhua | Whakamāramatanga |
|---|---|---|
file | file | E hiahiatia ana. Ko te whakaahua, PDF rānei hei tukatuka. |
tier | string | cpu (whakahaere, tere/whakahitu) vlm (AI utu: tuhituhi, whakaritenga, pāngarau). |
language | string | auto (whakahaere) he waehere reo rānei (en, ch, ja, ar,...). |
tool | string | Ko te utauta utauta kōwhiria (hei tauira. summarize-pdf, ask-pdf) ki te whakatū i te chat mō taua mahi. |
Whakarewa
| Waehere | Ko te tikanga |
|---|---|
400 | Kāore he faila, kāore he momo tautoko, he nui rawa rānei te faila. |
401 | Kua ngaro, kāore rānei i tika te tohu API. |
402 | I waho o ngā pātaka, i tae atu ki te tepe wātea o te rā/mua, kāore rānei i te pūtea. Kei roto i te tinana te āhua used/cap. |
404 | Kāore i kitea te UUID mahi. |
409 | I tonoa te whakahua i mua i te mutunga o te mahi. |
Ko ia pātaka i whakamātauria he utu ā-pūtea (1/pātaka i runga i te taumata tere, nui ake i te utu). Ko ngā mahere utu e whakanui ana i ngā kōpaka pātaka-whakahaere me te tāpiri i te arotahi. Tirohia. Whakataurite.
Ko nga pātai e pā ana
language=auto Hei kite, hei whakawhiti rānei i tētahi waehere tauwhāiti.