API PDF.chat
Apetraho ao amin'ny fampiharanao manokana ny PDF sy ny chat miaraka aminy — manontany ary mahazo valinteny voalaza ao amin'ny pejy, amin'ny teny 100+.
Fanoritsoritana
Ny API PDF.chat dia mpanera REST kely. Voalohany dia ianao POST tahirin-kevitra iray mba handraisana azy ary hahazo asa amin'ny lahatsoratra ao amin'ilay tahirin-kevitra sy ny fizarazarana isan-pejy (soratra, takelaka manasaraka, fahatokisan-tena). POST ny fanontaniana manoloana ilay asa ary mahazo valinteny mifototra amin'ilay antontan-taratasy, ny tsirairay amin'izy ireny dia milaza ny pejy niaviany. pending toe-javatra izay jerenao mandra- done.
- URL fototra:
https://pdf.chat - Tahirin-kevitra ao amin'ny: PDF, ary koa Word, PowerPoint, lahabolana, ary sary (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat avy: valinteny miaraka amin'ny famintinana pejy; fandikana amin'ny alalan'ny farany amin'ny diary
- Lahabolana notsipihina:
txt,md,docx,pdf,csv,json - Mpikirakira famakiana:
cpu(raharaha haingana, navoaka) aryvlm(AI premium, fanoratana an-tànana, famaritana sarotra, matematika)
Fanamarinana
Mifandraisa amin'ny alalan'ny Token API (hita ao amin'ny pejy kaonty) ho toy ny lohateny Bearer:
Authorization: Bearer YOUR_API_TOKEN
Afaka mandalo ihany koa ianao ?api_token=… toy ny sivana fanontaniana. Mifanaraka amin'ny sandan'ny pejy ao amin'ny kaontinao ny fampiasana.
Hampiditra tahirin-kevitra
POST /api/v1/ocr/, Fandefasana endrika marobe.
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"
Mamaly ny asa. Raha rakitra ≤5-pejy dia efa efa done miaraka amin'ny lahabolana; miverina ireo rakitra lehibe kokoa pending/processing, manontany ny farany farany amin'ny toe-draharaha.
{
"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 } ] } ]
}
Hahazo valiny
GET /api/v1/ocr/<uuid>/, poll until status dia done na failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
Maka lamina iray
GET /api/v1/ocr/<uuid>/download/?format=md, Avy amin'ny format iray amin'ireo 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 miaraka amin'ny tahirin-kevitra iray
Manontany momba ny asa vita. Ny valinteny dia mifototra amin'ny lahabolana voatahiry ihany ary milaza ny pejy loharano. Mila token'ny kaonty io, ny chat dia mifototra amin'ny kaonty.
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?"}'
Mandefa ny hafatra amin'ny mpanampy miaraka amin'ny valinteny sy ny lisitr'ireo pejy voalaza:
{"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/, maka ny dikan-teny feno amin'ny resaka ho an'ny asa iray.
Ohatran'ny soratra
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?"}'
Mpizahaky ny macro
| Field | Karazana | Fanoritsoritana |
|---|---|---|
file | file | Tsy maintsy atao. Ny sary na PDF hosokafana. |
tier | string | cpu (tsotra, haingana/antontana) na vlm (AI premium: fanoratana, famolavolana, matematika). |
language | string | auto (tsotra) na famaha teny (en, ch, ja, ar, …). |
tool | string | Slug-n'ny fitaovana safidy (e.g. summarize-pdf, ask-pdf) to pre-frame the chat for that task. |
Tsy fetezana sy fetra
| Fandrindrana | Ny dikan'ny |
|---|---|
400 | Tsy misy rakitra, karazana tsy raisina an-tànana, na rakitra be loatra. |
401 | Token API tsy misy na tsy mitombina. |
402 | Tsy misy pejy, efa tonga ny fetra isan'andro/isam-bolana, na tsy misy karatra. used/cap. |
404 | Tsy hita ny UUID'ny asa. |
409 | Nahazo fangatahana fampidinana alohan'ny nahavitan'ilay asa. |
Ny pejy tsirairay dia mandoa karatra (1/pejy amin'ny fidirana haingana, bebe kokoa amin'ny premium). Ny fidirana mividy dia mampiakatra ny fetra ho an'ny pejy isaky ny rakitra ary mampiditra ny laharam-pahamehana. Jereo fividianana.
Fanontaniana matetika
language=auto mba hitadiavana, na handefasana kaody manokana.