Kiểm duyệt nội dung
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
POST
https://test.kailin.com.cn/v1/moderationsResponseRESPONSE
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ểu | Bắt buộc | Mô tả |
|---|---|---|---|
model | string | Không | Mặc định là omni-moderation-latest, hỗ trợ đầu vào đa phương thức |
input | string / array | Có | 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ường | Mô tả |
|---|---|
results[].flagged | Nội dung có chạm chính sách hay không |
results[].categories | Kế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.