切题与识别(多模态)
更新时间:2026-11-17
接口描述
支持对整页试卷、习题册、作业本等教育场景进行全自动题目切分,并基于多模态大模型能力,准确识别手写、公式、英语等题目内容。可快速接入拍照搜题、题库录入、智能批改等业务场景,显著降低人工录入成本,提升题目处理效率与识别准确率。
题目切分+识别:异步接口,需要先调用提交请求接口获取 task_id ,然后调用获取结果接口进行结果轮询,建议提交请求后 5~10 秒轮询。提交请求接口QPS为2,获取结果接口QPS为10,需将请求参数only_split设置为false。 仅题目切分:同步接口,提交后同步返回切题结果,需将请求参数only_split设置为true。
在线调试
您可以在 示例代码中心 中调试该接口,可进行签名验证、查看在线调用的请求内容和返回结果、示例代码的自动生成。
提交请求接口
请求说明
请求示例
HTTP 方法:POST
请求URL: https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu_vlm/create_task
URL参数:
| 参数 | 值 |
|---|---|
| access_token | 通过API Key和Secret Key获取的access_token,参考“Access Token获取” |
Header如下:
| 参数 | 值 |
|---|---|
| Content-Type | application/json |
Body中放置请求参数,参数详情如下:
请求参数
| 参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
|---|---|---|---|---|
| image | 和 url/pdf_file 三选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过10M,最短边至少15px,最长边最大8192px,支持jpg/jpeg/png/bmp格式优先级:image > url > pdf_file,当image字段存在时,url、pdf_file字段失效 |
| url | 和 image/pdf_file 三选一 | string | - | 图片完整url,url长度不超过1024字节,url对应的图片base64编码后大小不超过10M,最短边至少15px,最长边最大8192px,支持jpg/jpeg/png/bmp格式优先级:image > url > pdf_file,当image字段存在时,url字段失效请注意关闭URL防盗链 |
| pdf_file | 和 image/url 三选一 | string | - | PDF文件,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过10M,最短边至少15px,最长边最大8192px优先级:image > url > pdf_file,当image、url字段存在时,pdf_file字段失效 |
| pdf_file_num | 否 | string | - | 需要识别的PDF文件的对应页码,当 pdf_file 参数有效时,识别传入页码的对应页面内容,若不传入,则默认识别第 1 页 |
| only_split | 否 | bool | true/false | 是否仅进行题目切分,默认不打开,即:false。可选值包括:- true :开启,返回单题位置信息以及题内手写答案位置信息,按照同步方式返回- false:不开启,返回单题位置信息以及题内结构化文本信息,按照异步方式返回 |
| direction | 否 | bool | true/false | 是否对本次请求做方向判断转正,默认 true,开启方向判断 |
| enhance | 否 | bool | true/false | 是否开启矫正增强,默认关闭 |
返回说明
返回参数
| 字段 | 类型 | 说明 |
|---|---|---|
| log_id | uint64 | 唯一的log id,用于问题定位 |
| error_code | int | 错误码 |
| error_msg | string | 错误描述信息 |
| result | dict | 返回的结果列表 |
| + task_id | string | 该请求生成的任务ID,后续使用该task_id获取批改结果 |
返回示例
成功返回示例:
JSON
1{
2 "error_code": "0",
3 "error_msg": "",
4 "result": {
5 "task_id": "1996199501805445169"
6 },
7 "log_id": 1996199501805445169
8}
失败返回示例(详细的错误码说明见API文档-错误码):
JSON
1{
2 "log_id": 1965746008642488944,
3 "error_msg": "image format error",
4 "error_code": 216201
5}
获取结果接口
请求说明
请求示例
HTTP 方法:POST
请求URL: https://aip.baidubce.com/rest/2.0/ocr/v1/paper_cut_edu_vlm/get_result
URL参数:
| 参数 | 值 |
|---|---|
| access_token | 通过API Key和Secret Key获取的access_token,参考“Access Token获取” |
Header如下:
| 参数 | 值 |
|---|---|
| Content-Type | application/json |
Body中放置请求参数,参数详情如下:
请求参数
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| task_id | 是 | string | 发送提交请求时返回的task_id |
返回说明
返回参数
| 字段 | 类型 | 说明 |
|---|---|---|
| log_id | uint64 | 唯一的log id,用于问题定位 |
| error_code | int | 错误码 |
| error_msg | string | 错误描述信息 |
| result | dict | 返回的结果列表 |
| + task_id | string | 任务ID |
| + status | string | 任务状态,- Pending:排队中(err_code=50)- Running:运行中(err_code=60)- Success:成功(err_code=0)- Failed:失败(err_code为具体的报错类型) |
| + enhance_url | string | 矫正后的图片url |
| + qus_result_num | int32 | 识别题目结果数 |
| + qus_result | array[] | 题目识别结果 |
| ++ qus_id | int32 | 题号 |
| ++ location | object | 切题位置信息 |
| +++ qus_location | array[] | 单道题位置信息,按照 [x,y,w,h]方式返回,其中 x,y 为左上顶点坐标 |
| ++ qus_elements | object | 题目元素 |
| +++ qus_words | string | 题目文本信息 |
| +++ qus_media | array[] | 题目图像元素 |
| ++++ qus_medias_type | string | 题目图像元素类型,类型包括image图片、table表格 |
| ++++ qus_media_location | array[] | 题目图像元素位置信息,按照 [x,y,w,h]方式返回,其中 x,y 为左上顶点坐标 |
| +++ subQs | array[] | 子题列表识别结果 |
| ++++ subIdx | int32 | 子题序号 |
| ++++ subTitle | string | 子题标题/题干文本 |
| ++++ subQs_location | array[] | 子题位置信息,按照 [x,y,w,h]方式返回,其中 x,y 为左上顶点坐标 |
| ++++ subQs_medias | array[] | 子题图像元素 |
| +++++ subQs_medias_type | string | 子题图像元素类型,类型包括image图片、table表格 |
| +++++ subQs_media_location | array[] | 子题图像元素位置信息,按照 [x,y,w,h]方式返回,其中 x,y 为左上顶点坐标 |
| ++++ ans | array[] | 手写作答识别结果 |
| +++++ ans_words | string | 手写作答信息 |
| +++++ ans_location | array[] | 手写作答位置信息,按照 [x,y,w,h]方式返回,其中 x,y 为左上顶点坐标 |
| ++++ choices | array[] | 选项文本信息 |
| +++++ choices_label | string | 选项 |
| +++++ choices_text | string | 选项文本信息 |
| +++++ choices_box | array[] | 选项位置信息,按照 [x,y,w,h]方式返回,其中 x,y 为左上顶点坐标 |
返回示例
成功返回示例:
示例一:仅切题场景

