Validate input before running a prediction
Feb 12, 2025
1 minute read
Predictions now support early input validation. Pass the Validate-Input: true header when creating a prediction and WriftAI will check your input against the model's schema before any hardware is provisioned.
The problem
Without validation, an invalid input, a missing required field, a wrong type, an out-of-range value only surfaces after the model has already started running on hardware. By that point, you've already paid for the cold start and however far execution got before the error.
What changed
The POST /predictions endpoint now accepts a Validate-Input header. When set to true, WriftAI validates the input against the model's schema upfront. If validation fails, you get an error immediately before any hardware is allocated.
1curl https://api.wrift.ai/v1/predictions \2 -H "Authorization: Bearer $WRIFTAI_ACCESS_TOKEN" \3 -H "Content-Type: application/json" \4 -H "Validate-Input: true" \5 -d '{6 "model": "owner/model_name",7 "input": {8 "prompt": "a photo of a mountain lake at sunset"9 }10 }'
Validation may add a small amount of latency to the request depending on the schema size, so it defaults to false. It's most useful during development and integration testing. Once you're confident your inputs are correct, you can drop the header in production.