REST API Reference > Model Serve REST API > Generating predictions
  

Generating predictions

Use the deployment resource to generate predictions from a quick start model or a user-defined model.
Before you generate predictions, make sure that the deployment is available. To make a deployment available, start the deployment and wait until its status is Available.
Note: To generate predictions from a quick start model, use the predictUrl value from the request for information about a single quick start model.To generate predictions from a user-defined machine learning model, use the predictUrl value from the request to monitor a model deployment.

POST request

To generate a prediction, include the deployment ID in the URI. Use the following URI:
/mlops/api/v1/deployment/request/<deployment ID>
Get the ID for a quick start model from the response to get information about a quick start model. For more information, see Getting information about a quick start model.
Get the deployment ID for a model deployment from the response to monitor a model deployment. For more information, see Monitoring model deployments.
Include the following fields in the request body:
Field
Type
Description
deployment_id
String
ID of the quick start model or model deployment.
request
String
Input fields needed to generate a prediction. The request should consist of key-value pairs in a serialized JSON string.
To generate predictions from a quick start model, use the input fields defined for that model.
To generate predictions from a user-defined model, use the input fields that you specified when you registered the machine learning model.

POST response

Returns the prediction from the machine learning model.
When you generate predictions from a user-defined model, you specify the output fields when you register the machine learning model. The model returns each output field as an attribute of the response.

Input and response for the image classification model

To generate predictions from the image classification quick start model, include a reference to the image file in the request. If successful, the request returns a list of the image descriptors.

Input fields

Include the following field in the request field of the POST request:
Field
Type
Description
inputImage
String
File path to the image file.

POST response

Returns an array that contains the five image descriptors and confidence scores, similar to the following example:
{
"prediction": [
{
"name": "drum, membranophone, tympan",
"confidence_score": 0.23505400121212006
},
{
"name": "frying pan, frypan, skillet",
"confidence_score": 0.1420985758304596
},
{
"name": "stove",
"confidence_score": 0.11630863696336746
},
{
"name": "ladle",
"confidence_score": 0.08813537657260895
},
{
"name": "strainer",
"confidence_score": 0.06395173072814941
}
]
}

Input and response for the text translation model

To generate predictions from the text translation quick start model, include the languages and input text in the request. If successful, the request returns the translated text.

Input fields

Include the following attributes in the request field of the POST request:
Attribute
Type
Description
source_language
String
Language code of the input text.
target_language
String
Language code to translate to.
input_text
String
Text to translate. Text can be a maximum of 3,000 characters.
To see the languages that the model supports and the language codes, refer to the Hugging Face documentation.

POST response

Returns the translated text as a string.