Documents

百度文档解析unlimited-ocr-parser

Try it

调用百度 Unlimited-OCR API 解析文档,基于 Unlimited-OCR 开源方案的标准化服务,开箱即用免部署,直接返回 Markdown 结构化结果。支持 PDF、Word、PPT、图片等格式,适合复杂表格、多段落、多结构文档解析。触发词:文档解析、Unlimited-OCR、大模型 OCR、Markdown 解析、免部署 OCR、复杂表格、结构化文档。

What it does

调用百度 Unlimited-OCR API 解析文档,基于 Unlimited-OCR 开源方案的标准化服务,开箱即用免部署,直接返回 Markdown 结构化结果。支持 PDF、Word、PPT、图片等格式,适合复杂表格、多段落、多结构文档解析。触发词:文档解析、Unlimited-OCR、大模型 OCR、Markdown 解析、免部署 OCR、复杂表格、结构化文档。

The skill document

百度文档解析(Unlimited-OCR)Skill

基于 Unlimited-OCR 开源方案的标准化 API 服务,无需部署即可调用,直接返回 Markdown 结构化结果。

功能概述

Unlimited-OCR 是基于开源方案打造的文档解析 API,具备:

  • 开箱即用:无需自行部署模型,云端一键调用
  • Markdown 直出:解析结果为 Markdown 结构化文本,内嵌 HTML `` 支持复杂表格(rowspan/colspan、居中、换行)
  • 异步任务架构:提交任务 → 轮询结果,适合批量处理
  • 多格式支持:PDF、Word、PPT、图片等主流格式
  • 长文档友好:单 PDF 最大 500 页

适用场景

当用户需要:

  • 快速将 PDF/图片/Word/PPT 转换为 Markdown
  • 处理含复杂表格(合并单元格、多层表头)的文档
  • 免部署快速集成 OCR 能力
  • 结构化解析长文档

与 PaddleOCR-VL 的区别

特性Unlimited-OCR(本 Skill)PaddleOCR-VL
输出格式Markdown(含 HTML 表格)Markdown + 结构化 JSON(版面/坐标/图片)
版面结构信息不返回细粒度版面返回 24 种版面元素及位置坐标
表格HTML ``(Markdown 内嵌)独立 tables[] 对象,含 cells/matrix
印章/公式/图表专项不专门标注支持 seal/formula/chart 类型识别
计费限时免费按页计费(见对应 Skill)
复杂度简单直接更细粒度、可编程
适用快速 Markdown 转换需要结构化数据/位置信息

API 配置

环境变量(必须)

使用前请设置以下环境变量:

export BAIDU_DOC_AI_API_KEY="your_api_key"
export BAIDU_DOC_AI_SECRET_KEY="your_secret_key"

认证方式

通过 API Key 和 Secret Key 换取 access_token(OAuth 2.0,有效期 30 天)。所有接口请求需以 URL 参数 access_token 携带。

OAuth Token 端点:https://aip.baidubce.com/oauth/2.0/tokengrant_type=client_credentials

支持格式

版式文档:pdf, jpg, jpeg, png, bmp, tif, tiff, ofd(图片最长边不大于 8192px)

流式文档:doc, docx, txt, wps, ppt, pptx

使用方式

python3 scripts/baidu_doc_unlimited_ocr_parser.py --file_data <文件的base64编码> --file_name "test.pdf"
python3 scripts/baidu_doc_unlimited_ocr_parser.py --file_url <文件公网URL> --file_name "test.pdf"

API 接口

Unlimited-OCR 是异步接口,需先调用提交请求接口获取 task_id,再调用获取结果接口轮询结果。

提交请求接口

  • HTTP 方法:POST
  • 请求 URLhttps://aip.baidubce.com/rest/2.0/brain/online/v2/unlimited-ocr-parser/task?access_token={token}
  • Content-Typeapplication/x-www-form-urlencoded

Python 示例

import base64
import os
import requests

API_KEY = "你的API_KEY"
SECRET_KEY = "你的SECRET_KEY"
FILE_PATH = "./test.pdf"


