UniteLabs
How-to

SDK installation

Install the UniteLabs SDK packages and send your first API request.

The UniteLabs SDK provides Python access to connected devices and Platform APIs. This guide creates a project, installs the SDK packages, configures client credentials, and sends a first API request. It assumes you have completed Set up your development machine. For endpoint details, see the REST API reference.

Prerequisites

UniteLabs requires Python 3.10 or newer. It is platform independent and works equally on Linux, macOS and Windows.

Some steps require authentication, therefore you need:

  • UniteLabs Artifactory Access A username and password to install UniteLabs Python packages. UniteLabs packages are not published to PyPI — they are hosted in a private GitLab package registry. This is separate from GroundControl and the Platform; it is simply where the Python packages live.
    • Username: 32 characters separated by dashes.
      Example: 56ae938f-484c-41cc-ae54-e4f9b8814fb7
    • Password: 22 characters separated by dashes.
      Example: ahjt-Lk-e1swOPZcWYYGh-mKJ
  • UniteLabs Client Credentials Client ID and secret to authenticate connections made from your local SDK installation (your code/client) to the UniteLabs API (the Platform).
    • Client ID: A custom username with variable length.
    • Client Secret: 32 characters without separators.
      Example: YT1a2HFEoi8tiAwl6bv127Tqp0ZXDSru
    • Tenant Base URL: the web address of your tenant's API.
      Example: https://api.<your-tenant>.unitelabs.io/
    • Tenant Auth URL: the sign-in endpoint of your tenant, including the realm ID.
      Example: https://auth.<your-tenant>.unitelabs.io/realms/<tenant-id>/protocol/openid-connect/

All of these come from UniteLabs. If you are missing one, the Get access page lists who to ask.

For local development you can skip the client ID and secret and log in with your own UniteLabs account through the UniteLabs CLI instead. You still need the Tenant Base URL. See Log in with the UniteLabs CLI.

Install Packages

We recommend installing the UniteLabs SDK using a Python virtual environment manager such as uv, Poetry, or venv. All packages are provided in a private package registry which requires configuration and authentication.

The examples below install unitelabs-liquid-handling. This package includes the Liquid Handling SDK, while the labware library unitelabs-labware and core UniteLabs SDK (unitelabs-sdk) typically need to be installed as well. See the parts of the system for the full breakdown.

Uv is a tool that manages dependencies, maintains a lockfile for reproducible installations, manages your virtual environment and can build packages for distribution.

If you have not used uv before, you can follow any of the options for installation in the official uv installation instructions.

1. Prepare uv

Uv reads the UniteLabs Artifactory Access from a user's .netrc file. Set it up as described in Set up registry access. See the official uv documentation for alternatives.

2. Setup Project

Terminal
uv init --package my-app
cd my-app

3. Install UniteLabs

Terminal
uv add unitelabs-liquid-handling \
  --index unitelabs=https://gitlab.com/api/v4/groups/1009252/-/packages/pypi/simple

The example below also uses python-dotenv. It lives on public PyPI, so it must not go through the private index:

Terminal
uv add python-dotenv

Authenticate Client

You need to authenticate your UniteLabs client to access the UniteLabs API on your behalf. There are two ways to do this:

  • Client credentials: a client ID and secret issued by UniteLabs. Use these for anything that runs unattended, such as deployed workflows, CI jobs and servers.
  • UniteLabs CLI login: log in once in your browser with your own UniteLabs account. Use this for local development on your own machine.

The SDK picks the method from the configuration it finds. If CLIENT_ID or CLIENT_SECRET is set, it uses client credentials. Otherwise it uses the token stored by the UniteLabs CLI.

Client credentials

We suggest to use python-dotenv to load the UniteLabs Client Credentials from a .env file in the root of your project.

.env
BASE_URL=https://api.<your-tenant>.unitelabs.io/
AUTH_URL=https://auth.<your-tenant>.unitelabs.io/realms/<tenant-id>/protocol/openid-connect/
CLIENT_ID=<client-id>
CLIENT_SECRET=<client-secret>

UniteLabs sometimes sends these four values as a filled env.txt. Move that file into your project root and rename it to .env. On Windows, enable file name extensions first, so no hidden .txt survives the rename (see Windows specifics). From PowerShell inside your project you can do both in one step:

PowerShell
Move-Item "$env:USERPROFILE\Downloads\env.txt" ".\.env"
BASE_URL contains neither the tenant UUID nor a /v1 suffix; the SDK appends /v1 itself. A 404 on /v1/secrets or /v1/workflows means the path is doubled.

Security note:
When using version control, make sure to exclude the .env file by e.g. adding it to the .gitignore file.

Log in with the UniteLabs CLI

The UniteLabs CLI (uctl) logs you in through your browser and stores the token in ~/.unitelabs/cache/ in your home folder (%USERPROFILE%\.unitelabs\cache\ on Windows). The SDK reads the token from there, so no client secret is saved in your project.

