Cnvrg makes it easy to publish your predictive models as web services, without IT or Dev Ops needed.

Publish a new model:

In your project view, go to Publish and click on `Publish New Model`:

  • If the input of the function is a file check the box specifying "Function accepts file as input" (unchecked by default)

Under File: choose the file to publish

Under Function to execute: fill in the function that will be called by the endpoint, i.e. predict

Choose type of machine, number of workers and if it should be scheduled or immediate

Click Publish! and your model will be published in a few minutes.

Once the model is published you can access your new endpoint page and view the logs, test the model etc.

That's it, so easy and no hassle involved!

You can also click on "Publish your Model" button in the experiment view.

Send API requests:

For regular types (non-file types):

In the lower part of the endpoint page, you will see an example how to access the model's endpoint (under Usage Example):

curl 
-H "Cnvrg-Api-Key:v6Phh3xBLxJfSsofKhdczspk"-H "Content-type: application/json" -X POST https://insights.cnvrg.io/10b0b0b220/api/v1/model/QG_kwYyMijUYygmxzn4B/predict -d '{"input_params":"PARAMS"}'

In order to send API requests to your published model, you'd have to have your api key to send as a header. It's located in the upper part of the endpoint page:

-H "Cnvrg-Api-Key:v6Phh3xBLxJfSsofKhdczspk" 

To send data to the request, first add content type:

-H "Content-type: application/json"

send your data in json as follow:

 '{"input_params":PARAMS}' 

so for example, if you need to send a string, replace PARAMS with your string:

 '{"input_params":"I just published my model"}'

You can send the following types:

  • Strings
  • Any type of number
  • Dictionary
  • List*
  • Booleans

If your function accepts more than 1 parameter, replace PARAMS with a list of params, for example,

your function looks like:

predict(a,b)

You will send:

'{"input_params":[some_input, other_input]}'

and it will be received as:

predict(some_input,other_input)

If your function receives a list as a parameter, you should send it as a list inside a list (so it won't receive as different parameters), for example:

your function looks like:

predict(a) -> a is a list

You will send:

'{"input_params":[[x,y,z,w,a]]}'

and it will be received as:

predict([x,y,z,w,a])

For File type:

(echo -n '{"data": "'; base64 FILE.jpg; echo '"}') |curl -H "Cnvrg-Api-Key:v6Phh3xBLxJfSsofKhdczspk"-H "Content-type: application/json" -X POST -d @- https://insights.cnvrg.io/10b0b0b220/api/v1/model/QG_kwYyMijUYygmxzn4B/predict

Wish to send audio files as input? Coming soon!

Did this answer your question?