Quickstart
Step 1: Get your credentials
Contact the Sylvester team (see Support) to get an API key ID and a secret access key (Authentication).
Step 2: Send an image
curl
BASE_URL="https://tably-admin.sylvester.ai"
API_KEY_ID="YOUR_API_KEY_ID"
SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY"
# Build the JSON body in a file (images are too large for a command-line argument).
printf '{"image":"%s"}' "$(base64 < cat.jpg | tr -d '\n')" > body.json
curl -X POST "$BASE_URL/api/v2/predict" \
-H "tably-api-key-id: $API_KEY_ID" \
-H "tably-secret-access-key: $SECRET_ACCESS_KEY" \
-H "Content-Type: application/json" \
--data @body.json
Python (requests)
import base64
import requests
BASE_URL = "https://tably-admin.sylvester.ai"
API_KEY_ID = "YOUR_API_KEY_ID"
SECRET_ACCESS_KEY = "YOUR_SECRET_ACCESS_KEY"
with open("cat.jpg", "rb") as f:
image_b64 = base64.b64encode(f.read()).decode("ascii")
response = requests.post(
f"{BASE_URL}/api/v2/predict",
headers={
"tably-api-key-id": API_KEY_ID,
"tably-secret-access-key": SECRET_ACCESS_KEY,
},
json={"image": image_b64},
timeout=60,
)
response.raise_for_status()
result = response.json()
if result["detection"] == "detected":
print(result["prediction"]["label"], result["prediction"]["score"])
elif result["detection"] == "low_confidence":
print("A cat may be present, but the photo isn't clear enough. Ask for a clearer photo.")
else:
print("No cat found in the photo.")
JavaScript (Node.js 18+)
import { readFile } from "node:fs/promises";
const BASE_URL = "https://tably-admin.sylvester.ai";
const API_KEY_ID = "YOUR_API_KEY_ID";
const SECRET_ACCESS_KEY = "YOUR_SECRET_ACCESS_KEY";
const image = (await readFile("cat.jpg")).toString("base64");
const response = await fetch(`${BASE_URL}/api/v2/predict`, {
method: "POST",
headers: {
"tably-api-key-id": API_KEY_ID,
"tably-secret-access-key": SECRET_ACCESS_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({ image }),
});
const result = await response.json();
if (!response.ok) {
throw new Error(`${result.error.code}: ${result.error.message} (request ${result.request_id})`);
}
console.log(result.detection, result.prediction);
Step 3: Read the result
{
"request_id": "req_743a78dbedca420f9ab7dac5dd0df7d7",
"model": { "id": "bc-v1", "version": "0.0.34" },
"detection": "detected",
"prediction": {
"label": "discomfort",
"score": 0.32395651936531067,
"threshold": 0.3
},
"cat": {
"bounding_box": { "x_min": 56, "y_min": 74, "x_max": 1005, "y_max": 1013 },
"detection_confidence": 0.9662923216819763
},
"image": { "width": 1028, "height": 1028 },
"scan_id": "0d6f3c9a-51e2-4b7e-9a4c-2f8e1b7d6c35"
}
detection: whether a usable cat was found (detected,low_confidence,not_detected).prediction.label:discomfortbecausescore(0.324) is greater thanthreshold(0.3).cat.bounding_box: where the cat is in the image, in pixels.scan_id: Sylvester's record of this prediction. Store it with therequest_id(Scan IDs).