Parse Document
Parse and extract structured data from documents using an LLM.
Asks the LLM to fill a fixed template for the chosen document type (invoice, receipt, resume, contract, form) or your own template, from the document text. It measures how many top-level fields came back filled and routes by that score.
Analyzes document text (OCR output, raw text, or pre-processed content) and extracts structured fields based on the document type. Includes built-in schemas for common document types and supports custom extraction schemas.
Operations:
- Invoice: Extract vendor, line items, totals, payment terms.
- Receipt: Extract merchant, items, totals, payment method.
- Resume: Extract contact info, experience, education, skills.
- Contract: Extract parties, dates, clauses, obligations.
- Form: Extract generic label-value field pairs.
- Custom: Use a user-defined JSON schema for extraction.
How it works
- Resolves the node config: expressions in config keys are evaluated against the run; the incoming item is used as-is.
- Merges the incoming item with the resolved config (config keys win) and reads the inputs from the result.
- Requires
text. Picks the template fordocument_type(defaultform); forcustomit parsesextraction_schemaas JSON. - If
knowledge_resource_idis set, loads its text or structured data as extra extraction context. Inputmetadatais added to the prompt as JSON. - Calls the LLM through the backend with the
llm_provider_idrecord.invocation_mode: "sync"(default) waits for the full answer;"stream"reads it over SSE and joins the chunks. - Parses the answer as JSON (temperature 0). Counts the template’s top-level keys that are not
null, missing or an empty array:completeness_score= filled / total, rounded to 2 decimals. - Routes to
incompletewhen the score is below 0.7, otherwise tosuccess.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-parse-invoice",
"label": "Parse invoice",
"operator_slug": "ai.parse.document",
"operator_version": "1.0.0",
"config": {
"llm_provider_id": "<llm_provider_id>",
"invocation_mode": "sync",
"document_type": "invoice",
"language": "en"
}
}{
"ok": true,
"port": "success",
"data": {
"document_type": "invoice",
"data": {
"vendor": "Example Supplies Ltd.",
"vendor_address": "12 Market St, Springfield",
"invoice_number": "INV-2026-0042",
"date": "2026-11-02",
"due_date": "2026-12-02",
"line_items": [
{
"description": "Printer paper A4",
"quantity": 10,
"unit_price": 4.5,
"total": 45
}
],
"subtotal": 45,
"tax": 8.55,
"total": 53.55,
"currency": "USD",
"payment_terms": null
},
"completeness_score": 0.91,
"missing_fields": [
"payment_terms"
]
}
}Configuration
-
llm_provider_idstring Optional -
The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.
-
invocation_modestring Optional -
Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.
-
timeout_msinteger Optional -
Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.
-
document_typestring Required -
Type of document to parse. Determines the extraction schema.
-
extraction_schemastring Optional -
JSON schema defining the fields to extract (used in custom mode).
-
languagestring Optional -
knowledge_resource_idstring Optional -
Optional Knowledge Resource with additional extraction context or field definitions.
Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
llm_provider_id - Required at runtime although the schema does not mark it as required. It is the id of an LLM provider record; the backend resolves endpoint, deployment and credentials from it.
-
extraction_schema - Used as a template, not as JSON Schema: write the object you want back, with
nullvalues, e.g.{"po_number": null, "items": [{"sku": null}]}. Its top-level keys are the fields counted for completeness. A JSON Schema document would make the model filltypeandproperties. -
knowledge_resource_id - If the knowledge resource cannot be loaded, the failure is only logged and the node continues without it.
-
language - Adds a reply-language line to the prompt when it is not
en. It does not translate field names. -
timeout_ms timeout_msonly takes effect instreammode, as the idle time allowed between chunks (default 600000). Insyncmode it is logged but the backend request has no timeout.
Output ports
success default completeness_score is 0.7 or higher.
{
"document_type": "invoice",
"data": {
"vendor": "Example Supplies Ltd.",
"vendor_address": "12 Market St, Springfield",
"invoice_number": "INV-2026-0042",
"date": "2026-11-02",
"due_date": "2026-12-02",
"line_items": [
{
"description": "Printer paper A4",
"quantity": 10,
"unit_price": 4.5,
"total": 45
}
],
"subtotal": 45,
"tax": 8.55,
"total": 53.55,
"currency": "USD",
"payment_terms": null
},
"completeness_score": 0.91,
"missing_fields": [
"payment_terms"
]
}incomplete completeness_score is below 0.7. Same shape.
{
"document_type": "receipt",
"data": {
"merchant": "Corner Café",
"date": null,
"items": [],
"subtotal": null,
"tax": null,
"total": 7.2,
"payment_method": null
},
"completeness_score": 0.29,
"missing_fields": [
"date",
"items",
"subtotal",
"tax",
"payment_method"
]
}error Validation, the LLM call or parsing failed. data is { error } (plus response when the backend returned a body).
{
"error": "Missing input text for document parsing."
}In expressions
What a later node can read from this node's output with $("Parse Document").item.json.<path> (write your node's label instead of Parse Document). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through success, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("Parse Document").item.json.document_typeThe document type that was parsed. | ||
$("Parse Document").item.json.dataExtracted structured data. | ||
$("Parse Document").item.json.completeness_scoreRatio of non-null extracted fields (0-1). | ||
$("Parse Document").item.json.missing_fieldsList of expected fields that could not be extracted. | ||
$("Parse Document").item.json.data.vendor | — | |
$("Parse Document").item.json.data.vendor_address | — | |
$("Parse Document").item.json.data.invoice_number | — | |
$("Parse Document").item.json.data.date | — | |
$("Parse Document").item.json.data.due_date | — | |
$("Parse Document").item.json.data.line_items | — | |
$("Parse Document").item.json.data.subtotal | — | |
$("Parse Document").item.json.data.tax | — | |
$("Parse Document").item.json.data.total | — | |
$("Parse Document").item.json.data.currency | — | |
$("Parse Document").item.json.data.payment_terms | — |
— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).
Errors
| Message | Port | Cause and fix |
|---|---|---|
Missing input text for document parsing. | error | The incoming item has no text. |
Missing extraction_schema for custom document type. | error | document_type is custom but extraction_schema is empty. |
extraction_schema is not valid JSON. | error | extraction_schema is a string that does not parse as JSON. |
Unknown document type: <document_type> | error | document_type is not one of the listed values. |
Model did not return valid document parsing output. | error | The answer did not contain a JSON object. Try a model that follows JSON instructions better. |
[AiParseDocument] Missing 'llm_provider_id' in node config (LlmProviderModel.id, e.g. 'wf-llm-provider-*'). … | error | The node has no llm_provider_id. Pick an LLM provider in the node config; the legacy model_id key is not accepted. |
LLM Invocation Error: <backend message> | error | The backend rejected the call (unknown or inactive provider record, provider error, credentials). Check the provider record. |
LLM Invocation Error: empty response from backend (<reason>). | error | The backend could not be reached or returned nothing in sync mode. |
RemoteApiService.stream: idle timeout after <timeout_ms>ms | error | In stream mode no chunk arrived within timeout_ms. |
Input contract
-
textstring Required -
Document text content to parse.
-
metadataobject Optional -
Optional metadata about the document (filename, source, etc.).
Output contract
-
document_typestring Optional -
The document type that was parsed.
-
dataobject Optional -
Extracted structured data.
-
completeness_scorenumber Optional -
Ratio of non-null extracted fields (0-1).
-
missing_fieldsarray<string> Optional -
List of expected fields that could not be extracted.
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "ai.parse.document",
"name": "Parse Document",
"category": "ai",
"version": "1.0.0",
"description": "Parse and extract structured data from documents using an LLM.\n\n Analyzes document text (OCR output, raw text, or pre-processed content) and extracts structured fields based on the document type. Includes built-in schemas for common document types and supports custom extraction schemas.\n\n **Operations:**\n - **Invoice:** Extract vendor, line items, totals, payment terms.\n - **Receipt:** Extract merchant, items, totals, payment method.\n - **Resume:** Extract contact info, experience, education, skills.\n - **Contract:** Extract parties, dates, clauses, obligations.\n - **Form:** Extract generic label-value field pairs.\n - **Custom:** Use a user-defined JSON schema for extraction.",
"capabilities": [
"ai",
"nlp",
"parsing",
"document",
"extraction",
"structured-output"
],
"knowledge_binding": {
"enabled": true,
"resource_types": [
"schema",
"template"
],
"field": "knowledge_resource_id",
"label": "Extraction Reference"
},
"config_schema": {
"type": "object",
"properties": {
"llm_provider_id": {
"type": "string",
"title": "LLM Provider",
"description": "The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.",
"x-ui-widget": "llm-provider-picker",
"x-llm-provider-capabilities": [
"chat"
]
},
"invocation_mode": {
"type": "string",
"title": "Invocation Mode",
"description": "Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.",
"enum": [
"sync",
"stream"
],
"default": "sync"
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.",
"minimum": 1000
},
"document_type": {
"type": "string",
"title": "Document Type",
"enum": [
"invoice",
"receipt",
"resume",
"contract",
"form",
"custom"
],
"default": "form",
"description": "Type of document to parse. Determines the extraction schema."
},
"extraction_schema": {
"type": "string",
"title": "Extraction Schema",
"format": "json",
"description": "JSON schema defining the fields to extract (used in custom mode).",
"ui_widget": "code_editor",
"ui_options": {
"language": "json"
},
"displayOptions": {
"show": {
"document_type": [
"custom"
]
}
}
},
"language": {
"type": "string",
"title": "Language",
"default": "en"
},
"knowledge_resource_id": {
"type": "string",
"title": "Extraction Reference (Knowledge Resource)",
"description": "Optional Knowledge Resource with additional extraction context or field definitions.",
"x-ui-widget": "knowledge-resource-picker"
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"document_type"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "Document text content to parse."
},
"metadata": {
"type": "object",
"description": "Optional metadata about the document (filename, source, etc.).",
"additionalProperties": true
}
},
"required": [
"text"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"document_type": {
"type": "string",
"description": "The document type that was parsed."
},
"data": {
"type": "object",
"description": "Extracted structured data."
},
"completeness_score": {
"type": "number",
"description": "Ratio of non-null extracted fields (0-1)."
},
"missing_fields": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of expected fields that could not be extracted."
}
}
},
"ports": [
{
"port_id": "success",
"label": "Parsed",
"is_default": true,
"description": "Document parsed with completeness >= 0.7."
},
{
"port_id": "incomplete",
"label": "Incomplete",
"description": "Document parsed but completeness < 0.7."
},
{
"port_id": "error",
"label": "Error",
"description": "Parsing failed."
}
],
"execution_mode": "async",
"tags": [
"ai",
"nlp",
"document",
"parser",
"extraction",
"invoice",
"receipt",
"resume",
"contract"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"llm_provider_id": {
"type": "string",
"title": "LLM Provider",
"description": "The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.",
"x-ui-widget": "llm-provider-picker",
"x-llm-provider-capabilities": [
"chat"
]
},
"invocation_mode": {
"type": "string",
"title": "Invocation Mode",
"description": "Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.",
"enum": [
"sync",
"stream"
],
"default": "sync"
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.",
"minimum": 1000
},
"document_type": {
"type": "string",
"title": "Document Type",
"enum": [
"invoice",
"receipt",
"resume",
"contract",
"form",
"custom"
],
"default": "form",
"description": "Type of document to parse. Determines the extraction schema."
},
"extraction_schema": {
"type": "string",
"title": "Extraction Schema",
"format": "json",
"description": "JSON schema defining the fields to extract (used in custom mode).",
"ui_widget": "code_editor",
"ui_options": {
"language": "json"
},
"displayOptions": {
"show": {
"document_type": [
"custom"
]
}
}
},
"language": {
"type": "string",
"title": "Language",
"default": "en"
},
"knowledge_resource_id": {
"type": "string",
"title": "Extraction Reference (Knowledge Resource)",
"description": "Optional Knowledge Resource with additional extraction context or field definitions.",
"x-ui-widget": "knowledge-resource-picker"
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
},
"required": [
"document_type"
]
}{
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "Document text content to parse."
},
"metadata": {
"type": "object",
"description": "Optional metadata about the document (filename, source, etc.).",
"additionalProperties": true
}
},
"required": [
"text"
]
}{
"type": "object",
"properties": {
"document_type": {
"type": "string",
"description": "The document type that was parsed."
},
"data": {
"type": "object",
"description": "Extracted structured data."
},
"completeness_score": {
"type": "number",
"description": "Ratio of non-null extracted fields (0-1)."
},
"missing_fields": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of expected fields that could not be extracted."
}
}
}[
{
"port_id": "success",
"label": "Parsed",
"is_default": true,
"description": "Document parsed with completeness >= 0.7."
},
{
"port_id": "incomplete",
"label": "Incomplete",
"description": "Document parsed but completeness < 0.7."
},
{
"port_id": "error",
"label": "Error",
"description": "Parsing failed."
}
]Execution
- Execution
async- Stateful
- No
- Retries (
retryOnFail) - No
- Capabilities
ainlpparsingdocumentextractionstructured-output- Tags
ainlpdocumentparserextractioninvoicereceiptresumecontract
Notes and limits
- Completeness only looks at top-level keys. A nested array with an item full of
nullvalues still counts as filled. - The 0.7 threshold is fixed in code.
- The model answer is parsed as JSON after removing Markdown code fences; if that fails, the text between the first
{and the last}is parsed. - Input fields are read from the incoming item (
$json). A key with the same name in the node config, which may be an expression, takes precedence over the input. - The worker also returns the provider response as
rawoutsidedata; the engine does not keep it. - On success the worker returns
portanddatawithout anokfield; the engine routes onportonly. timeout_msonly takes effect instreammode, as the idle time allowed between chunks (default 600000). Insyncmode it is logged but the backend request has no timeout.- In
streammode the temperature this node sets is not forwarded to the provider, andrawisnull. - The engine does not apply
execution.retryOnFail,maxTries,waitBetweenTriesorcontinueOnFailto this node. Handle failures by wiring theerrorport.
Reviewed against the orchestrator code · 31e874b · 2026-11-26