- A Datalab account with an API key (new accounts include $5 in free credits)
- Python 3.10+ installed
- The Datalab SDK:
pip install datalab-python-sdk - Your
DATALAB_API_KEYenvironment variable set
EU requests return a signed
result_url; the REST examples below download it before reading the output. See Regional Result Downloads, including the Python SDK 0.5.0 limitation.Building for production? Use Pipelines to chain processors, version your configuration, and deploy with a single API call.
Choose Page or Block Boundaries
With fast or balanced parsing, the standard block-level base rate is $4.50 / 1K pages. Accurate parsing costs more. See Billing for regional and account pricing.
Quick Start
This example requests page boundaries without parsing the text.When to Use
Segmentation is useful when:- Batch-scanned documents are combined into a single PDF
- Multiple document types are stapled together
- You need to apply different processing to different sections
Block-Level Segmentation
Use block boundaries when multiple documents share a page. The parsed output belongs to the whole document; use each segment’sstart_block, end_block, and blocks references to locate its content. Splitting only by pages can include content from neighboring segments.
Segmentation Schema
Pass a JSON-encoded object insegmentation_schema:
Response Format
Example page-boundary result:Process Each Segment
After page-level segmentation, process each segment separately. The example below handles names matchingInvoice or Contract; adapt the routing to the names in your results.
Using Checkpoints
If you already converted a document withsave_checkpoint=True using the Convert API, pass the checkpoint_id to SegmentOptions to skip re-parsing. This saves time and cost when running segmentation on a previously converted document.
Custom Segmentation Schema
Define expected segment types withname and description. Named segmentation requires parsed content. Automatic segment names are generated from the document and are not guaranteed to match your application labels.
Next Steps
Structured Extraction
Extract structured data from document segments using JSON schemas.
Handling Long Documents
Tips for TOC-based segmentation on documents with 50+ pages.
Document Conversion
Convert documents to Markdown, HTML, JSON, or chunks.
Pipelines
Chain processors into versioned, reusable pipelines.