Skip to main content

Installation

The CLI is included with the SDK:

Authentication

Set your API key as an environment variable:
Or pass it with each command:
Or sign in once with a device code:
datalab login saves the key to ~/.config/datalab/config.json, readable only by your user. Every datalab command uses it when --api_key is not passed and DATALAB_API_KEY is not set, but only for the host you signed in to. For another --base_url, run datalab login --host <url> or pass a key.
datalab login needs SDK 0.7.0 or newer.

Convert Documents

Convert documents to markdown, HTML, JSON, or chunks.

Basic Usage

Output Options

Processing Options

Advanced Options

Directory Processing

Convert all documents in a directory:
Each input saves to its own folder under the output directory, which mirrors the input directory. For example, ./documents/a/report.pdf saves to ./output/a/report/report.md, with its images in the same folder, so files with the same name in different folders keep separate results. Without --output_dir, results go to ./output/; pass --output_dir . to save them in the working directory, as before SDK 0.14.0. The CLI prints the full output path when a run starts and in its summary. Each output folder holds a .datalab-output file with the input’s file name. A directory scan skips these folders, so running the same command again does not process its own output. The CLI checks every output folder before it submits anything. It stops if two inputs would share a folder (for example report.pdf and report.docx in the same folder; process one type with --extensions pdf), if a folder already exists and was not made by the CLI, if a folder holds another input’s results from an earlier run, or if one input’s folder would be inside another’s (for example report.pdf next to a report/ folder of documents).

Convert Command Reference

Extract Structured Data

Extract structured data from documents using a JSON schema.

Basic Usage

To request phrase citations with SDK 0.9.2 or later (open beta; the format may change):

Extract Command Reference

Segment Documents

Segment documents into logical sections using a schema.

Basic Usage

Segment Command Reference

Track Changes

Extract tracked changes from DOCX files, PDFs, and images. DOCX files use exact XML extraction; PDFs and images use a vision model.

Basic Usage

Track Changes Command Reference

Published Processor (Beta)

This feature is currently in beta. The API may change.
Run an existing published processor that your team can access:
The processor determines its task and output format. See Run a Published Processor for prerequisites and SDK examples.

Create Document

Create a DOCX document from markdown with track changes.

Basic Usage

Create Document Command Reference

Compare (Open Beta)

This feature is currently in beta. The API may change.
Compare 2 to 4 variants of a pipeline on the same files, and see which one reads them best. See Compare with the SDK and API for the request and response shapes. These commands need SDK 0.11.0 or later. datalab eval is the deprecated SDK 0.10.0 name of these commands.
The summary from run --wait and get lists each variant’s share and each file’s ID, which compare differences takes (SDK 0.15.0 or later).

Exit Status

The document commands (convert, extract, segment, track-changes, fill, form-fields, agent and create-document) exit with status 1 when any file fails, so scripts and CI jobs can check the result. Invalid options exit with status 2. After a run over several files, the summary gives the number of files that succeeded and failed, and names each failed file with its error. It names the output directory only when the run saved results to it, and says No output was saved. when it saved none. A run that saves nothing leaves no empty output directory behind. compare run --wait exits with status 1 when the comparison fails or any of its files fails. Skipped files don’t count as failures. compare get exits 0 for a failed comparison, because it reports the status it read.

Examples

Batch Convert PDFs

Extract Data from Documents

High-Throughput Processing

Getting Help

Next Steps

Quickstart

Get up and running with Datalab in minutes.

Batch Processing

Process multiple documents efficiently in parallel.

SDK Reference

Explore the full Python SDK for advanced usage.

Supported File Types

See all document formats supported by Datalab.