AI Center
latest
false
Banner background image
AI Center
Last updated Apr 18, 2024

ML Skills

Check this section for examples on how to use ML Skills.

Save infrastructure costs using AI Center APIs

With the API requests, you can programmatically change the state of an ML Skill. These APIs could be used even within an automation workflow to deploy and undeploy an ML Skill, optimizing the uptime for infrastructure and saving costs. See the complete set of AI Center APIs documented in swagger.

Note that accountname and tenantname are specific to your account. For more information, see the API list.

You use the AI Center APIs to:

  1. Find the ML Skill ID of sampleClassifierSkill
  2. Stop (undeploy) the ML Skill
  3. Start (redeploy) and verify the status update.

In November 2022, we announced the availability of APIs to programmatically interact with every component within AI Center. You can now manage datasets, train ML models, and deploy ML Skills using APIs, without having to use the User interface.

One of the key use-cases for leveraging APIs is to manage the deployment status of an ML Skill. Depending on the automation, you may not need an ML Skill to be active all the time. Undeploying ML Skills when not in use can help you save on hardware costs (AI units).

The steps to access AI Center APIs are:

  1. Registering an external application (one-time setup)
  2. Generating an authentication token (renew upon expiry)
  3. Making AI Center API calls
Note: The first two steps enforce access control by making sure your application is registered and authenticated

Registering an external application

To use the APIs, your app needs to register as an external application with an AI Center scope.

  1. From the left navigation panel, go to the Admin page and select External Applications.
  2. To add a new external application, select + Add Application

    and name it.

    Note: Onlyconfidential application type can access AI Center APIs.
  3. To enable AI Center scope to the external application:
    1. Select Add scope
    2. Pick AI Center API Access (preview) from the Resource dropdown
    3. Navigate to the Application Scope tab
    4. Select the APIs to which you want to enable access to.
    In the example below, all the APIs are selected for simplicity, but you can choose to assign specific APIs access to specific external applications.


  4. Select Add. A pop up with App ID and an App Secret is generated.
    Tip: You can view the App ID and App Secret anytime from the Edit External application. These credentials are used to generate an authentication token in the next step. See additional information on managing external applications.


Generating an authentication token

For authentication and secure access, the external application requests an access token from the UiPath identity server. The generated authentication token expires in one hour, upon which you need to regenerate a new auth token.

If you want to use Postman, you can register for free and choose to use either the Postman web-based interface or the downloadable application. See the official Postman website.

  1. Generate a POST request to the Identity Server endpoint https://cloud.uipath.com/identity_/connect/token that includes the following in the body of the request.
    client_id: App ID from previous step
    client_secret: App Secret from previous step
    grant_type: “client_credentials”client_id: App ID from previous step
    client_secret: App Secret from previous step
    grant_type: “client_credentials”
  2. Set grant_type to client_credentials.
Use the application/x-www-form-urlencoded content type for Postman.


This request generates an auth token similar to the one below, listing the permissions enabled for this external application. Use this auth token when making AI Center API calls.


See additional information on credentials and auth tokens.

Making AI Center API calls

The API calls adhere to the following structure: https://cloud.uipath.com/accountname/tenantname/aifabric_/ where “accountname" and “tenantname” are specific to your account. Most APIs need the following information:
  1. Account ID and Tenant ID. You can find the account and tenant information in the profile info section within the tenant. See profile information.


  2. Authorization. The authorization field should be populated with the auth token generated in the previous step.
    Important: When using the auth token, prefix it with Bearer as in the screenshot below.
Now you can access specific APIs. Use sampleClassifierSkill for this example. In the ML Skills list, you can see this skill exists and is currently in the Available state.


Find ML Skill details

Using the GET ML Skills call, you can fetch a list of all ML Skills within the account and tenant. You can also add the ML Skill name as part of the query to search for a specific ML Skill and retrieve its details. In this case, you find the ML Skill idfor the sampleClassifierSkill
GET /ai-deployer/v1/mlskills?name=sampleClassifierSkill


