Understanding the structure and fields in API responses
The Omni API returns responses in a consistent JSON format. This page explains the structure and fields in the response to help you interpret and use the moderation results effectively.
Here's an example of a complete response from the API:
{
"id": "modr-123456",
"model": "text-moderation-latest",
"results": [
{
"flagged": false,
"categories": {
"hate": false,
"harassment": false,
"self-harm": false,
"sexual": false,
"violence": false
},
"category_scores": {
"hate": 0.0,
"harassment": 0.0,
"self-harm": 0.0,
"sexual": 0.0,
"violence": 0.0
}
},
{
"flagged": false,
"categories": {
"hate": false,
"harassment": false,
"self-harm": false,
"sexual": false,
"violence": false
},
"category_scores": {
"hate": 0.0,
"harassment": 0.0,
"self-harm": 0.0,
"sexual": 0.0,
"violence": 0.0
}
}
],
"combined_text_moderation": {
"flagged": false,
"categories": {
"hate": false,
"harassment": false,
"self-harm": false,
"sexual": false,
"violence": false
},
"category_scores": {
"hate": 0.0,
"harassment": 0.0,
"self-harm": 0.0,
"sexual": 0.0,
"violence": 0.0
}
},
"vision_analysis": [
{
"image_index": 1,
"analysis": "This image shows a plate of beautifully presented food in what appears to be a restaurant setting. The dish looks like a well-plated steak with garnishes and side dishes. The lighting is good, the food appears appetizing, and the image is of high quality. This is perfectly appropriate for a restaurant listing or review as it showcases the food offerings. VERDICT: APPROPRIATE",
"flagged": false
}
],
"flagged": false,
"signature": "abcdef1234567890"
}| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier for the moderation request |
| model | string | The moderation model used for the request |
| results | array | Array of moderation results for each input item |
| combined_text_moderation | object | Moderation result for all text items combined (only relevant when multiple text items are present) |
| vision_analysis | array | Array of vision analysis results for each image (only present if analyze_images is true) |
| flagged | boolean | Whether any content was flagged as inappropriate |
| signature | string | Cryptographic signature for verifying the response |
Each item in the results array has the following structure:
| Field | Type | Description |
|---|---|---|
| flagged | boolean | Whether the content was flagged as inappropriate |
| categories | object | Object containing boolean flags for each category |
| category_scores | object | Object containing scores (0.0 to 1.0) for each category |
The categories and category_scores objects contain the following fields:
| Category | Description |
|---|---|
| hate | Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste |
| harassment | Content that expresses, incites, or promotes harassing language towards any target |
| self-harm | Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders |
| sexual | Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness) |
| violence | Content that promotes or glorifies violence or celebrates the suffering or humiliation of others |
Each item in the vision_analysis array has the following structure:
| Field | Type | Description |
|---|---|---|
| image_index | number | The index of the image in the input array |
| analysis | string | Detailed analysis of the image content |
| flagged | boolean | Whether the image was flagged as inappropriate |
When processing the API response, you should check the top-level flagged field first. If it'strue, then at least one item in the request was flagged as inappropriate.
For more detailed analysis, you can check the individual results in the results array. Each result corresponds to an item in the input array, in the same order.
If you submitted multiple text items, you should also check the combined_text_moderation field to see if the combined text was flagged, even if individual text items were not.
If you requested vision analysis for images, check the vision_analysis array for detailed analysis of each image.
To ensure the response came from the Omni API and hasn't been tampered with, you should verify thesignature field. See the Verify Signature page for details.