Skip to content

Client libraries

UbiOps offers client libraries that allow for easy integration of UbiOps functionality into your project. The libraries offer the same functionality as the API. More advanced information about these client libraries can be found on our Github page.


The UbiOps client library (Python) is available on PyPi and can be installed using PIP:

pip install ubiops

Compatibility matrix

Client library API v1.1 API v2.1
ubiops 2.1.0 - old 'model' endpoints
ubiops 3.* -


To test if everything works properly, you can run the snippet below. Please, fill in your own API token (<YOUR_API_KEY>). Documentation on creating an API token can be found here.

import ubiops

configuration = ubiops.Configuration()
configuration.api_key['Authorization'] = 'Token <YOUR_API_KEY>'

client = ubiops.ApiClient(configuration)
api = ubiops.api.CoreApi(client)



More comprehensive information about the client library functionality can be found on Github.

Example deployment

The examples folder in the Github repository contains Jupyter notebooks which show how to create a deployment and pipeline on UbiOps using the Python client library.

Example usage inside deployment

The UbiOps client library can be used inside a deployment package. This is useful, for example, if you want to make a request to another deployment.

An example deployment, which returns the number of deployments in the project, is shown below. The full example deployment package, including requirements.txt, can be downloaded from here.

Upload this example to a deployment containing a structured input field project_name and structured output field n_deployments. An environment variable will be used to pass the API_TOKEN. Therefore, create an environment variable API_TOKEN for your deployment.

import ubiops
from os import environ

class Deployment:

    def __init__(self, base_directory, context):
        api_token = environ['API_TOKEN']  # formatted like 'Token .....'

        conf = ubiops.Configuration()
        conf.api_key['Authorization'] = api_token
        self.client = ubiops.ApiClient(conf)
        self.core_api = ubiops.api.CoreApi(self.client)

    def request(self, data):
        deployments = self.core_api.deployments_list(

        # You could create more api calls here.
        # For example, creating a request to deployment 'my-deployment'
        # version 'my-version':
        # request_results = self.core_api.deployment_requests_create(
        #     project_name=data['project_name'],
        #     deployment_name='my-deployment',
        #     version='my-version',
        #     data=data
        # )

        # Here we will close the opened connection to the api.
        # When you use self.core_api again, a new connection will be opened.

        return {
            "n_deployments": len(deployments)