> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://api.labelstud.io/api-reference/introduction/getting-started/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://api.labelstud.io/_mcp/server. > **Note** > > Endpoints with sparkles ✨ next to them are only available for Label Studio Enterprise and, in many cases, Starter Cloud users. > **Version 2.0 is here!** > > 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](https://github.com/HumanSignal/label-studio-sdk/releases/tag/2.0.0) 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](/tutorials). > **Tip** > > If you are using our SDK with an LLM, you can use this: [https://api.labelstud.io/llms.txt](https://api.labelstud.io/llms.txt) ## Install Install the Label Studio SDK using pip: ``` pip install label-studio-sdk ``` or ``` poetry add label-studio-sdk ``` ## Authenticate and Connect to the API ### “API keys” vs. “Access tokens” 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. ### Python SDK 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: * Do not including a trailing slash in your URL * `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](https://labelstud.io/guide/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: ```python # Define the URL where Label Studio is accessible LABEL_STUDIO_URL = 'YOUR_BASE_URL' # API key is available at the Account & Settings page in Label Studio UI LABEL_STUDIO_API_KEY = 'YOUR_API_KEY' # Import the SDK and the client module from label_studio_sdk import LabelStudio # Connect to the Label Studio API client = LabelStudio(base_url=LABEL_STUDIO_URL, api_key=LABEL_STUDIO_API_KEY) # A basic request to verify connection is working me = client.users.whoami() print("username:", me.username) print("email:", me.email) ``` > **Tip** > > You can set `LABEL_STUDIO_URL` and `LABEL_STUDIO_API_KEY` as environment variables: > > ```bash > export LABEL_STUDIO_API_KEY="YOUR_API_KEY" > export LABEL_STUDIO_URL="YOUR_BASE_URL" > ``` ### SDK CLI 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`**. ```bash export LABEL_STUDIO_API_KEY="YOUR_API_KEY" export LABEL_STUDIO_URL="YOUR_BASE_URL" # minimal help for one command label-studio-sdk projects create -h # full help (longer) label-studio-sdk projects create --help # top-level label-studio-sdk --help # List projects label-studio-sdk projects list # Create a project (generic key=value params) label-studio-sdk projects create \ --param title="CLI Example" \ --param 'label_config=' ``` #### Running the CLI with uv ```bash # from PyPI uv run --with label_studio_sdk label-studio-sdk --help # from github uv run --with git+https://github.com/HumanSignal/label-studio-sdk.git label-studio-sdk --help # from local uv run --with-editable . label-studio-sdk --help ``` ### HTTP API 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: ```bash curl -X