Skip to main content

Fitting of services via REST API

1. Get API token

To call REST API methods, you first need to generate an API token. If you already have one, proceed to the next step.

  1. Go to the My servicesAPI tokens section.
  2. Click Create token and copy the token. You will need it to send requests.

We recommend creating a separate API token for each user application. In the future, you will be able to view usage statistics for each token.

2. Create derived service

  1. Use the POST /api/mlpgate/account/{account}/model/{model}/derived method. With its help, you can create a derived service based on the fitted one. The derived service will inherit its parameters.

Send a request. Use the following values as parameters:

  • account is the identifier or the name of the service owner’s account.

  • model is the identifier or the name of the service.

  • You can find the account and model values in the card URL of the service you want to fit: https://caila.io/catalog/{account}/{model}.

  • name is the name of the future fitted service. Passed in the request.

  • MLP-API-KEY is the API token copied in the API tokens section. Passed as a header.

You will receive a JSON object with data about the created service in response. The new service will appear in the Caila interface in the My servicesFitted section.

  1. Copy the values of the accountId and modelId fields embedded in id. You will need them to send the fitting method request.

3. Fit service

Use the service fitting method: POST /api/mlpgate/account/{account}/model/{model}/fit. Send the request. Use the following values as parameters:

  • account is the account identifier copied in the previous step.
  • model is the service identifier copied in the previous step.
  • MLP-API-KEY is the API token copied in the API tokens section. Passed as a header.

In the request body, pass a JSON object with the fields:

  • config is the fitting configuration. Optional field. Specify according to the format from the description of the fittable service.
  • configId is the identifier of the fitting configuration. Optional field.

A list of all available configurations for the service can be obtained by using the GET /api/mlpgate/account/{account}/model/{model}/fit-config method. Use the values for the service to be fitted as {account} and {model}.

caution
Specify only one of the parameters: config or configId.
  • datasetId is the identifier of the dataset. The field is required. It can be obtained in the Caila interface in the Datasets section (on the page of the required dataset) or by using the GET /api/mlpgate/account/{account}/dataset method.

You will receive a JSON object with data about the launched fitting process in response.

When the fitted service is ready

The fitting process can take a long time. This depends on the volume of the dataset on which the fitting is performed. The service will be ready for use when the status of the fitting changes to SUCCESS.

To get the fitting status, send a request using the GET /api/mlpgate/account/{account}/job/{jobId} method.