cURL
curl --request POST \ --url https://api.example.com/batch_predict \ --header 'Content-Type: application/json' \ --data ' { "records": [ {} ] } '
{ "predictions": [ {} ] }
POST /batch_predict
min_length=1
PredictRequest
Show Record Schema
records
Show Prediction Schema
curl -X POST "http://localhost:8000/batch_predict" \ -H "Content-Type: application/json" \ -H "accept: application/json" \ -d '{ "records": [ { "student_country": "United States", "days_on_platform": 45, "minutes_watched": 320.5, "courses_started": 3, "practice_exams_started": 5, "practice_exams_passed": 3, "minutes_spent_on_exams": 87.2 }, { "student_country": "Canada", "days_on_platform": 12, "minutes_watched": 45.0, "courses_started": 1, "practice_exams_started": 0, "practice_exams_passed": 0, "minutes_spent_on_exams": 0.0 }, { "student_country": "United Kingdom", "days_on_platform": 90, "minutes_watched": 1250.0, "courses_started": 8, "practice_exams_started": 12, "practice_exams_passed": 10, "minutes_spent_on_exams": 340.5 } ] }'
{ "predictions": [ { "predicted_purchase_probability": 0.7834, "predicted_purchase": 1 }, { "predicted_purchase_probability": 0.2145, "predicted_purchase": 0 }, { "predicted_purchase_probability": 0.9512, "predicted_purchase": 1 } ] }
{ "detail": "practice_exams_passed cannot exceed practice_exams_started." }
{ "detail": [ { "loc": ["body", "records"], "msg": "ensure this value has at least 1 items", "type": "value_error.list.min_items" } ] }
{ "detail": "Model is not loaded." }
src/api.py:292-297
BatchPredictRequest
class BatchPredictRequest(BaseModel): records: List[PredictRequest] = Field(..., min_length=1)
BatchPredictResponse
class BatchPredictResponse(BaseModel): predictions: List[PredictResponse]
/predict
artifacts/prediction_log.jsonl