Deployment API in cURL

Once you have an accurate model deployed for production, you’ll want to use it to get predictions about new data. If you don’t find any Peltarion connector for the tools that you use, you can always use the Deployment API in any programming language.
This page will show you examples of how to work with the Deployment API from cURL, but you can also find more explanations and examples in other languages from the Deployment API page.

cURL is a command line tool for transferring data with URLs. It can be a very quick and practical way to test your deployments and to integrate them in your applications.

A command line example for cURL is shown on the Deployment view to let you try your model as soon as it’s deployed and enabled.


You need to create a deployment from the deployment view. The deployment view will show you the information you need to use the Deployment API:

  • All the input and output names (and shapes) of your model

  • The URL and deployment token to use for your requests

  • The status of the deployment. Make sure it is enabled, or queries will be denied


Submitting tabular data

See how to submit tabular data in Python.

Tabular data is data whose features could be submitted inside a CSV file (i.e., single numeric value, categorical, or text).

Here are examples for submitting one example.

  • Submit an example with cURL native options. You can only submit one example at a time this way.

curl -X POST \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-F "Type=animal" \
-F "Sound=woof" \
-F "Size=1.3" \
  • Submit a JSON formatted payload string. You can send a batch of examples with a single request that way.

curl -X POST \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json"  \
-d '{"rows": [{"Type": "animal", "Sound": "Miaow", "Size": 0.43}, {"Type": "animal", "Sound": "wouf", "Size": 0.71}]}' \

Submitting images

How to submit images as features.

You can send images of any size and the platform will automatically resize them to the expected resolution according to the settings specified on the datasets view.

  • Using cURL native options, you can directly give the name of an image file on your local machine preceded by the @ symbol.

curl -X POST \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json"  \
-F "Feature Name=@Number_6.png" \
  • You can also use the JSON payload format by encoding the image as a binary 64 text string.

curl -X POST \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json"  \
-d '{"rows": [{"Image feature": "data:image/png;base64,iVBORw0KGgoAAAANSU"}]}' \

Submitting arrays

See how to submit arrays in Python.

If you are working with NumPy data structures it is strongly suggested to use Peltarion’s sidekick library to query the Deployment API .

It is possible to send a JSON payload by providing both the shape and the flattened data of the array.

curl -X POST \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json"  \
-d '{"rows":[{"Array feature":{"shape":[2,3], "data":[1,2,3,4,5,6]}}]}' \

Working with responses

When you submit a request, you will get a JSON formatted string with the response. This string contains a list of predictions for all of the examples submitted, or an error message if there was a problem (e.g., one of the examples submitted contained invalid data).

For instance, if you send text instead of a numeric feature, the output will look like:

curl -X POST -F "Numeric feature=ABC" -u "<token>:" <url>
> {"errorCode":"InternalError","errorMessage":"We are sorry, something went wrong on our end. \uD83D\uDE14"}

Numeric predictions

See how to handle numeric predictions in Python.

For numeric predictions (single number), the value is returned directly. The message looks like this:

{"rows": [{"output name": 0.3740423}, {"output name": 6.784281}]}

Categorical predictions

See how to handle categorical predictions in Python.

For categorical predictions, every possible category is returned as a key, and the associated value gives the probability of the example belonging to that class. For example:

{"rows": [{"output name": {"cat": 0.98, "dog": 0.005, "train": 0.005, "car": 0.01}}, {"output name": {"cat": 0.001, "dog": 0.001, "train": 0.899, "car": 0.1}}]}

Image predictions

See how to handle image predictions in Python.

If the output of the model is an image, it is returned as a binary 64 encoded text string. For example:

{"rows": [{"output image": "data:image/png;base64,iVBORw0KGgoAAA"}]}

Array predictions

See how to handle array predictions in Python.

If the model output is an array, you will receive the shape and flattened data of the prediction. For example:

{"rows":[{"Array feature":{"shape":[2,3], "data":[1,2,3,4,5,6]}}]}
Was this page helpful?
Yes No