Introducing a new way to review your PRs.

Read the announcement

zipstack / unstract

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

View on GitHub

28 documents · Updated Nov 23, 2026

docs / document-processing

Document processing services

Document processing services turn source files into text that extraction workflows can use. They sit between file access and workflow execution: a conversion service prepares the document, while the execution system selects the service, manages the run, and passes the result to later extraction and indexing steps.

Processing boundary

Document preparation

Document preparation converts a file into a text representation without deciding what the text means. The conversion layer can call an external document parser and can write the resulting text to shared file storage for the rest of the workflow.

The conversion layer does not own prompts, field extraction, chunking, embeddings, or vector storage. Those concerns remain in the execution and indexing systems that consume the extracted text.

References: unstract/…/helper.py• L67-98 unstract/…/x2text_adapter.py• L43-54

Execution handoff

The execution system treats text conversion as one operation in a larger document run. It supplies a file location and a configured text-extractor instance, then receives an extraction result that downstream operations can use.

The executor owns run context, storage choice, usage data, logs, and error reporting. The conversion service owns the request to the document parser and the conversion response. This boundary lets the executor change the selected extractor without changing the rest of the workflow.

References: workers/…/legacy_executor.py• L189-231 unstract/…/x2txt.py• L98-119

Conversion service

X2Text service

X2Text is the standalone conversion service used by the Unstructured text-extractor adapters. It accepts a source file and parser settings, forwards them to the configured Unstructured API, and returns the converted text as a downloadable text file.

The service exposes three broad operations:

  • A health check shows whether the service is running.
  • A connection test checks the configured parser URL and credentials.
  • Document processing converts an uploaded file to text.

The X2Text document conversion service page describes this service and its API in more detail.

References: x2text-service/README.md• L1-54 x2text-service/…/controller.py• L27-73 x2text-service/…/controller.py• L76-138

Extractor adapters

An extractor adapter is the execution-side connector for one text conversion provider. The SDK presents a common X2Text contract, so the workflow can use different providers while keeping the same input and output shape.

The adapter registry makes active providers available to the SDK. At run time, the configured adapter instance selects the provider settings and the X2Text service location. The adapter then sends the file through shared storage-aware helpers and returns extracted text to the executor.

References: unstract/…/register.py• L17-49 unstract/…/x2txt.py• L47-86 unstract/…/unstructured_community.py• L13-63

Document conversion flow

The flow below shows how a configured workflow moves a source file through execution, conversion, and the later extraction stages.

flowchart LR
    A[Source document] --> B[Workflow executor]
    B --> C[Configured X2Text adapter]
    C --> D[X2Text service]
    D --> E[External document parser]
    E --> F[Extracted text]
    F --> B
    B --> G[Chunking and field extraction]
    G --> H[Indexing or workflow output]

Request lifecycle

When the executor processes a document, it follows a short sequence:

  1. It reads the configured text-extractor instance and the source file location.
  2. It resolves the adapter and its service settings.
  3. It sends the file to the conversion service.
  4. It receives text and optional conversion metadata.
  5. It passes the result to the next workflow operation.

The service call is synchronous from the view of this operation. The wider document run can still be asynchronous because the execution system controls when the operation starts and how its result moves through the workflow.

References: workers/…/legacy_executor.py• L198-231 unstract/…/x2txt.py• L51-119 unstract/…/helper.py• L100-130

Service boundary controls

Authentication boundary

The standalone X2Text service protects connection tests and document processing with a platform bearer token. It checks that the token exists and is active before it accepts work. The health endpoint remains a liveness check and does not use the same protected operation path.

The adapter sends the platform token when it calls the service. The service uses the token to identify the organization for its audit record, while the parser credentials remain request settings for the external Unstructured API.

References: x2text-service/…/authentication_middleware.py• L10-61 x2text-service/…/authentication_middleware.py• L63-98 unstract/…/helper.py• L106-126

Audit boundary

The X2Text service records each document request with its organization, file details, and final status. This record describes conversion service activity; it does not replace the execution system's run state or workflow result.

Successful conversion returns a text file. Failed conversion preserves the service error response and marks the audit record as failed, so callers can distinguish a parser failure from a successful workflow handoff.

References: x2text-service/…/models.py• L17-29 x2text-service/…/controller.py• L92-138

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the X2Text service URL, route prefix, and adapter request path aligned. The adapter builds the service URL rather than discovering it at run time.
  • Keep the adapter instance configuration compatible with the provider settings and the service's form fields. A mismatch can fail before the external parser receives the file.
  • Keep the platform token contract aligned across the executor, adapter, and service authentication middleware. This token also controls organization attribution in the audit record.
  • Keep the conversion result shape aligned with the executor's handoff. Downstream extraction and indexing expect text rather than a parser-specific response body.
  • Keep audit schema changes aligned with the service startup schema and any upgrade migration.

Important failure modes

TriggerConsequenceGuard
Missing or inactive platform tokenProtected X2Text operations return unauthorized and no conversion starts.Validate the token before calling the service and keep the platform key active.
Missing parser URL or uploaded fileThe conversion request is rejected before the external parser runs.Provide the configured URL and a non-empty source file.
Unreachable parser or parser errorThe service marks the conversion as failed and returns an error to the executor.Use the connection test before processing and surface the returned status.
Unknown or unavailable adapter instanceThe executor cannot build the text extractor.Keep the workflow's adapter instance ID mapped to an active registered adapter.
Conversion result not passed back as textLater extraction or indexing cannot process the document.Preserve the shared text-extraction result contract.

Key files

FileWhy to read it
workers/…/legacy_executor.pyShows where document conversion begins and where the executor boundary supplies run context.
unstract/…/x2txt.pyShows the shared text-extraction boundary between workflow execution and provider adapters.
unstract/…/helper.pyShows how an adapter sends a file to the X2Text service and receives text.
unstract/…/register.pyShows how active text-extractor providers become selectable.
x2text-service/…/controller.pyShows the standalone service operations and their conversion result boundary.
x2text-service/…/authentication_middleware.pyShows the service access boundary and organization lookup.
x2text-service/…/models.pyShows the audit record that tracks conversion activity.