PDF.chat API
PDF dosyasını yükleyin ve kendi uygulamanızdan chat ile birlikte — sorular sorun ve 100'den fazla dilde sayfaya atıfta bulunan cevapları alın. Sayfa başına ölçülür, sürpriz yok.
Genel Bakış
PDF.chat API küçük bir REST arayüzü. POST belgeyi almaya ve belgenin metni ve sayfa başına bir ayrıntı (metn, sınır kutuları, güven) ile bir iş geri almaya çalışın. Sonra POST Bu iş karşısında sorular sorabilir ve her biri çıktığı sayfayı alıntılayarak belgede yer alan cevapları alabilirsiniz. 5 sayfa veya daha az olan işler sıra içinde geri döner; daha büyük işler derhal bir pending Sonuna kadar oyladığınız durum done.
- Temel URL:
https://pdf.chat - Belgeler: PDF, Word, PowerPoint, metin ve resimler (PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat dışarı: sayfa referanslarıyla cevaplar; geçmiş son noktası üzerinden transkriptler
- İşlenmiş metin çıkış:
txt,md,docx,pdf,csv,json - Motorları oku:
cpu(hızlı, basılı belgeler) vevlm(Premium AI, el yazısı, karmaşık düzenleme, matematik)
Kimlik doğrulama
Kullanıcı adı ve şifre ile giriş yapın API token (Bunu bilgisayarınızda bulabilirsiniz) hesap sayfası) bir taşıyıcı başlığı olarak:
Authorization: Bearer YOUR_API_TOKEN
Sen de geçebilirsin. ?api_token=… Soru parametresi olarak. Kullanım hesabınızın sayfa dengesine göre ölçülür.
Belge gönder
POST /api/v1/ocr/, Çok parçalı form yükleme.
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 geri verir. ≤5 sayfalık dosyalar için zaten mevcuttur done metinle birlikte; daha büyük dosyalar geri gelir pending/processing, durum son noktasını sorgula.
{
"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 } ] } ]
}
Sonuç alın
GET /api/v1/ocr/<uuid>/, sorgulama status Bu done ya da failed.
curl https://pdf.chat/api/v1/ocr/9f2c1b7e4a.../ \
-H "Authorization: Bearer YOUR_API_TOKEN"
Bir biçimi indirin
GET /api/v1/ocr/<uuid>/download/?format=md, Sonuç çıkar. format Bunlardan biri. 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 belgeyle.
Bittiğinde bir iş hakkında sorular sor. Cevaplar sadece çıkarılan metin ve kaynak sayfasına dayanır. Bir hesap token'i gerektirir, chat özelliği hesap-kapılıdır.
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?"}'
Yardımcı mesajını cevabı ve alınan sayfaların bir listesiyle birlikte geri döndürür:
{"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ş için konuşmanın tam metnini alacağım.
Kod örnekleri
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?"}'
Parametreler
| Alan | Tipi | Açıklama |
|---|---|---|
file | file | Gerekir. İşlenecek resim veya PDF. |
tier | string | cpu (varsayılan, hızlı/basın) veya vlm (Premium AI: el yazısı, düzenleme, matematik). |
language | string | auto (varsayılan) veya bir dil kodu (en, ch, ja, ar, …). |
tool | string | Opsiyonel araç slug (örn. summarize-pdf, ask-pdfchat'i bu görev için önceden çerçevelemek için. |
Hatalar ve sınırlar
| Kod | Anlam |
|---|---|
400 | Dosya yok, desteklenmeyen tür, veya dosya çok büyük. |
401 | Kayıp veya geçersiz API token. |
402 | Sayfalar bitti, günlük/aylık ücretsiz limite ulaşıldı veya kredi yok. used/cap. |
404 | İş UUID' si bulunamıyor. |
409 | İş tamamlanmadan önce indirme istendi. |
İşlenen her sayfa krediye mal olur (hızlı seviyede sayfa başına 1, premium'da daha fazla). Ücretli planlar dosya başına sayfa sınırını yükseltir ve öncelik ekler. Gör fiyatlandırma.
Sıkça Sorulan Sorular
language=auto Belirli bir kodu tespit etmek veya vermek için.