Processor output types

Document processor outputs follow standardized formats based on the processor type. Understanding these formats is essential when working with evaluation sets, webhooks, and API responses.

Extraction output type (JSON Schema)

This section is relevant for processors using the JSON Schema config type. If you are using the Fields Array config type, please see the Extraction output type (Fields Array) documentation. If you aren’t sure which config type you are using, please see the Migrating to JSON Schema documentation.

The output structure for JSON Schema processors is composed of two properties: value and metadata.

The value object is the actual data extracted from the document which conforms to the JSON Schema defined in the processor config.

The metadata object holds details like confidence scores and citations for the extracted data. It uses keys that represent the path to the corresponding data within the value object. Crucially, the keys in the metadata object mirror the structure of the value object using a path-like notation (e.g., line_items[0].description), allowing you to precisely pinpoint metadata for any specific field, including those nested within objects or arrays. For instance, if your data has value.line_items[0].name, the metadata specifically for that name field will be found using the key ‘line_items[0].name’ within the metadata object.

Type definition

TypeScript Types
1type ExtractionOutput = {
2 value: ExtractionValue;
3 metadata: ExtractionMetadata;
4};
5
6type ExtractionValue = Record<string, any>; // Conforms to the schema defined in the processor config
7type ExtractionMetadata = {
8 [key: string]: ExtractionMetadataEntry | undefined;
9};
10
11type ExtractionMetadataEntry {
12 ocrConfidence?: number | null;
13 logprobsConfidence: number | null;
14 citations?: Citation[];
15 insights?: OutputInsight[];
16}
17
18type Citation = {
19 page?: number;
20 referenceText?: string | null;
21 polygon?: Point[];
22};
23
24type Point = {
25 x: number;
26 y: number;
27};
28
29type OutputInsight = {
30 type: "reasoning";
31 content: string;
32};

Accessing Metadata

To access the metadata for a specific field, especially nested ones like items in an array, you use a path-like key string. For example, to get the metadata for the description of the first item in a line_items array, the key would be line_items[0].description.

Here are examples in Python and TypeScript:

1const output = {
2 value: {
3 invoice_number: "INV-123",
4 line_items: [
5 { description: "Item A", quantity: 2, price: 10.0 },
6 { description: "Item B", quantity: 1, price: 25.5 },
7 ],
8 },
9 metadata: {
10 invoice_number: {
11 logprobsConfidence: 1,
12 ocrConfidence: 0.99,
13 citations: [
14 {
15 referenceText: "Invoice #: INV-123",
16 page: 1,
17 polygon: [
18 { x: 296.73359999999997, y: 40.888799999999996 },
19 { x: 386.4168, y: 40.464000000000006 },
20 { x: 386.4744, y: 52.1712 },
21 { x: 296.7912, y: 52.596000000000004 },
22 ],
23 },
24 ],
25 },
26 line_items: {
27 logprobsConfidence: 0.98,
28 ocrConfidence: 0.98,
29 },
30 "line_items[0]": {
31 logprobsConfidence: 0.98,
32 ocrConfidence: 0.98,
33 citations: [{ page: 1 }],
34 },
35 "line_items[0].description": { logprobsConfidence: 1, ocrConfidence: 0.95 },
36 "line_items[0].quantity": { logprobsConfidence: 1, ocrConfidence: 0.98 },
37 "line_items[0].price": { logprobsConfidence: 1, ocrConfidence: 0.98 },
38 "line_items[1].description": { logprobsConfidence: 1, ocrConfidence: 0.96 },
39 // Other metadata entries...
40 },
41};
42
43// Traversing the output object and accessing metadata
44const invoiceNumber = output.value.invoice_number;
45const invoiceNumberMetadata = output.metadata.invoice_number;
46
47// Access metadata for the line_items array itself
48const lineItemsMetadata = output.metadata.line_items;
49
50// Loop through line items array
51for (let i = 0; i < output.value.line_items.length; i++) {
52 const lineItemPath = `line_items[${i}]`;
53
54 // Access the line item object and its metadata
55 const lineItem = output.value.line_items[i];
56 const lineItemMetadata = output.metadata[lineItemPath];
57
58 // Access properties within the line item and their metadata
59 const lineItemDescription = lineItem.description;
60 const lineItemDescriptionMetadata =
61 output.metadata[`${lineItemPath}.description`];
62 const lineItemQuantity = lineItem.quantity;
63 const lineItemQuantityMetadata = output.metadata[`${lineItemPath}.quantity`];
64 const lineItemPrice = lineItem.price;
65 const lineItemPriceMetadata = output.metadata[`${lineItemPath}.price`];
66}

