Skip to main content

POST /v1/moderations

Classify text or image URLs for policy compliance.

  • Method: POST
  • Path: /v1/moderations
  • Auth: Bearer token in Authorization header
  • Content-Type: application/json

Request Parameters

  • model (string, required): Moderation model (e.g., omni-moderation-latest).
  • input (required): One of:
    • string (single text)
    • string[] (multiple texts)
    • array of objects mixing:
      • Text input: { "type": "text", "text": "..." }
      • Image URL input: { "type": "image_url", "image_url": { "url": "https://..." } }

Example Request

from openai import OpenAI

client = OpenAI(base_url="https://api.naga.ac/v1", api_key="YOUR_API_KEY")

# Single text
resp = client.moderations.create(
model="omni-moderation-latest",
input="Hello! Nice to meet you!"
)
print(resp)

# Mixed inputs (text + image URL)
resp2 = client.moderations.create(
model="omni-moderation-latest",
input=[
{"type": "text", "text": "This is a test."},
{"type": "image_url", "image_url": {"url": "https://yavuzceliker.github.io/sample-images/image-1021.jpg"}},
],
)
print(resp2)

Authentication

Provide your key as a Bearer token:

Authorization: Bearer YOUR_API_KEY

Response

Returns a moderation result compatible with OpenAI's moderation API, typically including categories and scores per input.

Response Fields

  • id (string): Unique request identifier
  • model (string): Model used for moderation
  • results (array): Array of moderation results per input
    • flagged (boolean): Whether the content was flagged
    • categories (object): Boolean flags for each category
    • category_scores (object): Confidence scores (0-1) for each category
    • category_applied_input_types (object): Which input types were checked for each category