Only your user account can read the token files, but anyone who gets a copy of them can act as you until the token expires. Don't commit, sync or share the ~/.unitelabs/cache/ folder, and run uctl auth logout when you're done on a shared computer.

1. Install the CLI

Download the binary for your Platform from the UniteLabs CLI releases, make it executable and put it on your PATH:

Terminal
# macOS / Linux, adjust the file name for your OS and architecture
chmod +x uctl-darwin-arm64
sudo mv uctl-darwin-arm64 /usr/local/bin/uctl
uctl --version

On Windows, download uctl-windows-amd64.exe, rename it to uctl.exe and move it to a folder on your PATH.

2. Log in

Terminal
uctl configure     # create the "default" profile, enter your tenant's issuer URL and API base URL
uctl auth login    # opens your browser to log in
uctl auth status   # confirm you are logged in

uctl configure asks for:

  • Issuer URL: your Tenant Auth URL up to the realm ID, e.g. https://auth.<your-platform>.unitelabs.io/realms/<tenant-id>.
  • API base URL: the API address of your tenant, e.g. https://api.<tenant-id>.unitelabs.io, without the tenant UUID or a /v1 suffix. uctl auth login stores it next to your token, where the SDK finds it.

(<your-platform> should be a human-readable string like "academic" or "company-name", <tenant-id> is the 36-character UUID. You can see both of them when accessing your Platform: UUID in the top left and Platform in the url.)

3. Use the SDK

If you entered the API base URL in uctl configure, there is nothing else to set up and you don't need a .env file. Do not set CLIENT_ID or CLIENT_SECRET, otherwise the SDK uses client credentials instead.

A BASE_URL environment variable, or base_url passed to the client, takes precedence over the profile:

.env
BASE_URL=https://api.<your-tenant>.unitelabs.io/

If you skipped the API base URL, or change it later in ~/.unitelabs/uctl.yaml, run uctl auth login again so the SDK picks it up.

The SDK uses the CLI profile named default. To use a different profile, set UNITELABS_PROFILE to its name, e.g. UNITELABS_PROFILE=staging after uctl configure --profile staging and uctl auth login --profile staging.

The SDK reads the token once when the client is created and does not refresh it. When the token expires, the SDK raises an error asking you to log in again. Run uctl auth login and restart your script.

Send Your First Request

The SDK provides both asynchronous and synchronous clients. Choose based on your application's needs and personal preference:

  • AsyncApiClient (recommended): For modern async/await code, better performance with concurrent operations
  • SyncApiClient: For simple scripts or blocking code where async is not needed
src/my_app/__main__.py
import asyncio

from unitelabs.sdk import AsyncApiClient
from dotenv import load_dotenv


async def main():
  # Async example (recommended)
  client = AsyncApiClient()
  connectors = await client.list_services()
  for connector in connectors:
    print(connector.name)


if __name__ == "__main__":
  load_dotenv()
  asyncio.run(main())

Run the script to verify your credentials and confirm the SDK can reach the Platform. It should print the names of your connected instruments. This is just a smoke test; in real projects your entry point will vary.

Run the package's __main__.py file with:

Terminal
uv run python -m my_app

Troubleshooting

  • Packages download from public PyPI instead of the private registry, or the install fails with 302 or 401: the .netrc file is not being picked up. Check the file permissions (chmod 600), the file location, and that it has no Windows line endings.
  • 404 on /v1/secrets or /v1/workflows: the BASE_URL contains the tenant UUID or a /v1 suffix. Remove both; the SDK appends /v1 itself.
  • 401 when running the first request: CLIENT_ID or CLIENT_SECRET is wrong, or the AUTH_URL misses the realm part.
  • No token found for profile '<name>': you have not logged in with that profile yet, or you logged in with an earlier uctl version that stored the token in the OS keychain. Run uctl configure and uctl auth login (add --profile <name> for a profile other than default).
  • Token for profile '<name>' has expired: run uctl auth login again.
  • Failed to read the token for profile '<name>': the token file in ~/.unitelabs/cache/ exists but cannot be read. Check that your user account owns it, or run uctl auth login again.
  • Warning that unitelabs-sdk has no cli-auth extra when installing: the SDK no longer needs it. Remove [cli-auth] from your dependency.
  • Error about missing AUTH_URL or CLIENT_ID although you wanted to use the CLI login: one of CLIENT_ID or CLIENT_SECRET is still set in your .env or environment. Remove both.

Versions

The installation defaults to the latest version. Updates on versions and the corresponding changelogs are posted in the Python SDK changelog. If a defined version is required or needs to be locked, it must be explicitly defined using the Version Specifiers(==, !=, <, >, <=, >, >=) in the pyproject.toml.

pyproject.toml
[project]
requires-python = ">=3.10,<4.0"
dependencies = [
    "unitelabs-liquid-handling~=0.11.0",
    "python-dotenv",
]

