Ask the AI model to draft a template from a sample
const url = 'http://localhost:8080/v1/extraction-templates/suggest';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"sample":"example","sampleId":"example","docTypeHint":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Request Bodyrequired
Section titled “Request Bodyrequired”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
Examplegenerated
{ "sample": "example", "sampleId": "example", "docTypeHint": "example"}Responses
Section titled “Responses”OK
A proposal and its proof: the suggested document template, how the sample classifies with it, and what it extracts.
object
object
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"}