def get_access_token():
    url = "https://aip.baidubce.com/oauth/2.0/token"
    params = {
        "grant_type": "client_credentials",
        "client_id": API_KEY,
        "client_secret": SECRET_KEY,
    }
    return requests.get(url, params=params, timeout=30).json()["access_token"]


def create_task(url, file_path):
    with open(file_path, "rb") as f:
        file_data = base64.b64encode(f.read()).decode()
    data = {
        "file_data": file_data,
        "file_name": os.path.basename(file_path),
    }
    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    return requests.post(url, headers=headers, data=data, timeout=120)


if __name__ == "__main__":
    access_token = get_access_token()
    url = (
        "https://aip.baidubce.com/rest/2.0/brain/online/v2/unlimited-ocr-parser/task"
        f"?access_token={access_token}"
    )
    response = create_task(url, FILE_PATH)
    print(response.json())

成功响应示例:

{
  "error_code": 0,
  "error_msg": "",
  "log_id": "10138598131137362685273505665433",
  "result": { "task_id": "task-3zy9Bg8CHt1M4pPOcX2q5bg28j26801S" }
}

失败响应示例:

{
  "error_code": 282003,
  "error_msg": "missing parameters",
  "log_id": "37507631033585544507983253924141",
  "result": "null"
}

获取结果接口

  • HTTP 方法:POST
  • 请求 URLhttps://aip.baidubce.com/rest/2.0/brain/online/v2/unlimited-ocr-parser/task/query?access_token={token}
  • Content-Typeapplication/x-www-form-urlencoded
  • 请求参数task_id(必填,提交时返回的 task_id)

Python 示例

import requests


def query_task(url, task_id):
    data = {"task_id": task_id}
    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    return requests.post(url, headers=headers, data=data, timeout=60)


access_token = "your_access_token"
url = (
    "https://aip.baidubce.com/rest/2.0/brain/online/v2/unlimited-ocr-parser/task/query"
    f"?access_token={access_token}"
)
print(query_task(url, "task_id").json())

成功响应示例:

{
  "log_id": "23596597899286921761579365582373",
  "error_code": 0,
  "error_msg": "",
  "result": {
    "task_id": "task-UnvGsgbYZp9pS3BZRHn11ifzjNvKzTgf",
    "status": "success",
    "task_error": null,
    "markdown_url": "https://xxxxxxxxxxxxxxxxxxx",
    "parse_result_url": "https://xxxxxxxxxxxxxxxxxxx"
  }
}

失败响应示例:

{
  "log_id": "13665091038742503867108513247608",
  "error_code": "282007",
  "error_msg": "task not exist, please check task id",
  "result": "null"
}

请求参数

文件参数(必选,二选一)

参数必选类型说明
file_data和 file_url 二选一string文件 Base64 编码数据。版式文档:pdf, jpg, jpeg, png, bmp, tif, tiff, ofd(图片最长边不大于 8192px);流式文档:doc, docx, txt, wps, ppt, pptx。图片≤10M,版式文档≤100M,流式文档≤50M,PDF≤500 页。超过 50M 须使用 file_url。优先级:file_data > file_url
file_url和 file_data 二选一string文件数据 URL,长度不超过 1024 字节。请注意关闭 URL 防盗链
file_namestring文件名,请保证文件名后缀正确,例如 "1.pdf"

返回结构

提交请求返回

字段类型说明
log_iduint64唯一的 log id,用于问题定位
error_codeint错误码
error_msgstring错误描述信息
result.task_idstring该请求生成的 task_id

获取结果返回

字段类型说明
log_iduint64唯一的 log id,用于问题定位
error_codeint错误码
error_msgstring错误描述信息
result.task_idstring任务 ID
result.statusstring任务状态:pending(排队中)、running(运行中)、success(成功)、failed(失败)
result.task_errorstring解析报错信息(任务失败、额度耗尽等)
result.markdown_urlstringMarkdown 格式结果链接,有效期 30 天
result.parse_result_urlstringJSON 格式结果 BOS 链接,有效期 30 天

解析结果格式

  • 主输出markdown_url 指向的 Markdown 文件,包含结构化文本;复杂表格以 HTML `` 元素内嵌(支持 rowspan/colspan、居中、换行等样式),可直接渲染。
  • 辅助输出parse_result_url 指向的 JSON 文件(未来能力扩展保留)。

