Endpoints with sparkles ✨ next to them are only available for Label Studio Enterprise and, in many cases, Starter Cloud users.
Version 2.0 of the Label Studio SDK is here, and it’s packed with more functionality and a smoother developer experience!
If you’re using an older version, please review the breaking changes before upgrading.
You can use the Label Studio Python SDK to make annotating data a more integrated part of your data science and machine learning pipelines. This software development kit (SDK) lets you call the Label Studio API directly from scripts using predefined classes and methods.
The following are basic examples. For more advanced examples, see Tutorials.
Install the Label Studio SDK using pip:
or
In Label Studio, “access tokens” and “API keys” mean the same thing and are used interchangeably.
For example, if you set the LABEL_STUDIO_API_KEY environment variable, you will set it to your access token.
In your Python scripts, you will need to do the following:
Import the SDK.
Define your Label Studio URL.
For example, http://localhost:8080 or https://app.humansignal.com
Note:
LABEL_STUDIO_URL should start with https:// or http://Define your access token/API key.
This should be available on the Account & Settings page, but you may need to enable it at the organization level first. See Access tokens.
You can use either the Legacy Token or the Personal Access Token, but for the SDK we recommend the Personal Access Token.
Connect to the API.
Try this example:
You can set LABEL_STUDIO_URL and LABEL_STUDIO_API_KEY as environment variables:
The SDK includes a CLI entrypoint that mirrors SDK resources and methods.
On leaf commands (for example projects create), use -h for minimal help (one-line summary, SDK signature, and options) and --help for the full generated documentation (parameters, examples, return shape, and options). Top-level groups only register --help.
If you are calling endpoints using HTTP (such as with cUrl commands), you will need to adjust your authorization header depending on which type of access token you are using.
Personal access tokens:
Legacy tokens:
For examples of getting started using SDK, see the following tutorials:
Advanced tutorials focused on ML backends:
SDK version < 1 is deprecated and no longer supported. We recommend upgrading to the latest version.
If you still want to use the older version, you can install it using pip install "label-studio-sdk<1".
You can also check out an older branch version in the GitHub repository:
Or you can simply modify you code to change the import stream as follows:
If you’re looking for the documentation for the older version, you can find it here.
If you encounter an error while using the Label Studio Python SDK, you can catch the error and handle it in your script.
Annotations are exported in the format specified in the Label Studio JSON format.
By default, requests time out after 5 seconds. You can configure this with a timeout option at the client or request level.
You can override the httpx client to customize it for your use case. Some common use cases include support for proxies and transports.