AI Units API request

I need to create an API requests that gets the number of AI units my organisation uses, I was wondering if anyone has been able to this?

I have checked the Swagger documentation but I couldn’t find anything would enable me to call thus data specifically.

Any help on this would be appreciated, thank you!

To retrieve the number of AI units that your organization currently uses, you can use the UiPath Orchestrator API. Here are the steps you can follow:

  1. Get an access token: To authenticate your API requests, you will need to obtain an access token. You can do this by sending a POST request to the Orchestrator API endpoint: /api/account/authenticate. You will need to include your Orchestrator username and password in the request body. The response will include an access token that you can use to make subsequent API requests.

  2. Retrieve organization information: To retrieve information about your organization, you can send a GET request to the Orchestrator API endpoint: /odata/Organizations. This will return a list of all the organizations that you have access to. You can filter the list to retrieve information about a specific organization by appending a $filter parameter to the request URL. For example, to retrieve information about the organization with the name “MyOrganization”, you can use the following URL: /odata/Organizations?$filter=DisplayName eq 'MyOrganization'.

  3. Retrieve AI units information: Once you have retrieved information about your organization, you can retrieve the AI units information by sending a GET request to the Orchestrator API endpoint: /odata/Settings/UiPath.Server.Configuration.OData.GetLicenseInfo. This will return information about your Orchestrator license, including the number of AI units that your organization currently uses.

Here’s an example of how you can retrieve the number of AI units using the UiPath Orchestrator API in Python:

import requests

# Orchestrator API endpoint URL
url = "https://<orchestrator_url>"

# Orchestrator username and password
username = "<username>"
password = "<password>"

# Authenticate and get access token
response = requests.post(url + "/api/account/authenticate", json={"tenancyName": "default", "usernameOrEmailAddress": username, "password": password})
access_token = response.json()["result"]

# Retrieve organization information
response = requests.get(url + "/odata/Organizations?$filter=DisplayName eq 'MyOrganization'", headers={"Authorization": "Bearer " + access_token})
organization_id = response.json()["value"][0]["Id"]

# Retrieve AI units information
response = requests.get(url + "/odata/Settings/UiPath.Server.Configuration.OData.GetLicenseInfo", headers={"Authorization": "Bearer " + access_token})
ai_units = response.json()["LicenseInfo"]["UsedLicenseUnits"]["AIUnits"]

print("Number of AI units used: " + str(ai_units))

Note: Replace <orchestrator_url>, <username>, <password>, and MyOrganization with your actual Orchestrator URL, username, password, and organization name, respectively. Also, make sure to install the requests library in your Python environment.

Hi @lashie,

Thank you for your response.

I tried using the /odata/Settings/UiPath.Server.Configuration.OData.GetLicenseInfo endpoint with the Orchestrator HTTP request in studio but it did return a successful output.

Instead I tried the /odata/Settings/UiPath.Server.Configuration.OData.GetLicense endpoint, this succesfully returned license information but unfortunately nothing on AI Units.

Would you know of another method of doing it through the Orchestrator HTTP request? I’m prohibited from using anything other than UiPath.

Many thanks,
David

Sorry for reviving this post so long after but I need to do the same thing as you and I would like to know if you found any solution to this?