API 特性

异步处理流程

  1. 调用提交请求接口 → 获取 task_id
  2. 通过 task_id 调用获取结果接口轮询
  3. status=success 后从 markdown_url 下载 Markdown 结果

轮询建议

  • 提交请求后 5~10 秒开始轮询
  • 轮询间隔:5 秒
  • 最大轮询时间:300 秒

QPS 限制

  • 提交请求接口:2 QPS
  • 获取结果接口:5 QPS

文件限制

限制项说明
图片大小≤ 10M,最长边 ≤ 8192px
版式文档大小≤ 100M
流式文档大小≤ 50M
PDF 页数≤ 500 页
URL 长度≤ 1024 字节
优先级file_data > file_url

错误处理

常见错误码示例:

错误码说明
282003missing parameters(缺少必要参数)
282007task not exist, please check task id(任务不存在)

完整错误码参见 references/error_codes.md

产品计费与购买方式

接口限时免费。免费额度自动发放:

用户类型免费额度
个人实名认证用户200 页
企业实名认证用户1000 页

登录文字识别控制台自动领取。后续正式定价以官方计费说明为准。

脚本

  • scripts/baidu_doc_unlimited_ocr_parser.py:文档解析主程序,支持命令行快速调用

参考文档

  • references/parameters.md:完整 API 参数与返回结构详解
  • references/error_codes.md:完整错误码参考
  • references/apikey-fetch.md:API Key 配置指南

相关链接

Related skills

调用百度文档解析API解析文档。支持PDF、Word、Excel、PPT、图片等18+格式。提取文本、表格、版面分析、OCR识别及RAG文档分块。当用户需要解析文档、提取文本/表格、分析文档结构、处理扫描件时使用。触发词:文档解析、PDF解析、Word解析、表格提取、OCR、文档分析、提取文本、文档结构、扫描识别。

15 installs

Convert long documents to complete Markdown with Unlimited-OCR. Supports images, scanned PDFs, OFD, Office and text files through Baidu Cloud, plus local image/PDF inference through SGLang or an OpenAI-compatible server. Use for OCR, PDF-to-Markdown, Chinese/CJK text, tables, formulas, reading order, multi-page scans, invoices, reports, papers, and structured document extraction.

2 installs

调用百度PaddleOCR-VL大模型API解析文档。基于PaddleOCR-VL-1.6多模态大模型,支持PDF、Word、PPT、图片等格式,精准识别印刷文本、手写文本、表格、公式、图表、印章等复杂元素,支持100+种语言,可处理不规则布局和长文档跨页解析。触发词:文档解析、VLM解析、大模型OCR、PaddleOCR、多模态文档、手写识别、公式识别、复杂版面。

13 installs

通用文档解析工具,支持PDF、图片、扫描件的结构化信息提取与OCR识别。Use when 需要文件处理、文档转换、格式互转、内容提取时使用。不适用于加密文件破解。适用于独立开发者、企业团队和自动化工作流场景。支持中文交互,无需复杂配置即开即用。输出结果可直接使用,减少二次加工成本。提供结构化输出和错误处理机制。

1 installs

百度智能文档分析(基于百度「智能文档分析」,官网入口:https://ai.baidu.com/tech/nlp/Textanalysis)的 API 调用技能。支持文档抽取、文档解析、文档解析(PaddleOCR-VL)、文档比对、合同审查、文档格式转换等功能。当用户需要:(1) 从文档中提取特定字段信息,(2) 解析文档内容,(3) 比对两份文档差异,(4) 审查合同风险,(5) 转换文档格式时使用此技能。触发词:文档抽取、文档解析、PaddleOCR、文档比对、合同审查、格式转换、智能文档分析、百度智能文档分析、百度文档AI。

17 installs

Install and configure the native Unlimited-OCR plugin for DeepSeek Harness (DSH) from its Settings GUI, using Baidu Cloud or a local SGLang/OpenAI-compatible service. Use for long-document OCR; PDF, OFD, Office, text, and scanned-image to Markdown; tables, formulas, and reading order; or DSH provider, credential, local inference, GUI setup, verification, and troubleshooting.

2 installs