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", "url": "https://..." }

Example requests

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", "url": "https://example.com/photo.jpg"},
],
)
print(resp2)

Response

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