ML Inference API

Model Inferencing

Deployed models are available for inferencing using the predict API method.

Authentication

Admins or Project Managers can generate an API Key in Settings to use for authentication. See the "Authorization" header below for details on using this key as a token.

post
Predict

https://<HOSTNAME>/v1/models/:modelVersionId/predict
This method takes an image, performs inferencing on the image using the deployed model, and returns predictions. You can post a base64-encoded image as JSON in your request body (see Body Parameters for details), or you can post it as form-data (see Form Data Parameters).
Request
Response
Request
Path Parameters
modelVersionId
required
string
ID of the model version
Headers
Authorization
required
string
Use your API Key as an access token for Bearer authentication e.g., Authorization: Bearer <APIKEY>
Form Data Parameters
file
optional
string
Path to the image file Must send image as form data OR as raw JSON in the request body.
Body Parameters
json
optional
string
JSON representing base64-encoded image file e.g., { "image": "RmgBDRSUtAgpKO9LQAlsKoisdiVzVNME1wQ2VoaUh6cmVTek5UY3" } Must send image as form data or as raw JSON in the request body.
Response
200: OK
Predictions successfully returned.
{
"Carrot": [
{
"children": {},
"data": {
"min": [
0.5634275054931641,
0.3518534216861176
],
"max": [
0.7167446899414063,
0.5963308703261638
]
},
"score": 0.940265953540802,
"type": "rectangle"
}
],
"Eggplant": [
{
"children": {},
"data": {
"min": [
0.4583647537231446,
0.09473074610831807
],
"max": [
0.7564459991455078,
0.4381538359716596
]
},
"score": 0.940265953540802,
"type": "rectangle"
}
],
"Pizza": [
{
"children": {},
"data": {
"min": [
0.349699478149414,
0.2804078467098283
],
"max": [
0.5902877044677735,
0.65408274960616
]
},
"score": 0.840265953540802,
"type": "rectangle"
},
{
"children": {},
"data": {
"min": [
0.3777778244018555,
0.2478937062706967
],
"max": [
0.5511894989013671,
0.5284756632989326
]
},
"score": 0.920265953540802,
"type": "rectangle"
}
],
"Plate": [
{
"children": {},
"data": {
"min": [
0,
0.01942050996631261
],
"max": [
0.8802156066894531,
0.9652658470373585
]
},
"score": 0.930265953540802,
"type": "rectangle"
}
],
"Waffle": [
{
"children": {},
"data": {
"min": [
0.1631441879272461,
0.5393700619293339
],
"max": [
0.4661079025268555,
0.8982106903452932
]
},
"score": 0.940265953540802,
"type": "rectangle"
}
]
}
400: Bad Request
Issue with the image or request.
File size too large
Unknown image format
Form could not be parsed or missing image
File size too large
{
"error": "filesize: 13610234",
"message": "File size is too large",
"status": 400
}
Unknown image format
{
"error": "image: unknown format",
"message": "could not parse image",
"status": 400
}
Form could not be parsed or missing image
{
"error": "request Content-Type isn't multipart/form-data",
"message": "could not parse multipart form",
"status": 400
}
401: Unauthorized
Invalid API key. Verify that you are using a valid API key to authenticate.
{
"message": "Invalid or missing API key.",
"status": 401
}
500: Internal Server Error
Model version is not recognized. Check your model version ID and ensure that the version has been deployed.
{
"error": "model type unrecognized",
"message": "model type unrecognized",
"status": 500
}

Supported image types: JPG, PNG, GIF, BMP, TIFF, WEBP. File size limit is 10 MB.

Examples

Send base64-encoded image as JSON

curl -X POST 'https://<HOSTNAME>/v1/models/01F5PXD35EF2F8SBK27NM9ABC4/predict' \
--header 'Authorization: Bearer <APIKEY>' \
--header 'Content-Type: application/json' \
--data-raw '{ "image": "RmgBDRSUtAgpKO9LQAlsKoisdiVzVNME1wQ2VoaUh6cmVTek5UY3" }'

Send image as form data

curl -X POST 'https://<HOSTNAME>/v1/models/01F5PXD35EF2F8SBK27NM9ABC4/predict' \
--header 'Authorization: Bearer <APIKEY>' \
--form '[email protected]/to/image.jpg'