PDF.chat API
PDF සහ chat ඔබේම යෙදුම් වලින් එය සමඟ උඩුගත - ප්රශ්න ඇසීමට හා පිටුව උපුටා පිළිතුරු ලබා, 100+ භාෂා. පිටුවකට මීටර, කිසිදු පුදුම.
දර්ශකය
මෙම PDF.chat API කුඩා REST අතුරුමුහුණත වේ. පළමු ඔබ POST එය ආහාරයට ගැනීමට සහ ලේඛනය පෙළ හා ප්රති-පිටුව බිඳ වැටීම (පෙළ, බෝන්ඩි කොටු, විශ්වාසය) සමග නැවත රැකියාවක් ලබා ගැනීමට ලේඛනයක්. එවිට ඔබ POST ඒ රැකියාව එරෙහිව ප්රශ්න සහ ලේඛනය මත පදනම් වූ පිළිතුරු ලබා, එය පැමිණි පිටුව උපුටා එක් එක්. රැකියා5පිටු හෝ අඩු ආපසු inline; විශාල රැකියා සමග වහාම ආපසු pending ඔබ පෝල් දක්වා බව තත්ත්වය done.
- මූලික URL:
https://pdf.chat - ලේඛන: PDF, මෙන්ම වචනය, පෝර්ට්නොට්, පෙළ, සහ රූප (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat පිටතට: පිටුව උපුටා සමග පිළිතුරු; ඉතිහාසය අවසන් ස්ථානය හරහා පරිවර්තන
- සැකසූ පෙළ පිටතට:
txt,md,docx,pdf,csv,json - කියවීමේ එන්ජින්:
cpu(ඉක්මන්, මුද්රිත ලේඛන) සහvlm(වැඩිම AI, අත්පිටපත්, සංකීර්ණ සැකසුම, ගණිතය)
අවසරදීම
ඔබේ API ටොකන් (ඔබගේ මත එය සොයා ගිණුම් පිටුව) දරන්නා ශීර්ෂකයක් ලෙස:
Authorization: Bearer YOUR_API_TOKEN
ඔයාටත් යන්න පුළුවන් ?api_token=… විමසුම් පරාමිතියක් ලෙස. භාවිතය ඔබේ ගිණුමේ පිටුව ශේෂය එරෙහිව මනින.
ලේඛනයක් ඉදිරිපත් කරන්න
POST /api/v1/ocr/, බහු කොටස් ආකෘතිය උඩුගත.
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"
රැකියාව ආපසු. ≤5-පිටුව ගොනු සඳහා එය දැනටමත් done පෙළ සමග; විශාල ගොනු ආපසු පැමිණ pending/processing, තත්වය අවසාන ස්ථානය පෝල්.
{
"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 } ] } ]
}
ප්රතිඵලයක් ලබාගන්න
GET /api/v1/ocr/<uuid>/, පෝල් තෙක් status යි done හෝ failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
සංයුතිය බාගත කරන්න
GET /api/v1/ocr/<uuid>/download/?format=md, ප්රතිඵලය අපනයනය කරන්න. format එකක් වේ 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 ලේඛනයක් සමග
අවසන් වැඩ ගැන ප්රශ්න අහන්න. පිළිතුරු පමණක් ඉවත් පෙළ පදනම් වන අතර මූලාශ්රය පිටුව උපුටා. ගිණුමක් ටොකන් අවශ්ය, chat විශේෂාංගය ගිණුම්-ගට් වේ.
POST /api/v1/chat/<uuid>/, 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?"}'
එහි පිළිතුර සහ පිටු ලැයිස්තුව උපදේශක පණිවිඩය නැවත:
{"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/, වැඩක් වෙනුවෙන් සම්පූර්ණ සංවාදයේ පිටපතක් ගන්න.
කේත උදාහරණ
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?"}'
පරාමිතීන්
| ක්ෂේත්රය | වර්ගය | විස්තරය |
|---|---|---|
file | file | අවශ්ය වේ. සැකසීමට පිළිඹිබුව හෝ PDF. |
tier | string | cpu (පෙරනිමි, වේගවත්/මුද්රණය) හෝ vlm (වැට් AI: අත්පිටපත්, සැකසුම, ගණිතය). |
language | string | auto (පෙරනිමි) හෝ භාෂා කේතය (en, ch, ja, ar,... |
tool | string | විකල්ප මෙවලම් ස්ලග් (උදා. summarize-pdf, ask-pdf) එම කාර්යය සඳහා chat පෙර-රාමු කිරීමට. |
දෝෂ සහ සීමා
| කේතය | අර්ථය |
|---|---|
400 | ගොනුවක් නැත, සහාය නොදක්වන වර්ගයක් හෝ ගොනුව විශාලයි. |
401 | API ටොකනය අතුරුදහන් හෝ වලංගු නොවේ. |
402 | පිටු පිටතට, දිනපතා / මාසික නිදහස් සීමා ළඟා, හෝ කිසිදු ණය. ශරීරය ඇතුළත් used/cap. |
404 | කාර්යය UUID හමු නොවිනි. |
409 | කාර්යය අවසන් වීමට පෙර බාගත කිරීම ඉල්ලා ඇත. |
එක් එක් පිටුව ක්රියාත්මක වියදම් ණය (1/page වේගවත් ස්ථරය මත, වැඩි වට්ටම් මත). ගෙවීම් සැලසුම් ගොනු පිටුව තොප්පි ඉහළ ගොස් ප්රමුඛතාව එක් කරන්න. බලන්න මිලදී ගැනීම.
නිතර අසන ප්රශ්න
language=auto හඳුනා ගැනීමට, හෝ විශේෂ කේතය සමත්.