Skip to main content
The following information applies to the legacy Unstructured Partition Endpoint.Unstructured recommends that you use the local-file processing jobs functionality in the Unstructured Pipeline API instead. Unstructured’s local-file processing jobs provide many benefits over the legacy Unstructured Partition Endpoint, including support for:
  • Production-level usage.
  • Multiple local input files in batches.
  • The latest and highest-performing models.
  • Post-transform enrichments.
  • All of Unstructured’s chunking strategies.
  • The generation of vector embeddings.
The Unstructured API also provides support for processing files and data in remote locations.
Do you want to run this quickstart without modifying your local machine? Skip ahead to run this quickstart as a notebook on Google Colab now!Do you want to just copy the sample code for use on your local machine? Skip ahead to the code now!This quickstart uses the Unstructured Partition Endpoint and focuses on a single, local file for ease-of-use demonstration purposes. This quickstart also focuses only on a limited set of Unstructured’s full capabilities. To unlock the full feature set, as well as use Unstructured to do large-scale batch processing of multiple files and semi-structured data that are stored in remote locations, skip over to an expanded, advanced version of this quickstart that uses the Unstructured Pipeline API instead.
The following code shows how to use the Unstructured Python SDK to have Unstructured process one or more local files by using the Unstructured Partition Endpoint. To run this code, you will need the following:
  • An Unstructured account and an Unstructured API key for your account. Learn how.
  • Python 3.9 or higher installed on your local machine.
  • A Python virtual environment is recommended for isolating and versioning Python project code dependencies, but this is not required. To create and activate a virtual environment, you can use a framework such as uv (recommended). Python provides a built-in framework named venv.
  • You must install the Unstructured Python SDK on your local machine, for example by running one of the following commands:
    • For uv, run uv add unstructured-client
    • For venv (or for no virtual environment), run pip install unstructured-client
  • Add the following code to a Python file on your local machine; make the following code changes; and then run the code file to see the results.
    • Replace <unstructured-api-key> with your Unstructured API key.
    • To process all files within a directory, change None for input_dir to a string that contains the path to the directory on your local machine. This can be a relative or absolute path.
    • To process specific files within a directory or across multiple directories, change None for input_file to a string that contains a comma-separated list of filepaths on your local machine, for example "./input/2507.13305v1.pdf,./input2/table-multi-row-column-cells.pdf". These filepaths can be relative or absolute.
      If input_dir and input_file are both set to something other than None, then the input_dir setting takes precedence, and the input_file setting is ignored.
    • For the output_dir parameter, specify a string that contains the path to the directory on your local machine that you want Unstructured to send its JSON output files. If the specified directory does not exist at that location, the code will create the missing directory for you. This path can be relative or absolute.
    If you choose to run this code in a notebook (such as a Google Colab notebook), you must do the following first to avoid nested event loop errors:
    1. Install the nest_asyncio Python package, by running the following command from a notebook cell:
    2. Import the nest_asyncio package and then enable nested event loops, by running the following code from a notebook cell:
    After completing these two steps, you can then run the following code as normal.

Sample code

Python SDK

Next steps

This quickstart shows how to use the Unstructured Partition Endpoint, which is intended for rapid prototyping of some of Unstructured’s partitioning strategies, with limited support for chunking. It is designed to work only with processing of local files. Take your code to the next level by switching over to the Unstructured Pipeline API for production-level scenarios, file processing in batches, files and data in remote locations, full support for chunking, generating embeddings, applying post-transform enrichments, using the latest and highest-performing models, and much more. Get started.