メインコンテンツへスキップ

モデレーション

POST /v1/moderations

テキスト/画像を安全ポリシーに対して分類し、コンテンツモデレーションを行います。カテゴリごとのフラグと信頼度スコアを返します。

RequestREQUEST
POSThttps://test.kailin.com.cn/v1/moderations
ResponseRESPONSE
Fill in the request and hit Send — the response shows up here

リクエスト​

curl https://test.kailin.com.cn/v1/moderations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token" \
-d '{
"model": "omni-moderation-latest",
"input": "text to review"
}'

リクエストボディ​

パラメーター型必須説明
modelstringいいえデフォルトは omni-moderation-latest。マルチモーダル入力に対応
inputstring / arrayはい審査対象のテキスト。マルチモーダルの場合はコンテンツ配列を渡します

マルチモーダル入力(テキスト + 画像):

{
"model": "omni-moderation-latest",
"input": [
{ "type": "moderation_text", "text": "some text" },
{ "type": "moderation_image", "image_url": "https://example.com/img.jpg" }
]
}

レスポンス​

{
"id": "modr-abc123",
"model": "omni-moderation-latest",
"results": [
{
"flagged": false,
"categories": {
"harassment": false,
"hate": false,
"sexual": false,
"violence": false
},
"category_scores": {
"harassment": 0.0001,
"hate": 0.0001,
"sexual": 0.0002,
"violence": 0.0003
}
}
]
}
フィールド説明
results[].flaggedコンテンツがポリシーに抵触したかどうか
results[].categoriesカテゴリごとの真偽結果(harassment_threatening、self-harm など、他のカテゴリも存在します)
results[].category_scoresカテゴリごとの信頼度 0–1

典型的な使い方​

def check(text: str) -> bool:
resp = client.moderations.create(model="omni-moderation-latest", input=text)
return resp.results[0].flagged # True means the content should be blocked
備考

モデレーションは無料または低コストです(チャネルに依存)。双方向の安全性のため、ユーザー入力とモデル出力の両方に対して呼び出してください。