PDF.chat API ကို
PDF ကို upload လုပ်ပါနှင့် chat သင့်ရဲ့ကိုယ်ပိုင် app မှအတူ — မေးခွန်းများကိုမေးမြန်းနှင့်စာမျက်နှာကိုဆိုလိုအဖြေတွေရ, 100+ ဘာသာစကားများ. စာမျက်နှာတစ်မျက်နှာတိုင်း Metered, အံ့သြစရာမရှိ.
အကျဉ်းချုပ်
အဆိုပါ PDF.chat API ကိုသေးငယ်တဲ့ REST interface ကိုဖြစ်ပါသည်. ပထမဦးဆုံးသင် POST ဒါဟာ ingest ဖို့စာရွက်စာတမ်းတစ်ခုနှင့်စာရွက်စာတမ်း၏စာသားနှင့်တစ်ဦးတစ်ဦးစာမျက်နှာခွဲဝေမှုနှင့်အတူအလုပ်ပြန်ရဖို့ (စာသား, bounding box တွေကို, ယုံကြည်မှု) ။ ထိုအခါသင် POST ထိုအလုပ်အကိုင်နှင့်ဆန့်ကျင်မေးခွန်းများကိုနှင့်စာရွက်စာတမ်းတွင်အခြေခံအဖြေများကိုရယူပါ, တစ်ခုချင်းစီကိုကလာတဲ့စာမျက်နှာကိုဆိုလို. အလုပ်အကိုင်များ5စာမျက်နှာများသို့မဟုတ်နည်းပါး inline ပြန်လာ; အကြီးစားအလုပ်အကိုင်များတစ်ဦးနှင့်အတူချက်ချင်းပြန်လာ pending အထိသင် poll ကြောင်း status ကို done.
- အခြေခံ URL:
https://pdf.chat - ဖိုင်များ အတွင်း: PDF, ပေါင်းစပ်စကားလုံး, PowerPoint ကို, စာသား, နှင့်ပုံရိပ်များ (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat ထွက်: စာမျက်နှာ quotes များနှင့်အတူအဖြေများ; သမိုင်း endpoint ကိုမှတဆင့် transcripts
- စာသားထုတ်ယူမှု
txt,md,docx,pdf,csv,json - ဖတ်ရှုခြင်းအင်ဂျင်များ:
cpu(မြန်, ပုံနှိပ်စာရွက်စာတမ်းများ) နှင့်vlm(ပရီမီယံ AI, လက်ရေး, ခက်ခဲ layout ကို, သင်္ချာ)
အသိအမှတ်ပြုခြင်း
သင့်ရဲ့ API တန်ဖိုး (သင့်ရဲ့ပေါ်တွင်ရှာဖွေတွေ့ရှိ အကောင့်စာမျက်နှာ) တစ်ဦး Bearer header ကိုအဖြစ်:
Authorization: Bearer YOUR_API_TOKEN
သင်လည်းပေးပို့နိုင်ပါတယ် ?api_token=… query parameter ကိုအဖြစ်. အသုံးပြုမှုသင့်ရဲ့အကောင့်ရဲ့စာမျက်နှာအရင်းအမြစ်ကိုဆန့်ကျင် metered ဖြစ်ပါတယ်။
ဖိုင်တစ်ခုတင်သွင်းပါ
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"
အလုပ်ပြန်လာ. ≤5-စာမျက်နှာဖိုင်များကိုများအတွက်ဒါဟာအရင်ကပဲဖြစ်ပါတယ် done စာသားနှင့်အတူ; ကြီးမားတဲ့ဖိုင်တွေပြန်လာ pending/processing, အခြေအနေ endpoint ကို poll ။
{
"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>/, poll အထိ 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 စာရွက်စာတမ်းနှင့်အတူ
ပြီးဆုံးအလုပ်အကြောင်းမေးခွန်းများကိုမေး. အဖြေများ extracted စာသားထဲမှာသာအခြေခံပြီးရင်းမြစ်စာမျက်နှာကိုဆိုလိုသည်. တစ်ဦးအကောင့်ကို token ကိုလိုအပ်ပါတယ်, အဆိုပါ chat feature ကိုအကောင့်-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/, အလုပ်တစ်ခုအတွက်အပြည့်အဝစကားပြော transcript ကို fetch ။
ကဒ်ဥပမာများ
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: လက်ရေး, layout ကို, သင်္ချာ). |
language | string | auto (စံ) သို့မဟုတ်ဘာသာစကားကုဒ် (en, ch, ja, ar,...) |
tool | string | ရွေးချယ်စရာ tool ကို slug (ဥပမာ။ summarize-pdf, ask-pdf) ထိုလုပ်ငန်းစဉ်အတွက် chat ကို pre-frame ကို။ |
အမှားများ နှင့် ကနဦး သတ်မှတ်ချက်များ
| ကုဒ် | အဓိပ္ပါယ် |
|---|---|
400 | ဖိုင်မရှိ၊ ထောက်ခံမှုမရှိသော အမျိုးအစား၊ သို့မဟုတ် ဖိုင်အကြီးကြီး |
401 | API token မပါ၊ မမှန် |
402 | စာမျက်နှာများအပြင်, တစ်နေ့လျှင် / လစဉ်အခမဲ့အကနဦးရောက်ရှိ, သို့မဟုတ်မရှိ credits. used/cap. |
404 | အလုပ် UUID ကိုမတွေ့ပါ |
409 | အလုပ်ပြီးဆုံးမတိုင်မီ ဒေါင်းလုပ်လုပ်ရန် တောင်းဆိုသည် |
တစ်ခုချင်းစီကိုစာမျက်နှာကိုခရက်ဒစ်ကုန်ကျစရိတ်များစီမံခန့်ခွဲ (1/page ကိုမြန်နှုန်းမြင့်တန်းအပေါ်, ပရီမီယံအပေါ်ပိုပြီး). ပေးချေပရောဂျက်များ per-file ကိုစာမျက်နှာခေါင်းလောင်းများတက်နှင့်အလိုအလျောက် add. See ဈေးနှုန်း.
မေးလေ့ရှိသောမေးခွန်းများ
language=auto ရှာဖွေတွေ့ရှိရန်, သို့မဟုတ်အထူးကုဒ်ကိုပေးပို့.