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) ary vlm (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

FieldKarazanaFanoritsoritana
filefileTsy maintsy atao. Ny sary na PDF hosokafana.
tierstringcpu (tsotra, haingana/antontana) na vlm (AI premium: fanoratana, famolavolana, matematika).
languagestringauto (tsotra) na famaha teny (en, ch, ja, ar, …).
toolstringSlug-n'ny fitaovana safidy (e.g. summarize-pdf, ask-pdf) to pre-frame the chat for that task.

Tsy fetezana sy fetra

FandrindranaNy dikan'ny
400Tsy misy rakitra, karazana tsy raisina an-tànana, na rakitra be loatra.
401Token API tsy misy na tsy mitombina.
402Tsy misy pejy, efa tonga ny fetra isan'andro/isam-bolana, na tsy misy karatra. used/cap.
404Tsy hita ny UUID'ny asa.
409Nahazo 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

Mamorona kaonty maimaimpoana ary manokatra ny pejy kaonty, ny token-nao dia miseho eo amin'ny tsindry "Adikao".

Eny, ny raki-pahalalana 5 pejy na latsaka dia manolotra ny voka-drakitra feno ao anatin'ny valin'ny POST, ka tsy mila fanadihadiana ny ankamaroan'ny sary sy ny PDF fohy.

Maherin'ny 100, anisan'izany ny soratra latina, CJK, Arabo, Sirilika ary Indiana. language=auto mba hitadiavana, na handefasana kaody manokana.

Tsy misy mivarotra, mizara na mampianatra ny tahirin-kevitrao izahay.

Ny fampiasana dia mitombo arakaraka ny pejy amin'ny alalan'ny tahirin'ny kaontinao: mahazo alalana isan'andro isaky ny IP ny antso tsy fantatra anarana, mahazo isaky ny volana ny kaonty maimaimpoana, ary mampiasa ny karatra mividy amin'ny fetra ambony kokoa sy ny laharam-pahamehana amin'ny pejy isaky ny rakitra ny kaonty mividy. Raha tsy ampy ny kaontinao dia mahazo 402 miaraka amin'ny ampiasaina sy ny fetra ao amin'ny vatana ianao.

Azonao alefa amin'ny endrika PNG, JPG, WEBP, GIF, BMP, TIFF, ary PDF maro pejy ny valiny. Afaka alefa amin'ny endrika txt, md, docx, pdf (azo karohina), csv, na json amin'ny alalan'ny lamin'ny farany amin'ny fidinana ny valiny.

400 dia rakitra tsy hita, karazana tsy raisina an-tànana, na rakitra lehibe loatra; 401 dia marika tsy hita na tsy mety ampiasaina; 402 dia tsy misy pejy; 404 dia UUID tsy fantatra ho an'ny asa; ary 409 dia fangatahana fampidinana natao talohan'ny nanombohan'ny asa. Misy hafatra fohy ao anatin'ny vatana tsy fetezana.

Zavatra iray misy ny toe-draharaha, ny ambaratonga, ny teny, ny page_count, ary ny mean_confidence, ary ny lahabolana feno sy ny markdown. Mizara ho vondrona misy ny lahabolana, ny takila voafaritra (bbox), ary ny fitoniana isan-tokony ny pejy tsirairay ny filaharan'ny pejy.

Ampiasao ny cpu (tsotra) ho an'ny fanamarinana haingana sy mora ny tahirin-kevitra an-tsoratra. Ampiasao ny vlm, ilay milina AI premium, ho an'ny fanoratana an-tànana, ny famolavolana sarotra na maro fariana, ny matematika, ary ny fandikàna teny, izay tena mety kokoa amin'izany.

Pass tool with a slug (for example summarize-pdf or ask-pdf) to pre-frame the chat for that task, so the assistant is tuned to summarize or answer questions about the document.

Miverina anatin'ny filaharan'ny valin'ny POST ireo rakitra manana pejy 5 na latsaka. Miverina avy hatrany ho toy ny miandry na miasa ireo rakitra lehibe kokoa, ary mandefa antso GET /api/v1/ocr/ ianao<uuid>/ mandra-pahatongan'ny zava-misy vita na tsy nahomby. Mampita ny fetra ho an'ny pejy isaky ny rakitra ny drafitra mividy.

REST tsotra amin'ny HTTPS ny API, ka miasa amin'ny teny rehetra miaraka amin'ny mpivatsy HTTP izy, jereo ny ohatra Python, Node.js, ary cURL etsy ambony. Tsy misy SDK azo apetraka; andalana vitsy amin'ny kaody HTTP mahazatra no ilainao.