Unitlab.ai is an AI-driven data annotation platform that automates the collection of raw data, facilitating collaboration with human annotators to produce highly accurate labels for your machine learning models. With our service, you can optimize work efficiency, improve data quality, and reduce costs.
Python SDK and CLI for the Unitlab.ai data annotation platform. Manage projects, upload data, and download datasets programmatically or from the command line.
pip install --upgrade unitlabRequires Python 3.10+.
Get your API key from unitlab.ai and configure the CLI:
# Set API key
unitlab configure --api-key YOUR_API_KEY
# Set a custom API URL
unitlab configure --api-url https://api.unitlab.ai
# Set both at once
unitlab configure --api-key YOUR_API_KEY --api-url https://api.unitlab.aiOr set environment variables:
export UNITLAB_API_KEY=YOUR_API_KEY
# Optional: point to a custom API server (e.g. self-hosted)
export UNITLAB_API_URL=https://api.unitlab.aifrom unitlab import UnitlabClient
# Initialize with an explicit key
client = UnitlabClient(api_key="YOUR_API_KEY")
# Or read from UNITLAB_API_KEY env var / config file
client = UnitlabClient()The client can also be used as a context manager:
with UnitlabClient() as client:
projects = client.projects()# List all projects
projects = client.projects()
# Get project details
project = client.project("PROJECT_ID")
# Get project members
members = client.project_members("PROJECT_ID")client.project_upload_data(
project_id="PROJECT_ID",
directory="./images",
)The upload command accepts mixed directories. File type is detected per file from
the supported extensions: images, text, video, audio, medical
(.dcm, .nii, .nii.gz, .nrrd), and documents (.pdf).
Additional options for specific file types:
# Text files
client.project_upload_data("PROJECT_ID", "./docs", sentences_per_chunk=10)
# Video files
client.project_upload_data("PROJECT_ID", "./videos", fps=30.0)
# PDF documents
client.project_upload_data("PROJECT_ID", "./pdfs")
# DICOM, NIfTI, and NRRD medical volumes
client.project_upload_data("PROJECT_ID", "./medical")# List all datasets
datasets = client.datasets()
# Download one annotation split using the release's fixed export format
path = client.dataset_download("DATASET_ID", split_type="train")
# Omit split_type to download all available splits as one bundle
path = client.dataset_download("DATASET_ID")
# Download raw files
folder = client.dataset_download_files("DATASET_ID")# List projects
unitlab project list
# Project details
unitlab project detail PROJECT_ID
# Project members
unitlab project members PROJECT_ID
# Upload data to a project
unitlab project upload PROJECT_ID --directory ./images
# Upload PDFs or medical volumes with the same command
unitlab project upload PROJECT_ID --directory ./pdfs
unitlab project upload PROJECT_ID --directory ./medical# List datasets
unitlab dataset list
# Download one annotation split using the release's fixed export format
unitlab dataset download DATASET_ID --split-type train
# Download all annotation splits as one bundle
unitlab dataset download DATASET_ID
# Download raw files
unitlab dataset download DATASET_ID --download-type filesSee the full documentation for detailed guides:

