Skip to main content

Generate sample code

Transform can generate sample curl or Python code from the partitioning process it just ran. Use this code to run Transform in your production environment at scale. First, connect your AI tool to the Transform MCP server and have Transform partition your source files. Then ask your AI tool the following:
To generate the curl code as downloadable shell script (.sh) files, ask your AI tool the following:
See the next section for how to run this code locally.

Run sample code

If your local development environment is already set up, skip ahead to get your Unstructured API key and URL.
Before you can run the generated example curl or Python code, you must set up your local development environment. This includes installing curl or Python locally, installing the Unstructured Python SDK locally if you’re using Python, and defining and setting two unique local environment variables, which the example code refers to and relies upon.

Install curl

curl installation instructions vary by operating system and download manager utility. See the curl Download page or the documentation for your operating system or download manager utility.

Install Python and the SDK

Python installation instructions vary by operating system and download manager utility. See the Download Python page or the documentation for your operating system or download manager utility. Unstructured recommends that you install the Python SDK into a Python virtual environment, such as uv. This enables you to isolate and manage various Python package dependencies for your Python projects. Learn more about Python virtual environments. To download and install the Unstructured Python SDK by using uv, run a command such as the following from within a uv virtual environment:
For Python package managers other than uv, see your package manager provider’s documentation.

Define environment variables

Your local development environment must have access to the following two environment variables:
  • UNSTRUCTURED_API_KEY, which represents the programmatic access identifier for your user account in the Transform service. Each call to the Transform service requires this identifier so that the correct user account is billed (or any remaining free page counts are reduced) accordingly.
  • UNSTRUCTURED_API_URL, which represents the programmatic API endpoint for the Unstructured Transform service. This service contains the file partitioning logic and orchestrates all file processing jobs.
To define these environment variables (for example, by setting an export or setx command or equivalent), see your environment’s documentation. To set these environment variables to the appropriate values, see the following sections.

Get your Unstructured API key and URL

  1. Sign in to Unstructured Transform, if you have not already done so, at https://transform.unstructured.io.
  2. On the sidebar, click API Keys.
  3. In the API Key field, click the pages icon (Copy) to copy your Unstructured API key.
  4. Set your UNSTRUCTURED_API_KEY environment variable to this value.
  5. In the API URL field, click the pages icon (Copy) to copy your Unstructured API URL.
  6. Set your UNSTRUCTURED_API_URL environment variable to this value.

View Transform API documentation

Unstructured Transform uses the Unstructured API. To view the related API reference documentation, see the following:

Next steps