Links

REST API

The official REST API SDK documentation for Banana.

Endpoint Design

Banana runs inference tasks on an async worker queue
  • ​Start:
    • Adds an inference call to the queue
    • Returns inference results if available in <50 seconds, else returns a Call ID
  • ​Check:
    • Checks for inference results by Call ID, returns those results if ready

Start Endpoint

API Version 4
https://api.banana.dev/start/v4
method: POST
example
curl -X POST "https://api.banana.dev/start/v4/" \
-H "Content-Type: application/json" \
-d \
'
{
"apiKey": "YOUR_API_KEY",
"modelKey": "YOUR_MODEL_KEY",
"modelInputs": {YOUR_MODEL_INPUT_JSON}
}'
​
​
full input json:
{
​
"id": "xyz", // **optional -** some uuid to identify the payload
"created": 123123123123, // **optional -** the current Unix timestamp in seconds
"apiKey": "your-auth-key", // **required -** your api key, for authorization
"modelKey": "your-model-key", // **required -** the key giving you access to this model
"startOnly": false, // **optional -** boolean flag to tell backend to return a callID immediately, without awaiting results. Defaults to false.
"modelInputs" : {
... // **required -** the json passed to the model inference server
},
}
Calls to the Start endpoint, by default, remain on the server for one minute awaiting a result, to eliminate the need to run a subsequent Check call. This behavior can be toggled off with the "startOnly" flag.
return json:
{
"id": "xyz" // the return payload id
"message": "success", // success or server error messages. Our API does not throw 500 errors, so always check this field for the substring "error" to catch errors
"created": 123123123123, // the current Unix timestamp in seconds
"apiVersion": "Nov 14 2021", // identifier on which backend was used, to help us debug
"callID": "call_abcabcabc", // the async call ID used on the /check/v4 call to see the task's status
"finished": true, // a boolean to communicate that the inference is finished and you can expect values in the modelOutputs field
"modelOutputs": [ {
... // the json returned from the model inference server
} ]

Check Endpoint

https://api.banana.dev/check/v4
method: POST
example
curl -X POST "https://api.banana.dev/check/v4/" \
-H "Content-Type: application/json" \
-d \
'
{
"apiKey": "YOUR_API_KEY",
"callID": "TASK_ID_RETURNED_FROM_START_CALL"
}'
​
input json:
{
"id": "xyz", // **optional -** some uuid to identify the payload
"created": 123123123123, // **optional -** the current Unix timestamp in seconds
"apiKey": "your-auth-key", // **required -** your api key, for authorization
"longPoll": true, // **suggested -** a flag telling the REST call wait on the server for results, up to 50s
"callID" : "call_abcabcabc" // **required -** the async task ID to fetch results for
}
return json:
{
"id": "xyz" // the return payload id
"message": "success", // success or server error messages. Our API does not throw 500 errors, so always check this field for the substring "error" to catch errors
"created": 123123123123, // the current Unix timestamp in seconds
"apiVersion": "Nov 14 2021", // identifier on which backend was used, to help us debug
"modelOutputs": [ {
... // the json returned from the model inference server
} ]
}
Because check is an async polling call, the status of the ongoing job will be displayed in the message field.
If message == "success", then the results will be found in the modelOutputs field.
If message contains "error", then the inference failed.
  • Errors will not throw an api-wide 500 error, as the check call technically was successful.
  • Make sure to watch for errors in the message field.
​