In the response below, the key fields are highlighted in yellow. Double check that the sampleClassifierSkill is in the Available state. The ML Skill id is used in the subsequent APIs to update the state.


Stop ML Skill

To stop an ML Skill:

  • Request query should contain the stop update action and ML Skill id
  • Header should contain account, tenant and auth info
PUT /ai-deployer/v2/mlskills/stop/{mlSkillId}


The response shows that the ML skill status change was successful:


Checking the UI, you can verify that sampleClassifierSkill was undeployed.


Resume ML Skill

To restart (deploy) the ML Skill, make the API calls with the updateType set to Resume.
POST /ai-deployer/v1/mlskills/{mlSkillId}?updateType=RESUME




From the response, you can see that the request was successful, and the skill state was updated to Deploying.


Wait for the Skill to become available, and check the ML Skill status using the GET ML Skill details API.


From the response, the ML Skill is now deployed and Available. Verify the skill availability in the UI. Now your automations can leverage the deployed ML Skill sampleClassifierSkill within workflows, to make predictions.




Update ML Skill deployment using API

To access the AI Center APIs:

  1. Register an external application (one-time setup).
  2. Generate an authentication token (renew upon expiry).
  3. Make AI Center API calls.
Note: The first two steps enforce access control by making sure your application is registered and authenticated. To access the application, you must register and authenticate the application. (step 1 and 2)

Registering an external application

To use these APIs, your app must register as an external application within the AI Center scope.
  1. Go to the Admin page from the left navigation panel and select External Applications.
  2. Select + Add Application and give it a name, to add a new external application.
    Note: Only the confidential application type can access the AI Center APIs.
  3. Select Add scope to enable the AI Center scope to the external application.
    • Choose AI Center API Access (preview) from the Resource drop-down.
    • Go to the Application Scope tab and choose the APIs you want to give access to external applications. In the example below you select all the APIs for simplicity.


  4. A pop up with App ID and an App Secret confirms that the application was successfully added. Check the App ID and App Secret anytime from the Edit External application.
    Note: Use these credentials to generate an authentication token in the next step.


Check the Managing external applications page for more information.

Generating an authentication token

The external application must request an access token from the UiPath identity server for authentication and secure access.

Note: The authentication token expires in one hour. After this time, you'll need to generate a new one.

For simplicity, we use Postman in this tutorial. You can register 10 tokens for free and use their web interface, application, or any other tool.

Generate a POST request to the Identity Server endpoint that includes the following in the body of the request:

  • client_id: App ID from previous step.
  • client_secret: App Secret from previous step.
  • grant_type: client_credentials.
Select application/x-www-form-urlencoded as the content type if you're using Postman.


This request creates an authentication token, used for AI Center API calls:


You can also see the permissions enabled for this external application.

Check the additional information on credentials and authentication tokens in the External Applications (OAuth) page.

Making AI Center API calls

The API calls follow the https://cloud.uipath.com/accountname/tenantname/aifabric_/ 10 structure, where accountname and tenantname are specific to your account.
Most APIs need the following information:
  • Account ID and Tenant ID. Check the account and tenant details in the profile information section within the tenant.


  • Authorization. The authorization field is populated with the authentication token generated in the previous step.

You can now access specific APIs.

In the ML Skills list, sampleClassifierSkill (used as an example) is currently in the Available state.


Use the AI Center APIs to:

  • Find the ML Skill ID of sampleClassifierSkill.
  • Stop (undeploy) the ML Skill.
  • Start (redeploy) and verify status update.
Find ML Skill details
With the GET ML Skills call, you can retrieve all the ML Skills in your account and tenant.
To find a specific ML Skill and get its details, include its name in the query: GET /ai-deployer/v1/mlskills?name=sampleClassifierSkill
In this case, we find the ML Skill id for the sampleClassifierSkill.
Note: When using the authentication token, prefix it with Bearer.


In the response below, the key fields are highlighted in yellow. Use the ML Skill id in the following APIs to modify the state:


Update ML Skill replicas
Use the UPDATE ML Skill call to modify the deployment configuration on a specific ML skill.

In the example below, we change the replica count by including the new number in the request body.



Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.