Improved validation for API prediction payloads

If you typo a field in the JSON request body when creating a prediction with the API, we will now tell you about it rather than silently accepting it.

Here’s an example showing the response you’ll get if you misspell input as inptu:

$ curl -s -X POST \
  -H "Authorization: Bearer $REPLICATE_API_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "version": "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", 
    "inptu": {"text": "Alice"}
  }' \
  https://api.replicate.com/v1/predictions | jq .invalid_fields
[
  {
    "type": "required",
    "field": "",
    "description": "input is required"
  },
  {
    "type": "additional_property_not_allowed",
    "field": "",
    "description": "Additional property inptu is not allowed"
  }
]

Note that this validation only applies to top-level properties in the payload like input, version, stream, webhook, webhook_events_filter, etc.