Response Format

Understanding the structure and fields in API responses

Overview

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.

Response Structure

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"
}

Response Fields

FieldTypeDescription
idstringUnique identifier for the moderation request
modelstringThe moderation model used for the request
resultsarrayArray of moderation results for each input item
combined_text_moderationobjectModeration result for all text items combined (only relevant when multiple text items are present)
vision_analysisarrayArray of vision analysis results for each image (only present if analyze_images is true)
flaggedbooleanWhether any content was flagged as inappropriate
signaturestringCryptographic signature for verifying the response

Result Object

Each item in the results array has the following structure:

FieldTypeDescription
flaggedbooleanWhether the content was flagged as inappropriate
categoriesobjectObject containing boolean flags for each category
category_scoresobjectObject containing scores (0.0 to 1.0) for each category

Categories

The categories and category_scores objects contain the following fields:

CategoryDescription
hateContent that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste
harassmentContent that expresses, incites, or promotes harassing language towards any target
self-harmContent that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders
sexualContent meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness)
violenceContent that promotes or glorifies violence or celebrates the suffering or humiliation of others

Vision Analysis Object

Each item in the vision_analysis array has the following structure:

FieldTypeDescription
image_indexnumberThe index of the image in the input array
analysisstringDetailed analysis of the image content
flaggedbooleanWhether the image was flagged as inappropriate

Interpreting Results

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.

Verifying the Response

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.

Next Steps