REST API Reference > Model Serve REST API > Machine learning models
  

Machine learning models

Use API resources to perform actions on user-defined machine learning models, such as downloading the template file, uploading and downloading a model file, and registering and editing a model.

Getting the code template file

Use the model resource to get the template file that you need to define a machine learning model.

GET request

To request the code template file, use the following URI:
/mlops/api/v1/model/template/custom

GET response

Returns the code template ZIP file as an octet-stream file.

Model file upload

Upload a model ZIP file that contains the files that define your machine learning algorithm.
Before you upload a new model file, send a request to generate a model file ID. Then, use the model file ID in the request to upload or update the file.

Generating a model file ID

Use the model resource to generate a model file ID before you upload the model file.

POST request

To generate a model file ID, use the following URI:
/mlops/api/v1/model/upload/generateID
Include the following field in the request:
Field
Type
Description
file_name
String
Name of the model file to upload, including the file extension.

POST response

Returns the new model file ID.

Uploading or updating a model file

Use the model resource and the model file ID to upload or update a model file.

POST request

To upload or update a model file, include the model file ID in the URI. Use the following URI:
/mlops/api/v1/model/upload/<model file ID>
Include the following fields in the request:
Field
Type
Description
file
String
Model file to upload as a multipart file.
framework
String
Use PYTHON or TENSORFLOW as the value.

POST response

Returns the model file ID.

Registering a machine learning model

Use the Documents resource to register a machine learning model after you upload the model file.

POST request

To register a machine learning model, include the project or folder ID in the URI. Use the following URI:
/frs/v1/Projects('<project ID>')/Documents
Include the following fields in the request:
Field
Type
Description
name
String
Machine learning model asset name.
description
String
Optional. Description of the machine learning model.
documentType
String
Use MLOPS_MODEL.
nativeData
Object
Blob object that defines the machine learning model.
Include the following fields in the nativeData object:
Field
Type
Description
name
String
Machine learning model asset name.
framework
String
Framework used to create the machine learning model. Use one of the following values:
  • - Python
  • - PyTorch
  • - TensorFlow
framework_type
String
Internal type of the framework.
For a Python model, use Custom.
For a PyTorch or TensorFlow model, use Standard.
file_id
String
Model file ID generated when you upload the model file.
file_name
String
Name of the model file. The name must match the file name you used to generate the model file ID.
size
String
Size of the model file in GB.
file_type
String
Use zip.
inputField
Input fields that the machine learning model expects. Include at least one input field.
name
String
Name of the field.
dataType
String
Data type of the field.
shape
String
Required for array data types. Shape of the array. For example, [2,3].
outputField
Output fields that the machine learning model returns. Include at least one output field.
name
String
Name of the field.
dataType
String
Data type of the field.
shape
String
Required for array data types. Shape of the array. For example, [2,3].

POST response

Returns a summary of the machine learning model.

Editing a machine learning model

Use the Documents resource to edit a machine learning model.

PATCH request

To edit a machine learning model, include the machine learning model ID in the URI. Use the following URI:
/frs/v1/Documents('<model ID>')
Get the model ID from the response to register a machine learning model.
Include the following fields in the request:
Field
Type
Description
name
String
Machine learning model asset name.
description
String
Optional. Description of the machine learning model.
documentType
String
Use MLOPS_MODEL.
nativeData
Object
Blob object that defines the machine learning model.
Include the following fields in the nativeData object:
Field
Type
Description
name
String
Machine learning model asset name.
framework
String
Framework used to create the machine learning model. Use one of the following values:
  • - Python
  • - PyTorch
  • - TensorFlow
framework_type
String
Internal type of the framework.
For a Python model, use Custom.
For a PyTorch or TensorFlow model, use Standard.
file_id
String
Model file ID generated when you upload the model file.
file_name
String
Name of the model file. The name must match the file name you used to generate the model file ID.
size
String
Size of the model file in GB.
file_type
String
Use zip.
inputField
Input fields that the machine learning model expects. Include at least one input field.
name
String
Name of the field.
dataType
String
Data type of the field.
shape
String
Required for array data types. Shape of the array. For example, [2,3].
outputField
Output fields that the machine learning model returns. Include at least one output field.
name
String
Name of the field.
dataType
String
Data type of the field.
shape
String
Required for array data types. Shape of the array. For example, [2,3].

PATCH response

Returns a summary of the machine learning model.

Getting the model file for a machine learning model

Use the model resource to download the model ZIP file from a registered machine learning model.

GET request

To get the model file, include the machine learning model ID in the URI. Use the following URI:
/mlops/api/v1/model/download/<model ID>
Get the model ID from the response to register a machine learning model.

GET response

Returns an octet-stream of the model file.