Request Validation
Request Validation
To ensure the integrity and reliability of the Supervised AI platform's testing suite, all incoming requests to the testing-api must adhere to strict schema requirements. This section outlines the validation rules for payloads submitted to the testing endpoints.
Global Validation Rules
All API endpoints expect data in JSON format. The following rules apply globally:
- Content-Type: Must be
application/json. - Field Types: Types are strictly enforced (e.g., a field defined as an
Integerwill fail if aStringis provided). - Mandatory Fields: Any field marked as
Requiredmust be present in the root of the JSON object. - Null Values: Fields do not accept
nullunless explicitly stated in the schema.
Test Submission Schema
When submitting a test case for evaluation, the request body must conform to the following structure:
| Field | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| test_id | UUID | Yes | A unique identifier for the specific test case. |
| model_version | String | Yes | The semantic version or hash of the model being tested. |
| input_data | Object | Yes | A key-value map containing the features or prompts for the model. |
| expected_output | Mixed | No | The ground truth or expected result for validation. |
| metadata | Object | No | Additional context (e.g., environment tags, timestamps). |
Example Payload
{
"test_id": "550e8400-e29b-41d4-a716-446655440000",
"model_version": "v2.1.0-alpha",
"input_data": {
"prompt": "Summarize the document.",
"context": "Text content here..."
},
"expected_output": "This is a summary.",
"metadata": {
"environment": "staging",
"priority": "high"
}
}
Batch Processing Validation
For high-throughput testing, use the batch endpoint. Validation is performed on the entire array before processing begins.
- Limit: Maximum of 100 test objects per batch request.
- Structure: An array of objects conforming to the Test Submission Schema.
[
{ "test_id": "...", "input_data": { ... } },
{ "test_id": "...", "input_data": { ... } }
]
Error Responses
If a request fails validation, the API returns a 422 Unprocessable Entity or 400 Bad Request status code. The response body provides details on the specific validation failure:
| Field | Type | Description |
| :--- | :--- | :--- |
| error_code | String | A machine-readable string identifying the error type (e.g., MISSING_FIELD). |
| message | String | A human-readable explanation of the validation error. |
| details | Array | An array of specific fields and the reasons they failed validation. |
Example Validation Error
{
"error_code": "VALIDATION_FAILED",
"message": "The request payload contains 1 validation error.",
"details": [
{
"field": "model_version",
"issue": "Field is required and cannot be empty."
}
]
}
Constraints and Sanitization
- String Length:
model_versionand keys withininput_dataare capped at 255 characters. - Nesting:
input_datasupports nested JSON objects up to 3 levels deep. - Character Encoding: Only
UTF-8encoded strings are accepted.