JSON
1{
2 "result": {
3 "qus_result": [
4 {
5 "location": {
6 "qus_location": [
7 18.333524703979492,
8 90.99459838867188,
9 615.7298583984375,
10 168.2823486328125
11 ],
12 "ans": [
13 {
14 "ans_location": [
15 227.4356231689453,
16 89.74613189697266,
17 272.8961181640625,
18 132.77159118652344
19 ]
20 }
21 ],
22 "qus_media": []
23 },
24 "qus_id": 1
25 },
26 {
27 "location": {
28 "qus_location": [
29 17.22620964050293,
30 164.92742919921875,
31 610.4304809570312,
32 245.6763916015625
33 ],
34 "ans": [
35 {
36 "ans_location": [
37 291.9205627441406,
38 165.265380859375,
39 334.0531005859375,
40 211.29347229003906
41 ]
42 },
43 {
44 "ans_location": [
45 505.94415283203125,
46 222.3392791748047,
47 540.1765747070312,
48 267.4246520996094
49 ]
50 }
51 ],
52 "qus_media": []
53 },
54 "qus_id": 2
55 },
56 {
57 "location": {
58 "qus_location": [
59 14.562027931213379,
60 220.0788116455078,
61 601.6246948242188,
62 324.49835205078125
63 ],
64 "ans": [],
65 "qus_media": []
66 },
67 "qus_id": 3
68 },
69 {
70 "location": {
71 "qus_location": [
72 10.640499114990234,
73 313.7164001464844,
74 598.6901245117188,
75 391.52789306640625
76 ],
77 "ans": [
78 {
79 "ans_location": [
80 392.86956787109375,
81 305.9491882324219,
82 427.9552001953125,
83 355.39862060546875
84 ]
85 }
86 ],
87 "qus_media": []
88 },
89 "qus_id": 4
90 }
91 ],
92 "qus_result_num": 4
93 },
94 "log_id": 2120819887575267051
95}
示例二:切题识别场景

JSON
1{
2 "error_code": 0,
3 "result": {
4 "task_id": "2120819567607817112",
5 "status": "Success",
6 "qus_result_num": 1,
7 "qus_result": [
8 {
9 "qus_id": 1,
10 "location": {
11 "qus_location": [
12 39.7,
13 20.2,
14 588.7,
15 164
16 ]
17 },
18 "qus_elements": {
19 "qus_words": "2. 一袋奶粉重500克。每天用50克,用了7天,还剩多少克? $5 0 \\times 7 = 3 5 0 (\\mathrm{克})$ $5 0 0 - 3 5 0 = 1 5 0 (\\mathrm{克})$ 答: 还剩150克。",
20 "qus_media": [
21 {
22 "qus_medias_type": "image",
23 "qus_media_location": [
24 535.4,
25 51.2,
26 87.7,
27 64.3
28 ]
29 }
30 ],
31 "subQs": [
32 {
33 "subIdx": 2,
34 "subTitle": "2. 一袋奶粉重500克。每天用50克,用了7天,还剩多少克? $5 0 \\times 7 = 3 5 0 (\\mathrm{克})$ $5 0 0 - 3 5 0 = 1 5 0 (\\mathrm{克})$ 答: 还剩150克。",
35 "subQs_location": [
36 54.4,
37 26.5,
38 489.2,
39 60.8
40 ],
41 "subQs_medias": [],
42 "ans": [
43 {
44 "ans_words": "$5 0 \\times 7 = 3 5 0 (\\mathrm{克})$ $5 0 0 - 3 5 0 = 1 5 0 (\\mathrm{克})$ 答: 还剩150克。",
45 "ans_location": [
46 69.7,
47 80.2,
48 170.7,
49 97.3
50 ]
51 }
52 ],
53 "choices": []
54 }
55 ]
56 }
57 }
58 ]
59 },
60 "error_msg": "success",
61 "log_id": 2120819605985441671
62}
失败返回示例(详细的错误码说明见API文档-错误码):
JSON
1{
2 "log_id": 1965712846932687146,
3 "error_msg": "recognize error",
4 "error_code": 216630
5}
评价此篇文章
