OCR.chat API

HTTP 的一项请求将图像或 PDF 转换成干净文本, 标记、 表格和 JSON, 以100+种语言写成。 使用每页, 没有任何惊喜 。

概览

The OCR.chat API is a small REST interface. You POST a file and get back a job with the recognized text and a per-page breakdown (text, bounding boxes, confidence). Jobs of 5 pages or fewer return inline; larger jobs return immediately with a pending status that you poll until done.

  • Base URL: https://ocr.chat
  • Formats in: PNG, JPG, WEBP, GIF, BMP, TIFF, and multi-page PDF
  • Formats out: txt, md, docx, pdf, csv, json
  • Engines: cpu (fast, printed docs) and vlm (premium AI, handwriting, complex layout, math)

验证

Authenticate with your API token (find it on your account page) as a Bearer header:

Authorization: Bearer YOUR_API_TOKEN

You can also pass ?api_token=… as a query parameter. Usage is metered against your account's page balance.

提交文件

POST /api/v1/ocr/, multipart form upload.

curl -X POST https://ocr.chat/api/v1/ocr/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "file=@invoice.pdf" \
  -F "tier=vlm" \
  -F "language=auto"

Returns the job. For ≤5-page files it is already done with the text; larger files come back pending/processing, poll the status endpoint.

{
  "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>/, poll until status is done or failed.

curl https://ocr.chat/api/v1/ocr/9f2c1b7e4a.../ \
  -H "Authorization: Bearer YOUR_API_TOKEN"

下载格式

GET /api/v1/ocr/<uuid>/download/?format=md, export the result. format is one of txt, md, docx, pdf, csv, json.

curl -L "https://ocr.chat/api/v1/ocr/9f2c1b7e4a.../download/?format=docx" \
  -H "Authorization: Bearer YOUR_API_TOKEN" -o result.docx

与文档聊天

询问关于已完成的工作的问题。 答案仅以摘录文本为基础并引用源页。 需要账户标记 — — 聊天功能是记账的。

POST /api/v1/chat/<uuid>/, JSON body {"message": "your question"}.

curl -X POST https://ocr.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, "snippet": "The invoice total is $42…"}]
}}

GET /api/v1/chat/<uuid>/history/, 找工作要全部的谈话记录

守则示例

import requests, time

API = "https://ocr.chat/api/v1/ocr/"
H = {"Authorization": "Bearer YOUR_API_TOKEN"}

# Submit
with open("invoice.pdf", "rb") as f:
    job = requests.post(API, headers=H,
        files={"file": f}, data={"tier": "vlm"}).json()

# Poll until done
while job["status"] in ("pending", "processing"):
    time.sleep(2)
    job = requests.get(API + job["uuid"] + "/", headers=H).json()

print(job["markdown"])

# Download as DOCX
r = requests.get(API + job["uuid"] + "/download/",
                 headers=H, params={"format": "docx"})
open("result.docx", "wb").write(r.content)
import fs from "fs";

const API = "https://ocr.chat/api/v1/ocr/";
const H = { Authorization: "Bearer YOUR_API_TOKEN" };

const form = new FormData();
form.append("file", new Blob([fs.readFileSync("invoice.pdf")]), "invoice.pdf");
form.append("tier", "vlm");

let job = await (await fetch(API, { method: "POST", headers: H, body: form })).json();

while (["pending", "processing"].includes(job.status)) {
  await new Promise(r => setTimeout(r, 2000));
  job = await (await fetch(API + job.uuid + "/", { headers: H })).json();
}
console.log(job.markdown);
# 1. Submit
curl -X POST https://ocr.chat/api/v1/ocr/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "file=@invoice.pdf" -F "tier=vlm"

# 2. Poll  (use the uuid from step 1)
curl https://ocr.chat/api/v1/ocr/UUID/ \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# 3. Download
curl -L "https://ocr.chat/api/v1/ocr/UUID/download/?format=md" \
  -H "Authorization: Bearer YOUR_API_TOKEN" -o result.md

参数

FieldTypeDescription
filefileRequired. The image or PDF to process.
tierstringcpu (default, fast/printed) or vlm (premium AI: handwriting, layout, math).
languagestringauto (default) or a language code (en, ch, ja, ar, …).
toolstringOptional tool slug (e.g. extract-tables, handwriting-to-text) to apply that tool's preset.
translate_tostringFor the translate tool, target language code.

错误和限制

CodeMeaning
400No file, unsupported type, or file too large.
401Missing or invalid API token.
402Out of pages, daily/monthly free limit reached, or no credits. The body includes used/cap.
404Job UUID not found.
409Download requested before the job finished.

Each page processed costs credits (1/page on the fast tier, more on premium). Paid plans raise per-file page caps and add priority. See pricing.

经常问到的问题

Create a free account and open your account page, your token is shown there with a copy button.

Yes, files of 5 pages or fewer return the full result inline in the POST response, so no polling is needed for most images and short PDFs.

Over 100, including Latin, CJK, Arabic, Cyrillic and Indic scripts. Use language=auto to detect, or pass a specific code.

Uploads are processed for OCR and deleted automatically. We never sell, share, or train on your documents.

使用量是每页的计量,以抵消您的账户余额:匿名电话得到每个IP每天津贴,免费账户每月一桶,支付计划使用购买的信用额,每页上限和优先级较高。 使用量为402, 时时用量为402, 时用量在身体上。

您可以通过下载端点格式参数发送 PNG、JPG、WEBP、GIF、BMP、TIFF和多页 PDF。 结果以 txt、 md、 docx、pdf (可搜索)、 csv 或json 格式参数下载 。

400 是指丢失的文件、不支持的类型或太大的文件;401 是指丢失或无效的标牌;402 指页;404 指未知的工作 UUID;409 指任务完成前要求的下载。错误体包括一个短消息。

带有状态、 级别、 语言、 页面数和平均值_ 信任的 工作对象, 加上全文和标记。 页面阵列将每页用文字、 框框( bbox) 和每个街区的可信度拆分成块块 。

使用 cpu (默认) 快速、 低成本的识别清洁打印文件。 使用 vlm, 高级 AI 引擎, 用于笔迹、 复杂或多栏布局、 数学和翻译, 其准确性远高于此 。

带弹片( 例如 抽取表或笔记本到文本) 的传票工具可以应用该工具的调制预设。 对于翻译工具, 也用目标语言代码将翻译器和语言代码连接到 。

POST 响应中返回的5页或以下文件。 更大的文件在等待或处理时立即返回, 并进行测试 Get/ api/ v1/ ocr/<uuid>支付计划提高了每页页上限。

API是HTTPS的普通RET,因此它使用任何语言与 HTTP 客户端(见 Python, Node.js, 和 CIURL 示例) 。 没有SDK 安装; 您需要的只是几行标准的 HTTP 代码。