PDF.chat API
PDF we chat bilen öz programmaňyzdan ýükläň — soraglar soraň we sahypadan alnan jogaplary alyň, 100+ dillerde. Sahypa üçin ölçeýlen, hiç hili şaşkalar ýok.
_Gözleg
PDF.chat API bir kiçi REST aragatnaşy. Önüm siz POST Bir sened, ony kabul etmek we senediň metin bilen bir işi almak üçin, we her sahypa üçin bir bölüşmek (metin, çäk çuwallary, ynam). Soňra siz POST bu iş bilen soraglar sora we senediň içinden jogaplary al, her biri öz gelen sahypasyny getirip. 5 sahypadan az işler hatda gaýtýar; uly işler derhal bir bilen gaýtýar pending status that you poll until done.
- Base URL:
https://pdf.chat - Senedler PDF, plus Word, PowerPoint, metin we resimler (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat out: page citations with answers; transcripts via the history endpoint
- Metin çykdy:
txt,md,docx,pdf,csv,json - Okap al
cpu(gyzykly, çap edilen senedler) wevlm(premium AI, el ýazgy, mürekkep çyzgy, matematika)
Tanyşlyk
_Gün tertibini tassykla API tokeni (ony öz hasap sahypasy) bir Beriji başlyg:
Authorization: Bearer YOUR_API_TOKEN
Sen hem geçip bilersiň ?api_token=… soragly parametr hökmünde. Ullanyş hasabyň sahypa balansyna görä ölçenilýär.
Bir sened iber
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"
Işleri gaýtalaýar. ≤5-sahypa faýllar üçin ol öňden bar done metn bilen; uly faýllar gaýd eder pending/processing, statusyň ahtaryş nokadyny sora
{
"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 } ] } ]
}
Netijäni al
GET /api/v1/ocr/<uuid>/, sora status _Iňlisçe done ýa-da failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
Bir formaty ýükle
GET /api/v1/ocr/<uuid>/download/?format=md, netijäni eksport et format bir 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 with a document
Bir tamamlanan iş hakda soraglar sora. Soraglar diňe çykarylan metinde esaslanýar we çeşme sahypany getirýär. Bir hasabyň tokeni gerek, chat aýratynlyk hasabyň gaty.
POST /api/v1/chat/<uuid>/, JSON bedeni {"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?"}'
Asist islegini öz jogap bilen we sahypalaryň bir sanawy bilen gaýtar:
{"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/, bir iş üçin doly gürleşig transkriptini al
Kod mysallary
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?"}'
Parametrler
| Faýl | _Täze | _Aýdym |
|---|---|---|
file | file | Mugt Resim ýa-da PDF işlemek üçin. |
tier | string | cpu (öň bellenen, tiz/çap edilen) ýa-da vlm (premium AI: handwriting, layout, mathematics) |
language | string | auto (öň bellenen) ýa-da bir dil ködi (en, ch, ja, ar,...) |
tool | string | Opsional esbap slug (eg summarize-pdf, ask-pdf) bu iş üçin chat-i öňden-fraýmlamak üçin. |
Hatalar we çäkler
| Kod | Manysy |
|---|---|
400 | Faýl ýok, goldanylmaýan görnüş ýa-da faýl gaty uludyr. |
401 | Eksik ýa-da saýlawly API tokeni. |
402 | Sahypalar tapan, gündelik/aýdalyk boşluk çäk ýetdi, ýa-da kreditler ýok. Bedeni içinden al used/cap. |
404 | Iş UUID tapylmady. |
409 | Iş tamamlanmazdan öň ýüklenmek islendi. |
Her bir işlenen sahypa kreditler bahasyny alýan (1/sahypada tiz derejede, has köp premiumde). Ödenilen planlar faýl üçin sahypalary ýokarlandyrýar we öňe sürüjiligi goşýar. Gör price.
Köp soralýan soraglar
language=auto belli bir kody tapmak ýa-da geçirmek üçin