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://..." }
- Text input:
Example requests
- Python
- Node.js
- cURL
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)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.naga.ac/v1", apiKey: "YOUR_API_KEY" });
// Single text
const resp = await client.moderations.create({
model: "omni-moderation-latest",
input: "Hello! Nice to meet you!",
});
console.log(resp);
// Mixed inputs (text + image URL)
const resp2 = await client.moderations.create({
model: "omni-moderation-latest",
input: [
{ type: "text", text: "This is a test." },
{ type: "image_url", url: "https://example.com/photo.jpg" },
],
});
console.log(resp2);
# Single text
curl https://api.naga.ac/v1/moderations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "omni-moderation-latest",
"input": "Hello! Nice to meet you!"
}'
# Mixed inputs (text + image URL)
curl https://api.naga.ac/v1/moderations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "omni-moderation-latest",
"input": [
{ "type": "text", "text": "This is a test." },
{ "type": "image_url", "url": "https://example.com/photo.jpg" }
]
}'
Response
Returns a moderation result compatible with OpenAI's moderation API, typically including categories and scores per input.