PDF.chat API
ផ្ទុកឡើងជា PDF និង chat ជាមួយវាពីកម្មវិធីផ្ទាល់ខ្លួនរបស់អ្នក - សំណួរនិងទទួលបានចម្លើយដែលបានលើកឡើងទៅទំព័រនេះ, ក្នុង 100 + ភាសា. វាស់តាមទំព័រ, គ្មានការភ្ញាក់ផ្អើល.
ទិដ្ឋភាពទូទៅ
PDF.chat API នេះ គឺជា ចំណុច ប្រទាក់ REST មួយ តិចតួច ។ ដំបូង អ្នក POST ឯកសារមួយដើម្បីញ៉ាំវានិងទទួលបានការងារត្រឡប់មកវិញជាមួយអត្ថបទរបស់ឯកសារនិងការបែកបាក់ក្នុងមួយទំព័រ (អត្ថបទ ប្រអប់កំណត់ព្រំដែន ទំនុកចិត្ត) ។ បន្ទាប់មកអ្នក POST សំណួរប្រឆាំងនឹងការងារនោះនិងទទួលបានចម្លើយដែលផ្អែកលើនៅក្នុងឯកសារ, រៀងរាល់លើកឡើងទំព័រដែលវាមកពី. ការងារនៃ5ទំព័រឬតិចជាងត្រឡប់ inline; ការងារធំជាងនេះត្រឡប់ភ្លាមៗជាមួយ pending ស្ថានភាពដែលអ្នកបោះឆ្នោតរហូតដល់ done.
- URL មូលដ្ឋាន ៖
https://pdf.chat - ឯកសារក្នុង ៖ PDF បន្ថែមទៀតពាក្យ PowerPoint អត្ថបទនិងរូបភាព (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat out: ចម្លើយជាមួយការដកស្រង់ទំព័រ អត្ថបទតាមរយៈចំណុចបញ្ចប់ប្រវត្តិ
- អត្ថបទដែលបានដំណើរការចេញ ៖
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, 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 } ] } ]
}
យកលទ្ធផល
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 ជាមួយឯកសារ
Ask questions about a finished job. Answers are grounded only in the extracted text and cite the source page. Requires an account token, the chat feature is account-gated.
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 | ឧបករណ៍ slug ជម្រើស (ឧ. summarize-pdf, ask-pdf) ដើម្បី មុន ស៊ុម chat សម្រាប់ ភារកិច្ច នោះ ។ |
កំហុស និងដែនកំណត់
| កូដ | អត្ថន័យ |
|---|---|
400 | គ្មានឯកសារ ប្រភេទដែលមិនគាំទ្រ ឬឯកសារធំពេក ។ |
401 | បាត់ ឬមិនត្រឹមត្រូវ API តូកុង ។ |
402 | ចេញនៃទំព័រ, កំណត់ដោយឥតគិតថ្លៃប្រចាំថ្ងៃ / ខែបានឈានដល់, ឬគ្មានឥណទាន. រាងកាយរួមបញ្ចូល used/cap. |
404 | រកមិនឃើញ UUID របស់ការងារ ។ |
409 | បានស្នើការទាញយកមុនពេលការងារបញ្ចប់ ។ |
ទំព័រនីមួយៗដំណើរការចំណាយប្រាក់កក់ (1 / ទំព័រនៅលើជួរលឿន, ច្រើនទៀតលើប្រាក់រង្វាន់) ។ ផែនការបង់ប្រាក់បង្កើនក្បាលទំព័រឯកសារក្នុងមួយនិងបន្ថែមអាទិភាព។ មើល ការកំណត់តម្លៃ.
សំណួរដែលសួរញឹកញាប់
language=auto ដើម្បីរកឃើញ ឬបញ្ជូនកូដជាក់លាក់ ។