Skip to content

Ask the AI model to draft a template from a sample

POST
/v1/extraction-templates/suggest
curl --request POST \
--url http://localhost:8080/v1/extraction-templates/suggest \
--header 'Content-Type: application/json' \
--data '{ "sample": "example", "sampleId": "example", "docTypeHint": "example" }'

Takes a sample document (sample: the PDF’s bytes as base64, ≤ 20 MB; or sampleId of an uploaded sample) and an optional docTypeHint, sends the recognised page text and the catalogs to the configured OpenAI-compatible endpoint (ai.endpoint/ai.model, a local model works), validates the proposed template, and proves it by classifying and extracting the sample with only the proposal in play; the response carries the template and the values it read with their boxes, for a person to review before saving. 422 when no model is configured; 400 when the sample or the model’s answer is unusable. Administrators only.

Media typeapplication/json

Body of POST /v1/extraction-templates/suggest: a sample document (base64 PDF, or the id of an uploaded sample) and an optional taxonomy hint.

object
sample
string
sampleId
null | string
docTypeHint
null | string
Examplegenerated
{
"sample": "example",
"sampleId": "example",
"docTypeHint": "example"
}

OK

Media typeapplication/json

A proposal and its proof: the suggested document template, how the sample classifies with it, and what it extracts.

object
template
required
classifiedAs
required
string
confidence
required
number | string format: double
/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/
fields
required
Array<object>
object
fieldName
required
string
rawText
required
null | string
normalizedValue
required
null | string
valueKind
required
string
pageNo
required
null | integer | string format: int32
/^-?(?:0|[1-9]\d*)$/
bbox
required
One of:
null
confidence
required
number | string format: double
/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/
method
required
string
engineVersion
required
string
Examplegenerated
{
"template": "example",
"classifiedAs": "example",
"confidence": 1,
"fields": [
{
"fieldName": "example",
"rawText": "example",
"normalizedValue": "example",
"valueKind": "example",
"pageNo": 1,
"bbox": {
"x": 1,
"y": 1,
"w": 1,
"h": 1
},
"confidence": 1,
"method": "example"
}
],
"engineVersion": "example"
}