Template service prediction supports custom KV templates and custom table templates.
Try it now
Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.
Test
RAM authorization
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| TaskId |
integer |
Yes |
The task ID. |
1 |
| Content |
string |
No |
The URL of the image or PDF file. |
https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/demo.png |
| BinaryToText |
boolean |
No |
Set this parameter to |
false:表示content传入的是url true:表示body是直接传入图片进行base64的内容 |
| Body |
string |
No |
The base64-encoded content of the image or PDF file. |
data:image/png;base64,xxxxx |
You can use either the content or body parameter, but not both. Provide the image URL in content, or the base64-encoded content in body and set BinaryToText to true.
PDF files are limited to 20 MB and 10 pages. Except for the long document prediction model, all other prediction services process only the first page.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The top-level response object. |
||
| RequestId |
string |
The unique identifier for the request. |
F25FBAB4-665A-5D85-8AEF-39AE29F7D588 |
| Data |
object |
The returned business data. |
{ "score": 0.9091, "data": [ { "prob": 1, "fieldName": "姓名", "fieldWordRaw": "方大呆", "wordInfo": [ { "prob": 0.9899999999999999, "location": [ { "x": 119, "y": 48 }, { "x": 199, "y": 48 }, { "x": 199, "y": 69 }, { "x": 119, "y": 69 } ], "word": "方大呆", "charInfo": [ { "prob": 0.99, "location": [ { "x": 119, "y": 48 }, { "x": 142, "y": 48 }, { "x": 142, "y": 67 }, { "x": 119, "y": 67 } ], "word": "方" }, { "prob": 0.99, "location": [ { "x": 142, "y": 48 }, { "x": 165, "y": 48 }, { "x": 165, "y": 67 }, { "x": 142, "y": 67 } ], "word": "大" }, { "prob": 0.99, "location": [ { "x": 167, "y": 48 }, { "x": 197, "y": 48 }, { "x": 197, "y": 67 }, { "x": 167, "y": 67 } ], "word": "呆" } ] } ], "location": [ { "x": 119, "y": 48 }, { "x": 199, "y": 48 }, { "x": 199, "y": 69 }, { "x": 119, "y": 69 } ], "fieldWord": "方大呆" }, { "prob": 1, "fieldName": "性别", "fieldWordRaw": "男", "wordInfo": [ { "prob": 0.99, "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "word": "男", "charInfo": [ { "prob": 0.99, "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "word": "男" } ] } ], "location": [ { "x": 117, "y": 93 }, { "x": 142, "y": 93 }, { "x": 142, "y": 112 }, { "x": 117, "y": 112 } ], "fieldWord": "男" }, { "prob": 1, "fieldName": "身份证号", "fieldWordRaw": "310101********3222", "wordInfo": [ { "prob": 0.9899999999999998, "location": [ { "x": 206, "y": 301 }, { "x": 518, "y": 301 }, { "x": 518, "y": 320 }, { "x": 206, "y": 320 } ], "word": "310101198610203222", "charInfo": [ { "prob": 0.99, "location": [ { "x": 206, "y": 302 }, { "x": 223, "y": 302 }, { "x": 223, "y": 319 }, { "x": 206, "y": 319 } ], "word": "3" }, { "prob": 0.99, "location": [ { "x": 223, "y": 302 }, { "x": 238, "y": 302 }, { "x": 238, "y": 319 }, { "x": 223, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 240, "y": 302 }, { "x": 255, "y": 302 }, { "x": 255, "y": 319 }, { "x": 240, "y": 319 } ], "word": "0" }, { "prob": 0.99, "location": [ { "x": 259, "y": 302 }, { "x": 274, "y": 302 }, { "x": 274, "y": 319 }, { "x": 259, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 276, "y": 302 }, { "x": 291, "y": 302 }, { "x": 291, "y": 319 }, { "x": 276, "y": 319 } ], "word": "0" }, { "prob": 0.99, "location": [ { "x": 292, "y": 302 }, { "x": 307, "y": 302 }, { "x": 307, "y": 319 }, { "x": 292, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 311, "y": 302 }, { "x": 326, "y": 302 }, { "x": 326, "y": 319 }, { "x": 311, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 328, "y": 302 }, { "x": 343, "y": 302 }, { "x": 343, "y": 319 }, { "x": 328, "y": 319 } ], "word": "9" }, { "prob": 0.99, "location": [ { "x": 344, "y": 302 }, { "x": 359, "y": 302 }, { "x": 359, "y": 319 }, { "x": 344, "y": 319 } ], "word": "8" }, { "prob": 0.99, "location": [ { "x": 361, "y": 302 }, { "x": 376, "y": 302 }, { "x": 376, "y": 319 }, { "x": 361, "y": 319 } ], "word": "6" }, { "prob": 0.99, "location": [ { "x": 380, "y": 302 }, { "x": 395, "y": 302 }, { "x": 395, "y": 319 }, { "x": 380, "y": 319 } ], "word": "1" }, { "prob": 0.99, "location": [ { "x": 396, "y": 302 }, { "x": 411, "y": 302 }, { "x": 411, "y": 319 }, { "x": 396, "y": 319 } ], "word": "0" }, { "prob": 0.99, "location": [ { "x": 415, "y": 302 }, { "x": 430, "y": 302 }, { "x": 430, "y": 319 }, { "x": 415, "y": 319 } ], "word": "2" }, { "prob": 0.99, "location": [ { "x": 432, "y": 302 }, { "x": 447, "y": 302 }, { "x": 447, "y": 319 }, { "x": 432, "y": 319 } ], "word": "0" }, { "prob": 0.99, "location": [ { "x": 448, "y": 302 }, { "x": 463, "y": 302 }, { "x": 463, "y": 319 }, { "x": 448, "y": 319 } ], "word": "3" }, { "prob": 0.99, "location": [ { "x": 467, "y": 302 }, { "x": 482, "y": 302 }, { "x": 482, "y": 319 }, { "x": 467, "y": 319 } ], "word": "2" }, { "prob": 0.99, "location": [ { "x": 484, "y": 302 }, { "x": 499, "y": 302 }, { "x": 499, "y": 319 }, { "x": 484, "y": 319 } ], "word": "2" }, { "prob": 0.99, "location": [ { "x": 501, "y": 302 }, { "x": 516, "y": 302 }, { "x": 516, "y": 319 }, { "x": 501, "y": 319 } ], "word": "2" } ] } ], "location": [ { "x": 206, "y": 301 }, { "x": 518, "y": 301 }, { "x": 518, "y": 320 }, { "x": 206, "y": 320 } ], "fieldWord": "310101198610203222" }, { "prob": 1, "fieldName": "名族", "fieldWordRaw": "汉", "wordInfo": [ { "prob": 0.99, "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "word": "汉", "charInfo": [ { "prob": 0.99, "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "word": "汉" } ] } ], "location": [ { "x": 232, "y": 94 }, { "x": 259, "y": 94 }, { "x": 259, "y": 112 }, { "x": 232, "y": 112 } ], "fieldWord": "汉" } ], "specificType": "infoCustomeKvTemp", "width": 586, "angle": 0, "classType": "template", "height": 374, "predictFile": "https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/demo.png" } |
| Message |
string |
The returned status message. |
successful |
| Code |
string |
The status code for the request. A value of |
200 |
This section describes the fields in the `Data` object returned by the template service prediction API.
score The confidence score of the prediction service, a float value between 0 and 1.
data An array of objects containing the prediction results returned by the algorithm.
prob The confidence score for the algorithm's result, a float value between 0 and 1.
fieldName The extracted key.
fieldWord The extracted value.
location The coordinates of the extraction result. For example, { "x": 119, "y": 48 } is a coordinate on the page.
wordInfo Detailed information about the extracted content, including the location of each character.
specificType The algorithm type. Valid values include: infoCustomKvTemp (custom key-value template), infoCustomTableTemp (custom table template), ocr_infoExtractBill (OCR for information extraction), infoExtractBill (form/receipt extraction), and infoExtractDoc (long document information extraction).
classType The type of prediction service, such as a model prediction service or a template service.
predictFile The URL of the file used for prediction, which expires in 60 minutes.
Examples
Success response
JSON format
{
"RequestId": "F25FBAB4-665A-5D85-8AEF-39AE29F7D588",
"Data": {
"score": 0.9091,
"data": [
{
"prob": 1,
"fieldName": "姓名",
"fieldWordRaw": "方大呆",
"wordInfo": [
{
"prob": 0.9899999999999999,
"location": [
{
"x": 119,
"y": 48
},
{
"x": 199,
"y": 48
},
{
"x": 199,
"y": 69
},
{
"x": 119,
"y": 69
}
],
"word": "方大呆",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 119,
"y": 48
},
{
"x": 142,
"y": 48
},
{
"x": 142,
"y": 67
},
{
"x": 119,
"y": 67
}
],
"word": "方"
},
{
"prob": 0.99,
"location": [
{
"x": 142,
"y": 48
},
{
"x": 165,
"y": 48
},
{
"x": 165,
"y": 67
},
{
"x": 142,
"y": 67
}
],
"word": "大"
},
{
"prob": 0.99,
"location": [
{
"x": 167,
"y": 48
},
{
"x": 197,
"y": 48
},
{
"x": 197,
"y": 67
},
{
"x": 167,
"y": 67
}
],
"word": "呆"
}
]
}
],
"location": [
{
"x": 119,
"y": 48
},
{
"x": 199,
"y": 48
},
{
"x": 199,
"y": 69
},
{
"x": 119,
"y": 69
}
],
"fieldWord": "方大呆"
},
{
"prob": 1,
"fieldName": "性别",
"fieldWordRaw": "男",
"wordInfo": [
{
"prob": 0.99,
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"word": "男",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"word": "男"
}
]
}
],
"location": [
{
"x": 117,
"y": 93
},
{
"x": 142,
"y": 93
},
{
"x": 142,
"y": 112
},
{
"x": 117,
"y": 112
}
],
"fieldWord": "男"
},
{
"prob": 1,
"fieldName": "身份证号",
"fieldWordRaw": "310101********3222",
"wordInfo": [
{
"prob": 0.9899999999999998,
"location": [
{
"x": 206,
"y": 301
},
{
"x": 518,
"y": 301
},
{
"x": 518,
"y": 320
},
{
"x": 206,
"y": 320
}
],
"word": "310101198610203222",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 206,
"y": 302
},
{
"x": 223,
"y": 302
},
{
"x": 223,
"y": 319
},
{
"x": 206,
"y": 319
}
],
"word": "3"
},
{
"prob": 0.99,
"location": [
{
"x": 223,
"y": 302
},
{
"x": 238,
"y": 302
},
{
"x": 238,
"y": 319
},
{
"x": 223,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 240,
"y": 302
},
{
"x": 255,
"y": 302
},
{
"x": 255,
"y": 319
},
{
"x": 240,
"y": 319
}
],
"word": "0"
},
{
"prob": 0.99,
"location": [
{
"x": 259,
"y": 302
},
{
"x": 274,
"y": 302
},
{
"x": 274,
"y": 319
},
{
"x": 259,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 276,
"y": 302
},
{
"x": 291,
"y": 302
},
{
"x": 291,
"y": 319
},
{
"x": 276,
"y": 319
}
],
"word": "0"
},
{
"prob": 0.99,
"location": [
{
"x": 292,
"y": 302
},
{
"x": 307,
"y": 302
},
{
"x": 307,
"y": 319
},
{
"x": 292,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 311,
"y": 302
},
{
"x": 326,
"y": 302
},
{
"x": 326,
"y": 319
},
{
"x": 311,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 328,
"y": 302
},
{
"x": 343,
"y": 302
},
{
"x": 343,
"y": 319
},
{
"x": 328,
"y": 319
}
],
"word": "9"
},
{
"prob": 0.99,
"location": [
{
"x": 344,
"y": 302
},
{
"x": 359,
"y": 302
},
{
"x": 359,
"y": 319
},
{
"x": 344,
"y": 319
}
],
"word": "8"
},
{
"prob": 0.99,
"location": [
{
"x": 361,
"y": 302
},
{
"x": 376,
"y": 302
},
{
"x": 376,
"y": 319
},
{
"x": 361,
"y": 319
}
],
"word": "6"
},
{
"prob": 0.99,
"location": [
{
"x": 380,
"y": 302
},
{
"x": 395,
"y": 302
},
{
"x": 395,
"y": 319
},
{
"x": 380,
"y": 319
}
],
"word": "1"
},
{
"prob": 0.99,
"location": [
{
"x": 396,
"y": 302
},
{
"x": 411,
"y": 302
},
{
"x": 411,
"y": 319
},
{
"x": 396,
"y": 319
}
],
"word": "0"
},
{
"prob": 0.99,
"location": [
{
"x": 415,
"y": 302
},
{
"x": 430,
"y": 302
},
{
"x": 430,
"y": 319
},
{
"x": 415,
"y": 319
}
],
"word": "2"
},
{
"prob": 0.99,
"location": [
{
"x": 432,
"y": 302
},
{
"x": 447,
"y": 302
},
{
"x": 447,
"y": 319
},
{
"x": 432,
"y": 319
}
],
"word": "0"
},
{
"prob": 0.99,
"location": [
{
"x": 448,
"y": 302
},
{
"x": 463,
"y": 302
},
{
"x": 463,
"y": 319
},
{
"x": 448,
"y": 319
}
],
"word": "3"
},
{
"prob": 0.99,
"location": [
{
"x": 467,
"y": 302
},
{
"x": 482,
"y": 302
},
{
"x": 482,
"y": 319
},
{
"x": 467,
"y": 319
}
],
"word": "2"
},
{
"prob": 0.99,
"location": [
{
"x": 484,
"y": 302
},
{
"x": 499,
"y": 302
},
{
"x": 499,
"y": 319
},
{
"x": 484,
"y": 319
}
],
"word": "2"
},
{
"prob": 0.99,
"location": [
{
"x": 501,
"y": 302
},
{
"x": 516,
"y": 302
},
{
"x": 516,
"y": 319
},
{
"x": 501,
"y": 319
}
],
"word": "2"
}
]
}
],
"location": [
{
"x": 206,
"y": 301
},
{
"x": 518,
"y": 301
},
{
"x": 518,
"y": 320
},
{
"x": 206,
"y": 320
}
],
"fieldWord": "310101198610203222"
},
{
"prob": 1,
"fieldName": "名族",
"fieldWordRaw": "汉",
"wordInfo": [
{
"prob": 0.99,
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"word": "汉",
"charInfo": [
{
"prob": 0.99,
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"word": "汉"
}
]
}
],
"location": [
{
"x": 232,
"y": 94
},
{
"x": 259,
"y": 94
},
{
"x": 259,
"y": 112
},
{
"x": 232,
"y": 112
}
],
"fieldWord": "汉"
}
],
"specificType": "infoCustomeKvTemp",
"width": 586,
"angle": 0,
"classType": "template",
"height": 374,
"predictFile": "https://doc-automl-public.oss-cn-hangzhou.aliyuncs.com/demo/demo.png"
},
"Message": "successful",
"Code": "200"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 200 | 21002 | 模板预测超时 | |
| 200 | 21003 | 模板预测失败 | |
| 200 | 21004 | 模板提交失败 | |
| 200 | 10001 | 参数出错 | |
| 200 | 10005 | 服务不存在 | |
| 200 | 21018 | 未找到模板信息 | |
| 200 | 16001 | 未找到可预测的模型 | |
| 200 | 16004 | 指定的模型不存在 | |
| 200 | 23002 | 获取资源HTTP异常 | |
| 200 | 22002 | ocr服务异常 | |
| 200 | 11002 | 账号没有开通服务 | |
| 200 | 19999 | 未知异常 |
See Error CodesError Codes for a complete list.
Release notes
See Release NotesRelease Notes for a complete list.