Examples

1{
2 "value": {
3 "amount": {
4 "amount": 15735.1,
5 "iso_4217_currency_code": "USD"
6 },
7 "invoice_number": "36995"
8 },
9 "metadata": {
10 "amount": {
11 "insights": [
12 {
13 "type": "reasoning",
14 "content": "The total amount is shown as '$15,735.1' in both the table summary and the bottom right of the document. The currency symbol '$' and the US address indicate the currency is USD. The value is numeric and matches the required format."
15 }
16 ],
17 "citations": [
18 {
19 "page": 1,
20 "polygon": [
21 {
22 "x": 430.164,
23 "y": 722.772
24 },
25 {
26 "x": 467.27279999999996,
27 "y": 722.8296
28 },
29 {
30 "x": 467.2584,
31 "y": 731.6351999999999
32 },
33 {
34 "x": 430.1496,
35 "y": 731.5776
36 }
37 ],
38 "referenceText": "TOTAL $15,735.1"
39 }
40 ],
41 "ocrConfidence": 0.992,
42 "logprobsConfidence": 1
43 },
44 "invoice_number": {
45 "insights": [
46 {
47 "type": "reasoning",
48 "content": "The invoice number is clearly labeled as 'Invoice #36995' at the top right of the document, making it straightforward to extract."
49 }
50 ],
51 "citations": [
52 {
53 "page": 1,
54 "polygon": [
55 {
56 "x": 296.73359999999997,
57 "y": 40.888799999999996
58 },
59 {
60 "x": 386.4168,
61 "y": 40.464000000000006
62 },
63 {
64 "x": 386.4744,
65 "y": 52.1712
66 },
67 {
68 "x": 296.7912,
69 "y": 52.596000000000004
70 }
71 ],
72 "referenceText": "Invoice #36995"
73 }
74 ],
75 "ocrConfidence": 0.986,
76 "logprobsConfidence": 1
77 }
78 }
79}
1{
2 "value": {
3 "line_items": [
4 {
5 "item": "Widget A",
6 "quantity": 5,
7 "price": {
8 "amount": 10.0,
9 "iso_4217_currency_code": "USD"
10 }
11 },
12 {
13 "item": "Widget B",
14 "quantity": 2,
15 "price": {
16 "amount": 15.0,
17 "iso_4217_currency_code": "USD"
18 }
19 }
20 ],
21 "signature_block": {
22 "printed_name": "John Smith",
23 "signature_date": "2024-03-15",
24 "is_signed": true,
25 "title_or_role": "Purchasing Manager"
26 }
27 },
28 "metadata": {
29 "line_items": {
30 "logprobsConfidence": 0.96 // Minimum confidence for the values in the array
31 },
32 "line_items[0]": {
33 "logprobsConfidence": 0.96, // Minimum confidence for the values in the item
34 "page": 1
35 },
36 "line_items[0].item": {
37 "logprobsConfidence": 0.99
38 },
39 "line_items[0].quantity": {
40 "logprobsConfidence": 1.0
41 },
42 "line_items[0].price.amount": {
43 "logprobsConfidence": 0.98
44 },
45 "line_items[0].price.iso_4217_currency_code": {
46 "logprobsConfidence": 0.96
47 },
48 "line_items[1]": {
49 "logprobsConfidence": 0.96,
50 "page": 1
51 },
52 "line_items[1].item": {
53 "logprobsConfidence": 0.98
54 },
55 "line_items[1].quantity": {
56 "logprobsConfidence": 1.0
57 },
58 "line_items[1].price.amount": {
59 "logprobsConfidence": 0.97
60 },
61 "line_items[1].price.iso_4217_currency_code": {
62 "logprobsConfidence": 0.96
63 },
64 "signature_block": {
65 "logprobsConfidence": 0.99, // Confidence for the overall object
66 "citations": [
67 {
68 "page": 1,
69 "referenceText": "John Smith",
70 "polygon": [
71 /* points omitted */
72 ]
73 }
74 ]
75 }
76 }
77}

