Skip to content
kenari.

Moderations

Classify text and learn whether it is flagged, with a score for each category. The endpoint is compatible with the OpenAI Moderations API.

POST /v1/moderations

Only moderation models are served here. List them with a public call that needs no key:

Terminal window
curl "https://kenari.id/v1/models?modality=moderation"

Otherwise the contract below applies to the ids it returns. A plain GET /v1/models does not list embedding, rerank, moderation or System One models. It does list chat, image, speech, transcription and video models.

FieldTypeRequiredDescription
modelstringyesA moderation model id from the call above.
inputstring or array of stringsyesOne text, or several texts in one request. Every text must be a non-empty string. Up to 2,048 texts and 1 MiB of text in total.

The response has the OpenAI shape. id starts with modr-, model is the id you requested, and results has one entry per input, in the same order. Each entry has flagged, categories (a boolean per category) and category_scores (a number per category). Only the standard OpenAI category names are returned. <model-id> below stands for an id returned by the models call.

{
"id": "modr-...",
"model": "<model-id>",
"results": [
{
"flagged": false,
"categories": { "harassment": false, "hate": false },
"category_scores": { "harassment": 0.001, "hate": 0.0002 }
}
]
}

Replace <model-id> with an id from GET /v1/models?modality=moderation.

Terminal window
curl https://kenari.id/v1/moderations \
-H "Authorization: Bearer $KENARI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<model-id>",
"input": "text to check"
}'
import os
from openai import OpenAI
client = OpenAI(
base_url="https://kenari.id/v1",
api_key=os.environ["KENARI_API_KEY"],
)
result = client.moderations.create(
model="<model-id>",
input="text to check",
)
print(result.results[0].flagged)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://kenari.id/v1",
apiKey: process.env.KENARI_API_KEY,
});
const result = await client.moderations.create({
model: "<model-id>",
input: "text to check",
});
console.log(result.results[0].flagged);

Moderation is billed per input token. Moderation models are free by default, so a model without a price set charges Rp 0. The price of each model is in its catalog entry. See How billing works for balance and price dimensions.

StatusCodeWhen
400bad_requestmodel is unknown or is not a moderation model (the message lists the moderation ids that are available), input is missing or contains an empty or non-string item, or the request is over the 2,048 text or 1 MiB limit.
400model_not_foundThe model is listed but no provider serves it right now. Retry later.
503upstream_error, all_providers_failedNo provider returned a usable response. You are not charged. Retry.

See Errors for the other codes.