Skip to main content

Inference Requests

Pretrained Inference

You can see the OpenAPI specifications of the SliceX AI Predictor API in the API Reference section.

The SliceX AI Predictor main URL endpoint is:

api.slicex.ai/predictor/language

With the SliceX AI Predictor, inference is accessible with a simple POST request to the following endpoint:

api.slicex.ai/predictor/language/pre-trained/MODEL_NAME

Just change the MODEL_NAME, and pass your API Key in the header along with your query. That’s it!

Here is an example inference request with the pretrained customer review API:

Example Pretrained Inference Request
curl -X POST \
"https://api.slicex.ai/predictor/language/pre-trained/customer-review" \
-H "accept: application/json" \
-H "x-api-key: API_KEY" \
-H "Content-Type: application/json" \
-d "{ \"query\": \"This restaurant was amazing, I really liked the chicken there.\"}"

The corresponding response is:

Example Inference Request- Response
{
"data": {
"labels": [
"POSITIVE",
"NEGATIVE"
],
"scores": [
0.9923157691955566,
0.007684230804443359
]
},
"metadata": {
"model_inference_time_ms": 8.461669921875
}
}

Custom Inference

In order to predict with a custom model you first need to train it. See the SliceX Trainer Section for more details. Once a model is trained, it is immediately available for inference. Just like with the Pretrained Inference API, you can predict using your model in an identical manner, with a POST request to the custom inference endpoint:

api.slicex.ai/predictor/language/pre-trained/MODEL_ID

Note that this time, you will need your MODEL_ID pointing to the correct custom trained model.

For example:

Example Custom Inference Request
curl -X POST \
"https://api.slicex.ai/predictor/language/model/MODEL_ID" \
-H "accept: application/json" \
-H "x-api-key: API_KEY -H "Content-Type: application/json" \
-d "{ \"query\": \"This restaurant was amazing, I really liked the chicken there.\"}"

Batch Inference

For some subscription tiers (See Pricing) the SliceX AI Predictor offers batch inference. It works the same way as single queries, except you can now do more queries at a time. The limit is set to 20 and every query in the batch is cost equivalent to 1 individual inference call.

Batch inference has a separate endpoint from single query. It is accessible with a POST request to the following endpoint:

api.slicex.ai/batch-predictor/language/pre-trained/MODEL_NAME

For custom inference it is:

api.slicex.ai/batch-predictor/language/model/MODEL_ID

For example:

Example Batch Inference Request
curl -X POST \
"https://api.slicex.ai/batch-predictor/language/pre-trained/customer-review" \
-H "accept: application/json" \
-H "x-api-key: API_KEY" \
-H "Content-Type: application/json" \
-d "{ \"queries\": [ \"This restaurant was really nice!\", \"I didn't like this movie\", \"Great job! keep up the good work!\" ]}"

The corresponding response is:

Example Batch Inference Request- Response
{
"data": [
{
"labels": [
"POSITIVE",
"NEGATIVE"
],
"scores": [
0.9493195414543152,
0.050680458545684814
]
},
{
"labels": [
"NEGATIVE",
"POSITIVE"
],
"scores": [
0.9958140254020691,
0.0041859811171889305
]
},
{
"labels": [
"POSITIVE",
"NEGATIVE"
],
"scores": [
0.9992074370384216,
0.0007925629615783691
]
}
],
"metadata": {
"model_inference_time_ms": 37.556640625
}
}

Multiple Models Inference

Some subscription tiers (see Pricing) offer access to the SliceX AI Medley. It allows you to call multiple models at a time for the same query and you can combine it with the SliceX AI Batch Predictor.

For more information about how to make requests with the SliceX AI Medley API, please refer to its dedicated section.

note

Every SliceX AI Medley inference prediction request counts towards 1 inference call.