Extraction output type (Fields Array)

This section is relevant for the Fields Array config type. If you are using the JSON Schema config type, please see the Extraction output type (JSON Schema) documentation. If you aren’t sure which config type you are using, please see the Migrating to JSON Schema documentation.

For processors using the legacy Fields Array configuration, the extraction output is a flat dictionary where each key is the fieldName (or sometimes the id if names aren’t unique) you defined in the configuration, and the value is an ExtractionFieldResult object containing the extracted data and associated details.

Type definition

Each ExtractionFieldResult object contains the core id, type, and extracted value. It can also include the following optional details:

  • schema: The schema definition for nested fields (like objects or array items).
  • insights: Reasoning or explanations from the model (if enabled).
  • references: Location information, including the page number and specific Bounding Boxes relevant to the legacy Fields Array configuration (see Bounding Boxes Guide).
  • enum: The available options if the field type is enum.
1type ExtractionOutput = {
2 [fieldName: string]: ExtractionFieldResult;
3};
4
5type ExtractionFieldResult = {
6 id: string;
7 type:
8 | "string"
9 | "number"
10 | "currency"
11 | "boolean"
12 | "date"
13 | "enum"
14 | "array"
15 | "object"
16 | "signature";
17 value:
18 | string
19 | number
20 | Currency
21 | boolean
22 | Date
23 | ExtractionValueArray
24 | ExtractionValueObject
25 | Signature
26 | null;
27
28 /* The following fields are included in outputs, but not required for creating an evaluation set item */
29
30 /* Includes the field schema of nested fields (e.g. array fields, object fields, signature fields etc) */
31 schema: ExtractionFieldSchemaValue[];
32
33 /* Insights the reasoning and other insights outputs of the model (when reasoning is enabled) */
34 insights: Insight[];
35
36 /* References for the extracted field, always includes the page number for all fields, and might include bounding boxes and citations when available. */
37 references: ExtractionFieldResultReference[];
38
39 /* The enum options for enum fields, only set when type=enum */
40 enum: EnumOption[];
41};
42
43type Currency = {
44 amount: number;
45 iso_4217_currency_code: string;
46};
47
48type Signature = {
49 printed_name: string;
50 signature_date: string;
51 is_signed: boolean;
52 title_or_role: string;
53};
54
55type EnumOption = {
56 value: string; // The enum value (e.g. "ANNUAL", "MONTHLY", etc.)
57 description: string; // The description of the enum value
58};
59
60type ExtractionValueArray = Array<ExtractionValueObject>;
61type ExtractionValueObject = Record<string, any>;

References

1type ExtractionFieldResultReference = {
2 /* The field id. When nested for arrays, this is the index of the row number */
3 id: string;
4 /* The field name */
5 fieldName: string;
6 /* The page number (starting at 1) that this bounding box is from */
7 page: number;
8 /**
9 * Array of bounding box references for this field.
10 * There can be multiple is the extraction result was drawn from multiple distinct sources on the page.
11 */
12 boundingBoxes: BoundingBox[];
13};
14
15/* See the Bounding boxes guide for information on how to use/interpret this data */
16type BoundingBox = {
17 /* The left most position of the bounding box */
18 left: number;
19 /* The top most position of the bounding box */
20 top: number;
21 /* The right most position of the bounding box */
22 right: number;
23 /* The bottom most position of the bounding box */
24 bottom: number;
25};

Examples

