Chuyển đến nội dung chính

Kiểm duyệt nội dung

POST /v1/moderations

Phân loại văn bản/hình ảnh theo các chính sách an toàn phục vụ kiểm duyệt nội dung, trả về cờ theo danh mục và điểm độ tin cậy.

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

Yêu cầu​

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"
}'

Thân yêu cầu​

Tham sốKiểuBắt buộcMô tả
modelstringKhôngMặc định là omni-moderation-latest, hỗ trợ đầu vào đa phương thức
inputstring / arrayCóVăn bản cần kiểm duyệt; với đầu vào đa phương thức, hãy truyền một mảng nội dung

Đầu vào đa phương thức (văn bản + hình ảnh):

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

Phản hồi​

{
"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
}
}
]
}
TrườngMô tả
results[].flaggedNội dung có chạm chính sách hay không
results[].categoriesKết quả boolean theo từng danh mục (còn nhiều danh mục khác, ví dụ harassment_threatening, self-harm)
results[].category_scoresĐộ tin cậy 0–1 theo từng danh mục

Cách dùng điển hình​

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
Ghi chú

Kiểm duyệt thường miễn phí hoặc chi phí thấp (tùy kênh). Hãy gọi nó cho cả đầu vào của người dùng và đầu ra của mô hình để đảm bảo an toàn hai chiều.