Before you upgrade to a new version, read Migrate the UniteLabs SDK and Migrate the Liquid Handling SDK. It gives the changes that make it necessary to change your code.

Transitive dependencies

A package like unitelabs-liquid-handling itself depends on other UniteLabs packages, specifically unitelabs-sdk and unitelabs-labware. Those dependencies are pinned with compatible-release specifiers (~=) rather than exact versions. This is a deliberate choice: if every package pinned its dependencies to an exact version, a bug fix or compatibility update released for one package could only reach you once every package that depends on it had, in turn, published a new release pointing at it. A compatible-release specifier lets a fix in a dependency reach installations right away, without waiting on a coordinated release across the whole chain.

The specifier's granularity depends on how tightly a dependency's changes are coupled to the depending package's own code. unitelabs-sdk is pinned as ~=0.X, allowing any 0.Y release from 0.X onwards, since changes there rarely affect how unitelabs-liquid-handling uses it. unitelabs-labware is pinned more narrowly, as ~=0.Z.0, only allowing patch releases within 0.Z, since labware releases are more tightly coupled to liquid handling behavior and a minor release there is more likely to require a matching unitelabs-liquid-handling release to stay compatible.

Because a package's own dependencies are pinned with ~=, the exact set of versions you get can change between installs, even with the top-level package version unchanged. If your workflow needs a fully reproducible, exact set of versions, e.g. because it has already been validated against a specific combination and shouldn't drift, pin those transitive dependencies explicitly in your own pyproject.toml. An explicit pin always takes precedence over the compatible-release specifier the dependency was declared with.
pyproject.toml
[project]
dependencies = [
    "unitelabs-liquid-handling~=0.37.1",
    "unitelabs-sdk==0.17.0",
    "unitelabs-labware==0.36.1",
]

The installed versions can be checked using __version__:

__main__.py
from unitelabs import labware, liquid_handling, sdk

if __name__ == "__main__":
    print(sdk.__version__)
    print(labware.__version__)
    print(liquid_handling.__version__)

Run the file as explained above.

Note on client types:

  • Client from unitelabs.sdk is deprecated
  • Use AsyncApiClient (recommended) for async/await patterns
  • Use SyncApiClient for synchronous/blocking code
  • Both clients provide the same methods - the only difference is async vs sync execution

Connector versions

unitelabs-liquid-handling can sometimes rely on commands that only newer versions of liquid handler connectors provide. Compatible connector versions are stored within the SDK. Since unitelabs-liquid-handling version 0.40.0, the SDK automatically compares them against the version your connector reports the first time it connects, which is usually when your script sends its first command.

Print the requirements of your installed SDK with connector_compatibility:

__main__.py
from unitelabs import liquid_handling

if __name__ == "__main__":
    print(liquid_handling.connector_compatibility)
Output
{'microlab_star': '>=0.5.0', 'microlab_vantage': '>=0.7.0', 'biomek_i_series': '>=0.2.0', 'agilent_bravo': '>=0.9.0', 'tecan_freedom_evo': '>=0.6.0'}

If the connector is older than the required version, the SDK raises IncompatibleConnectorError and does not connect. No command reaches the instrument:

Output
unitelabs.liquid_handling.liquid_handler_protocol.IncompatibleConnectorError: Connector 'STAR' reports version 0.4.2, but unitelabs-liquid-handling 0.40.0 requires >=0.5.0. Update the connector or install a compatible SDK version.

Resolve the error by updating the connector (recommended), or by pinning unitelabs-liquid-handling to an older release whose requirement the connector meets.

The check runs every time the SDK reconnects. If the SDK cannot read the connector's version, it logs a warning to the console (stderr) instead of raising, connects anyway, and tries again on the next connection.

Importing the SDK and creating a liquid handler, such as MicrolabSTAR(name="STAR"), do not connect, so they never raise this error. The first call that reaches the connector does, which in a typical workflow is await lh.configure(). Call configure() at the start of your workflow, before steps such as moving plates or starting other instruments, so an incompatible connector stops the run before anything has happened.

IDE Integration

VSCode

.vscode/extensions.json
{
  "recommendations": ["ms-python.python"]
}
.vscode/settings.json
{
  "python.defaultInterpreterPath": ".venv/bin/python",
  "python.terminal.activateEnvironment": false
}

On Windows, set python.defaultInterpreterPath to .venv/Scripts/python.exe instead, with forward slashes so the JSON stays valid. Or skip the setting and pick the interpreter through the Command Palette with Python: Select Interpreter.

Jupyter Notebooks

Prefer Jupyter for exploration? Install ipykernel as a dev dependency and run SDK calls interactively in notebook cells — all async methods work via await in Jupyter without an explicit asyncio.run() wrapper.
Terminal
uv add --dev ipykernel
All SDK calls work identically in Jupyter. This is useful for prototyping and exploring connectors interactively before writing a script.

Next steps

Your first request already listed the connected instruments. Control a device shows how to inspect one and call its actions.

Last updated