Skip to content

datalab-to/sdk

Repository files navigation

Datalab SDK

A Python SDK for the Datalab API - a document intelligence platform powered by marker and surya.

See the full documentation at https://documentation.datalab.to.

Installation

pip install datalab-python-sdk

Quick Start

Authentication

Get your API key from https://www.datalab.to/app/keys:

export DATALAB_API_KEY="your_api_key_here"

Basic Usage

from datalab_sdk import DatalabClient

client = DatalabClient() # use env var from above, or pass api_key="your_api_key_here"

# Convert PDF to markdown
result = client.convert("document.pdf")
print(result.markdown)

# OCR a document
ocr_result = client.ocr("document.pdf")
print(ocr_result.pages)  # Get all text as string

Workflows

Workflows allow you to chain multiple document processing steps together. Each workflow consists of one or more steps that can depend on previous steps.

Note: All workflow operations require authentication. Make sure you have set your DATALAB_API_KEY environment variable or pass api_key when creating the client (see Authentication section above).

For more Workflow tips, see our examples here and documentation.

CLI Usage

The SDK includes a command-line interface:

# Convert document to markdown
datalab convert document.pdf

# OCR with JSON output
datalab ocr document.pdf --output-format json

# Workflow commands
datalab create-workflow --help
datalab execute-workflow --help
datalab get-execution-status --help
datalab list-workflows --help
datalab get-workflow --help
datalab visualize-workflow --help

License

MIT License