モデレーション
テキスト/画像を安全ポリシーに対して分類し、コンテンツモデレーションを行います。カテゴリごとのフラグと信頼度スコアを返します。
RequestREQUEST
POST
https://test.kailin.com.cn/v1/moderationsResponseRESPONSE
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"
}'
リクエストボディ
| パラメーター | 型 | 必須 | 説明 |
|---|---|---|---|
model | string | いいえ | デフォルトは omni-moderation-latest。マルチモーダル入力に対応 |
input | string / 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
備考
モデレーションは無料または低コストです(チャネルに依存)。双方向の安全性のため、ユーザー入力とモデル出力の両方に対して呼び出してください。