> ## Documentation Index
> Fetch the complete documentation index at: https://docs.naga.ac/llms.txt
> Use this file to discover all available pages before exploring further.

# Moderations

> Classify text and images for harmful content with POST /v1/moderations.

<CodeGroup>
  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(base_url="https://api.naga.ac/v1", api_key=os.environ["NAGAAI_API_KEY"])

  result = client.moderations.create(
      model="omni-moderation-latest",
      input=[
          {"type": "text", "text": "I will hurt you"},
          {"type": "image_url", "image_url": {"url": "https://media.naga.ac/outputs/6ab3444c-f19e-4944-80dc-d0b49c49c144.png"}},
      ],
  )

  outcome = result.results[0]
  print(outcome.flagged, outcome.categories)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({ baseURL: "https://api.naga.ac/v1", apiKey: process.env.NAGAAI_API_KEY });

  const result = await client.moderations.create({
    model: "omni-moderation-latest",
    input: [
      { type: "text", text: "I will hurt you" },
      { type: "image_url", image_url: { url: "https://media.naga.ac/outputs/6ab3444c-f19e-4944-80dc-d0b49c49c144.png" } },
    ],
  });

  console.log(result.results[0].flagged, result.results[0].categories);
  ```

  ```bash cURL theme={null}
  curl https://api.naga.ac/v1/moderations \
    -H "Authorization: Bearer $NAGAAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"model": "omni-moderation-latest", "input": "I will hurt you"}'
  ```
</CodeGroup>

`model` is required. `input` is a string, a list of strings, or a list of `text` and `image_url` parts that are judged together.

Each result has `flagged`, `categories` and `category_scores`. `omni-moderation-latest` also returns `category_applied_input_types`, which says whether text, image or both triggered each category. Other models, such as `mistral-moderation`, use their own category set.

NagaAI charges each `image_url` part as 250 input tokens.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.