Learn how to install and initialize the Labellerr SDK, a Python library for seamless interaction with the Labellerr platform to manage data annotations, projects, and exports.
New version v2.0.0 of the SDK is available with major improvements and new features. See the Changelog for details and upgrade notes.
The Labellerr SDK is a Python library designed to make interaction with the Labellerr platform simple and efficient. With this SDK, you can manage data annotations, projects, and exports seamlessly in your applications.This documentation will guide you through installing the SDK, understanding its core functionalities, and handling common errors.
from labellerr.client import LabellerrClientfrom labellerr.core.exceptions import LabellerrError# Initialize the client with your API credentialsapi_key = "your-api-key"api_secret = "your-api-secret"client_id = "your-client-id"client = LabellerrClient(api_key, api_secret, client_id)
The Labellerr SDK supports seamless integration with cloud storage providers like AWS S3 and Google Cloud Storage (GCS). You can create, test, list, and manage connections programmatically.
Required PermissionsBefore creating cloud connections, ensure your IAM user (S3) or Service Account (GCS) has the required permissions:
S3 Connection with Explicit Path TestingFor AWS S3 connections, you must provide a specific path to test the connection. The SDK will validate access to that exact path in your S3 bucket.
Create and Test S3 Connection
Copy
from labellerr.client import LabellerrClientfrom labellerr.core.connectors import LabellerrS3Connectionfrom labellerr.core.schemas import AWSConnectionParams, AWSConnectionTestParamsfrom labellerr.core.exceptions import LabellerrError# Initialize clientclient = LabellerrClient(api_key, api_secret, client_id)try: # Test S3 connection first (recommended) test_params = AWSConnectionTestParams( aws_access_key="your_aws_access_key", aws_secrets_key="your_aws_secret_key", path="s3://your-bucket-name/path/to/data", # Explicit path required data_type="image", connection_type="import" ) test_result = LabellerrS3Connection.test_connection(client, test_params) print(f"Connection test result: {test_result}") # If test succeeds, create the connection connection_params = AWSConnectionParams( client_id=client_id, aws_access_key="your_aws_access_key", aws_secrets_key="your_aws_secret_key", path="s3://your-bucket-name/path/to/data", data_type="image", name="My S3 Connection", description="Production data bucket", connection_type="import" ) # create_connection automatically tests before creating s3_connection = LabellerrS3Connection.create_connection(client, connection_params) print(f"✓ S3 Connection created: {s3_connection.connection_id}")except LabellerrError as e: print(f"Connection failed: {str(e)}")
Path Validation:
The path must be accessible with the provided credentials
Path format: s3://bucket-name/folder/subfolder
Test fails if permissions are insufficient or path doesn’t exist
GCS Connection with Service AccountFor Google Cloud Storage, you need to provide a service account JSON file. The connection test validates both credentials and path access.
Create and Test GCS Connection
Copy
from labellerr.client import LabellerrClientfrom labellerr.core.connectors import LabellerrGCSConnectionfrom labellerr.core.schemas import GCSConnectionParams, GCSConnectionTestParamsfrom labellerr.core.exceptions import LabellerrError# Initialize clientclient = LabellerrClient(api_key, api_secret, client_id)try: # Test GCS connection first (recommended) test_params = GCSConnectionTestParams( svc_account_json="/path/to/service-account.json", path="gs://your-bucket-name/path/to/data", data_type="image", connection_type="import" ) test_result = LabellerrGCSConnection.test_connection(client, test_params) print(f"Connection test result: {test_result}") # If test succeeds, create the connection connection_params = GCSConnectionParams( client_id=client_id, svc_account_json="/path/to/service-account.json", path="gs://your-bucket-name/path/to/data", data_type="image", name="My GCS Connection", description="Production GCS bucket", connection_type="import" ) # create_connection automatically tests before creating gcs_connection = LabellerrGCSConnection.create_connection(client, connection_params) print(f"✓ GCS Connection created: {gcs_connection.connection_id}")except LabellerrError as e: print(f"Connection failed: {str(e)}")
Service Account Requirements:
Service account must have Storage Object Viewer permission (minimum)
JSON key file must be valid and accessible
Path must exist in the specified GCS bucket
List and Manage Connections
Copy
from labellerr.client import LabellerrClientfrom labellerr.core.connectors import list_connections, delete_connectionfrom labellerr.core.schemas import ConnectorType, ConnectionTypefrom labellerr.core.exceptions import LabellerrError# Initialize clientclient = LabellerrClient(api_key, api_secret, client_id)try: # List all S3 connections s3_connections = list_connections( client=client, connector=ConnectorType._S3, connection_type=ConnectionType.IMPORT ) print("Available S3 Connections:") for conn in s3_connections: print(f"- ID: {conn.connection_id}") # List all GCS connections gcs_connections = list_connections( client=client, connector=ConnectorType._GCS ) print("Available GCS Connections:") for conn in gcs_connections: print(f"- ID: {conn.connection_id}") # Delete a connection if needed # delete_response = delete_connection(client, connection_id="connection_id_here") # print(f"Connection deleted: {delete_response}")except LabellerrError as e: print(f"Operation failed: {str(e)}")
Connection Testing Best PracticesAlways test your connection before creating datasets:
Explicit Path Testing (S3): Provide the exact S3 path you’ll use for data access
Implicit Validation (GCS): GCS connections validate both credentials and path accessibility
Error Handling: Wrap connection operations in try-except blocks
Credential Security: Never hardcode credentials; use environment variables or secret managers
Once you’ve created and tested a cloud connection (S3 or GCS), you can use it to create datasets directly from your cloud storage. This allows you to manage large volumes of files without manual uploads, and keeps your data in sync with your existing cloud infrastructure.
Visit your workspace API keys page at https://<your-workspace-name>.labellerr.com/workspace/api-keys and click the Show Client ID button to reveal and copy your client ID.
Where can I find my API credentials?
You can obtain your api_key and api_secret by visiting: https://<your-workspace-name>.labellerr.com/workspace/api-keys