ML Inference API

Model Inferencing

This feature is coming soon.

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.
{
"Broccoli": [
{
"children": {},
"data": {
"min": [
0.4112356821695964,
0.4720712661743164
],
"max": [
0.5976914723714193,
0.6196210861206055
]
},
"type": "rectangle"
}
],
"Egg": [
{
"children": {},
"data": {
"min": [
0.22393133375379776,
0.5325012524922689
],
"max": [
0.3971275329589844,
0.6394755045572916
]
},
"type": "rectangle"
}
],
"Pizza": [
{
"children": {},
"data": {
"min": [
0.38378545973036027,
0.33704675038655596
],
"max": [
0.6061868879530166,
0.47794354756673174
]
},
"type": "rectangle"
}
],
"Plate": [
{
"children": {},
"data": {
"min": [
0.07183820936414931,
0.16654847462972006
],
"max": [
0.988360850016276,
0.7316844940185547
]
},
"type": "rectangle"
}
],
"Red bell pepper": [
{
"children": {},
"data": {
"min": [
0.6345162285698785,
0.5504103978474935
],
"max": [
0.8281489054361979,
0.6704284032185872
]
},
"type": "rectangle"
}
]
}
302: Found
304: Not Modified
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 deployment is still initializing. Inferencing is not yet available. Please wait until the API status is "Active"
{
"error": "googleapi: Error 404: Field: name Error: Online prediction is unavailable for this version. Please verify that CreateVersion has completed successfully., notFound",
"message": "could not inference model",
"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'