03 — API
Call it over HTTP
Hosted on RapidAPI — no infrastructure, no model files, metered per request.
Predict
POST /v1/predict — the request body is raw image bytes,
not multipart form data. Add ?include_attention=true to get an attention overlay
back alongside the score.
curl
curl --request POST \
--url 'https://print-vision.p.rapidapi.com/v1/predict' \
--header 'Content-Type: image/jpeg' \
--header 'x-rapidapi-host: print-vision.p.rapidapi.com' \
--header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
--data-binary @frame.jpg
Python
import requests
with open("frame.jpg", "rb") as handle:
image_bytes = handle.read()
response = requests.post(
"https://print-vision.p.rapidapi.com/v1/predict",
data=image_bytes,
headers={
"Content-Type": "image/jpeg",
"x-rapidapi-host": "print-vision.p.rapidapi.com",
"x-rapidapi-key": "YOUR_RAPIDAPI_KEY",
},
timeout=10,
)
print(response.json()["failed_probability"])
Response
attention_jpeg_base64 is present only when include_attention=true was requested.
JSON
{
"failed_probability": 0.9873,
"attention_jpeg_base64": "/9j/4AAQSkZJRgABAQAAAQ..."
}
Status codes
| Code | Meaning |
|---|---|
200 |
Scored — body contains failed_probability |
400 |
Body was empty or could not be decoded as an image |
413 |
Image is larger than the 16 MiB upload cap |
503 |
Attention was requested but no Keras model is loaded |
Other endpoints
| Endpoint | Purpose |
|---|---|
GET /healthz |
Liveness check |
POST /v1/collect |
Store a frame for future training without running inference |
GET /v1/model/metadata |
Model hash, size, input dimensions and quantisation flag |
GET /v1/model |
Download the TFLite model, used for local deployments and custom integrations |