1{
2 "invoice_number": {
3 "id": "field_123",
4 "type": "string",
5 "value": "INV-2024-001"
6 },
7 "amount_due": {
8 "id": "field_456",
9 "type": "currency",
10 "value": {
11 "amount": 1250.5,
12 "iso_4217_currency_code": "USD"
13 }
14 }
15}
1{
2 "line_items": {
3 "id": "field_789",
4 "type": "array",
5 "value": [
6 {
7 "item": "Widget A",
8 "quantity": 5,
9 "price": {
10 "amount": 10.0,
11 "iso_4217_currency_code": "USD"
12 }
13 },
14 {
15 "item": "Widget B",
16 "quantity": 2,
17 "price": {
18 "amount": 15.0,
19 "iso_4217_currency_code": "USD"
20 }
21 }
22 ],
23 "schema": [
24 // Schema definition for the items in the array
25 {
26 "id": "item",
27 "name": "Item Name",
28 "type": "string",
29 "description": "..."
30 },
31 {
32 "id": "quantity",
33 "name": "Quantity",
34 "type": "number",
35 "description": "..."
36 },
37 {
38 "id": "price",
39 "name": "Price",
40 "type": "currency",
41 "description": "..."
42 }
43 ]
44 },
45 "signature_block": {
46 "id": "field_101",
47 "type": "signature",
48 "value": {
49 "printed_name": "John Smith",
50 "signature_date": "2024-03-15",
51 "is_signed": true,
52 "title_or_role": "Purchasing Manager"
53 },
54 "schema": [
55 // Schema for the signature object fields
56 {
57 "id": "printed_name",
58 "name": "Printed Name",
59 "type": "string",
60 "description": "..."
61 },
62 {
63 "id": "signature_date",
64 "name": "Signature Date",
65 "type": "date",
66 "description": "..."
67 },
68 {
69 "id": "is_signed",
70 "name": "Is Signed",
71 "type": "boolean",
72 "description": "..."
73 },
74 {
75 "id": "title_or_role",
76 "name": "Title/Role",
77 "type": "string",
78 "description": "..."
79 }
80 ],
81 "insights": [
82 {
83 "type": "reasoning",
84 "content": "Signature block found at the bottom of page 2. 'is_signed' is true based on visual confirmation."
85 }
86 ],
87 "references": [
88 {
89 "id": "signature_block", // Refers to the top-level field ID
90 "fieldName": "Signature Block",
91 "page": 2,
92 "boundingBoxes": [
93 // Box around the whole signature area
94 { "left": 100, "top": 700, "right": 400, "bottom": 780 }
95 ]
96 }
97 ]
98 }
99}

Classification Output Type

Type Definition

1type ClassificationOutput = {
2 id: string;
3 type: string;
4};

Example

1{
2 "id": "classification_123",
3 "type": "INVOICE"
4}

Splitter Output Type

Type Definition

1type SplitterOutput = {
2 splits: Split[];
3};
4
5type Split = {
6 classificationId: string; // The id of the classification type (set in the processor config)
7 type: string; // The type of the split document (set in the processor config), corresponds to the classificationId.
8 startPage: number; // The start page of the split document
9 endPage: number; // The end page of the split document
10
11 // Fields included in outputs, but not required for creating an evaluation set item
12 identifier?: string; // Identifier for the split document (e.g. invoice number)
13 observation?: string; // Explanation of the results
14};

Example

1{
2 "splits": [
3 {
4 "classificationId": "invoice",
5 "type": "invoice",
6 "startPage": 1,
7 "endPage": 3
8 },
9 {
10 "classificationId": "other",
11 "type": "other",
12 "startPage": 4,
13 "endPage": 5
14 }
15 ]
16}

Shared Types

Certain types are shared across different processor outputs. These provide additional context and information about the processor’s decisions.

Type Definition

1type Insight = {
2 type: "reasoning"; // Currently only reasoning is supported
3 content: string; // The explanation or reasoning provided by the model
4};

Example

1{
2 "insights": [
3 {
4 "type": "reasoning",
5 "content": "This was classified as an invoice because it contains standard invoice elements including an invoice number, billing details, and itemized charges."
6 }
7 ]
8}

Insights can appear in both Extraction and Classification outputs to provide transparency into the model’s decision-making process. They are particularly useful when debugging or validating processor results.