{"id":3530,"library":"label-studio-sdk","title":"Label Studio SDK","description":"The `label-studio-sdk` is the official Python client library for interacting with the Label Studio API. It provides programmatic access to manage projects, tasks, annotations, import/export data, and automate various data labeling workflows. It is currently at version 2.0.19 and maintains a regular release cadence with frequent updates adding new features and API endpoint support.","status":"active","version":"2.0.19","language":"en","source_language":"en","source_url":"https://github.com/HumanSignal/label-studio-sdk","tags":["data labeling","machine learning","api client","annotation","ai"],"install":[{"cmd":"pip install label-studio-sdk","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"HTTP client for API communication.","package":"requests","optional":false},{"reason":"Used for data validation and parsing API responses into models.","package":"pydantic","optional":false},{"reason":"For image processing related to data handling.","package":"Pillow","optional":false},{"reason":"For loading environment variables (e.g., API keys) from .env files.","package":"python-dotenv","optional":false}],"imports":[{"symbol":"Client","correct":"from label_studio_sdk import Client"},{"note":"Project objects are typically accessed via the Client instance (e.g., `ls.get_projects()[0]`) or from `label_studio_sdk.objects` directly, not `client`.","wrong":"from label_studio_sdk.client import Project","symbol":"Project","correct":"from label_studio_sdk.objects import Project"}],"quickstart":{"code":"import os\nfrom label_studio_sdk import Client\n\n# Set your Label Studio URL and API Key\n# It's recommended to set these as environment variables\nLABEL_STUDIO_URL = os.environ.get('LABEL_STUDIO_URL', 'http://localhost:8080')\nLABEL_STUDIO_API_KEY = os.environ.get('LABEL_STUDIO_API_KEY', 'YOUR_API_KEY_HERE') # Replace with your actual API key if not in env\n\nif not LABEL_STUDIO_API_KEY or LABEL_STUDIO_API_KEY == 'YOUR_API_KEY_HERE':\n    print(\"Warning: LABEL_STUDIO_API_KEY not set. Please set it as an environment variable or replace 'YOUR_API_KEY_HERE'.\")\n    exit()\n\ntry:\n    # Initialize the Label Studio client\n    ls = Client(url=LABEL_STUDIO_URL, api_key=LABEL_STUDIO_API_KEY)\n    \n    # Test connection and fetch projects\n    projects = ls.get_projects()\n    print(f\"Successfully connected to Label Studio at {LABEL_STUDIO_URL}.\")\n    print(f\"Found {len(projects)} projects:\")\n    for p in projects:\n        print(f\"  - Project ID: {p.id}, Title: {p.title}\")\n\nexcept Exception as e:\n    print(f\"Error connecting to Label Studio or fetching projects: {e}\")\n    print(\"Please ensure LABEL_STUDIO_URL and LABEL_STUDIO_API_KEY are correct and Label Studio is running.\")","lang":"python","description":"Initializes the Label Studio client, connects to your instance, and lists all available projects. Ensure `LABEL_STUDIO_URL` and `LABEL_STUDIO_API_KEY` are set either as environment variables or directly in the code."},"warnings":[{"fix":"Refer to the official migration guide for updating your code to use the v2.x API client: https://labelstud.io/guide/sdk_migrate_v1_v2/","message":"The SDK underwent a significant overhaul from v1.x to v2.x, introducing numerous breaking changes in client initialization, method names, object structures, and pagination handling. Code written for v1.x will not work with v2.x.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Ensure you pass a valid `project` ID when calling these storage list endpoints, for example: `ls.get_s3_import_storages(project=your_project_id)`.","message":"Starting from v2.0.13, the `project` argument became a required parameter for all Import and Export Storage list endpoints (e.g., S3, Google Cloud Storage, Azure Blob Storage).","severity":"breaking","affected_versions":">=2.0.13"},{"fix":"Verify that the feature you are trying to use is supported by your Label Studio edition. Check the official Label Studio documentation for feature availability per edition.","message":"Some advanced features and API endpoints, particularly those related to Finite State Management (FSM) or Workspace management, are exclusive to Label Studio Enterprise (LSE). Attempts to use them with the Community Edition will result in API errors.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Consult the SDK documentation for specific methods and their pagination arguments (e.g., `page_size`, `page`). You may need to loop through results until all pages are retrieved.","message":"For large datasets, methods that retrieve lists of resources (e.g., tasks, annotations, members) may require explicit pagination to fetch all items. The SDK provides mechanisms to iterate through pages.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}