Installation
Authentication
Set your API key as an environment variable (recommended):Quick Example
Client Options
Both sync and async clients accept the same configuration options:| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | DATALAB_API_KEY env var | Your Datalab API key |
base_url | str | https://www.datalab.to | API base URL |
timeout | int | 300 | Request timeout in seconds |
Async Support
For high-throughput applications, useAsyncDatalabClient:
Error Handling
The SDK raises specific exceptions for different error types:| Exception | Description |
|---|---|
DatalabAPIError | API returned an error response (includes status_code and response_data) |
DatalabTimeoutError | Request exceeded timeout |
DatalabFileError | File not found or cannot be read |
DatalabValidationError | Invalid parameters provided |
Automatic Retries
The SDK automatically retries requests for:408Request Timeout429Rate Limit Exceeded5xxServer Errors
max_polls and poll_interval parameters on individual methods.
SDK Features
Document Conversion
Convert PDFs, images, and documents to Markdown, HTML, JSON, or chunks.
Form Filling
Fill PDF and image forms with structured field data.
File Management
Upload, list, and manage files in Datalab storage.
Workflows
Create and execute document processing pipelines.
CLI
Command-line interface for document conversion.
Method Summary
| Method | Description |
|---|---|
convert() | Convert documents to markdown, HTML, JSON, or chunks |
fill() | Fill PDF or image forms with field data |
upload_files() | Upload files to Datalab storage |
list_files() | List uploaded files |
get_file_metadata() | Get metadata for a specific file |
get_file_download_url() | Generate presigned download URL |
delete_file() | Delete an uploaded file |
create_workflow() | Create a workflow definition |
execute_workflow() | Execute a workflow |
get_execution_status() | Check workflow execution status |
list_workflows() | List all workflows |
get_workflow() | Get a workflow by ID |
delete_workflow() | Delete a workflow |
get_step_types() | Get available workflow step types |
Try Datalab
Get started with our API in less than a minute. We include free credits.