PDF.chat API
PDF를 업로드하고 자신의 앱에서 그것과 함께 chat. 질문을하고 100 개 이상의 언어로 페이지에 인용 답변을 얻을. 페이지 당 계측, 놀라움이 없습니다.
개요
PDF.chat API는 작은 REST 인터페이스입니다. 먼저 POST 문서를 흡수하고 문서의 텍스트와 페이지별 분석(텍스트, 경계 상자, 신뢰도)을 갖춘 작업을 돌려받습니다. POST 5페이지 이하의 작업은 인라인으로 반환되며, 큰 작업은 즉시 페이지 번호와 함께 반환됩니다. pending 폴링할 때까지의 상태 done.
- 기본 URL:
https://pdf.chat - 문서 형식: PDF, Word, PowerPoint, 텍스트 및 이미지(PNG, JPG, WEBP, GIF, BMP, TIFF)
- Chat 밖으로: 페이지 인용과 함께 답변; 히스토리 엔드포인트를 통해 전사
- 처리된 텍스트 출력:
txt,md,docx,pdf,csv,json - 읽기 엔진:
cpu(빠른, 인쇄 문서) 및vlm(프리미엄 AI, 필기, 복잡한 레이아웃, 수학)
인증
귀하의 로그인 정보로 인증 API 토큰 네가 찾아라 계정 페이지) 베어러 헤더로서:
Authorization: Bearer YOUR_API_TOKEN
당신은 또한 통과 할 수 있습니다 ?api_token=… 사용량은 계정의 페이지 균형에 따라 측정됩니다.
문서 제출하기
POST /api/v1/ocr/, 다중 양식 업로드.
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, 상태 엔드포인트를 폴링합니다.
{
"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>/, 폴링 끝날 때까지 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
완료된 작업에 대한 질문을 던집니다. 답변은 추출된 텍스트에만 기반하고 소스 페이지를 인용합니다. 계정 토큰이 필요합니다. chat 기능은 계정 게이트입니다.
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/, 작업에 대한 전체 대화 기록을 가져옵니다.
코드 예제
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 : 필기, 레이아웃, 수학). |
language | string | auto (기본값) 또는 언어 코드 (en, ch, ja, ar,...). |
tool | string | 옵션으로 제공되는 툴 슬래그(예: summarize-pdf, ask-pdfchat은 chat 시리즈의 첫 번째 프로세서이다. |
오류 및 한계
| 코드 | 의미 |
|---|---|
400 | 파일이 없거나, 지원되지 않는 유형이거나, 파일이 너무 크습니다. |
401 | API 토큰이 누락되었거나 잘못되었습니다. |
402 | 페이지가 부족하거나, 일일/월간 무료 한도에 도달하거나, 크레딧이 없습니다. used/cap. |
404 | 작업 UUID를 찾을 수 없습니다. |
409 | 작업이 끝나기 전에 다운로드 요청. |
처리된 각 페이지는 크레딧을 소모합니다(빠른 계층에서는 페이지당 1개, 프리미엄 계층에서는 더 많습니다). 유료 계획은 파일당 페이지 제한을 높이고 우선 순위를 추가합니다. 가격.
자주 묻는 질문
language=auto 특정한 코드를 감지하거나 전달하기 위해서입니다.