Datalab Python SDK
raw JSON → 0.5.0 verified Sat May 09 auth: no python
SDK for the Datalab document intelligence API. Current version 0.5.0, requires Python >=3.10. Released on a monthly cadence, still in early active development.
pip install datalab-python-sdk Common errors
error ImportError: cannot import name 'DatalabClient' from 'datalab' ↓
cause Library not installed or wrong Python environment.
fix
Run
pip install datalab-python-sdk and check Python version >=3.10. error TypeError: __init__() got an unexpected keyword argument 'token' ↓
cause Using deprecated parameter name `token` (renamed in v0.5.0).
fix
Replace
token= with api_key=. error ValueError: API key is required ↓
cause No API key provided or key is empty string.
fix
Set environment variable
DATALAB_API_KEY or pass api_key='your_key'. Warnings
breaking In version 0.5.0, the `extract` method changed from returning a list to returning a dict. ↓
fix Update code to handle dict response: `result['fields']` instead of `result[0]`.
deprecated `DatalabClient` constructor parameter `token` has been renamed to `api_key`. ↓
fix Use `api_key='your_key'` instead of `token='your_token'`.
gotcha API key must be passed as a keyword argument, not positional. ↓
fix Always use `DatalabClient(api_key='...')`.
Imports
- DatalabClient
from datalab import DatalabClient - DatalabError
from datalab import DatalabError
Quickstart
import os
from datalab import DatalabClient
client = DatalabClient(api_key=os.environ.get('DATALAB_API_KEY', ''))
result = client.extract(
file_path='invoice.pdf',
document_type='invoice',
fields=['total', 'date', 'vendor']
)
print(result)