Tạo một moderation
Sử dụng CometAPI POST /v1/moderations để kiểm tra văn bản hoặc đầu vào đa phương thức bằng một yêu cầu moderation tương thích với OpenAI.
model và input.
Authorization: Bearer $COMETAPI_KEY.Nội dung yêu cầu
| Field | Type | Required | Description |
|---|---|---|---|
input | string hoặc array | Yes | Nội dung cần kiểm tra. Dùng một string cho một đầu vào văn bản, một array các string để kiểm tra văn bản theo lô, hoặc các phần đa phương thức theo kiểu OpenAI như văn bản cộng với image_url. |
model | string | Yes | model ID của moderation. Sử dụng omni-moderation-latest cho moderation văn bản và hình ảnh trừ khi bạn có yêu cầu cụ thể về model moderation. |
omni-moderation-latest. URL hình ảnh công khai phải có thể được máy chủ CometAPI tải xuống. Để thử nghiệm hình ảnh có thể sao chép, hãy sử dụng một base64 data URL.
Ví dụ yêu cầu
Gửi một chuỗi văn bản đơn khi bạn chỉ cần phân loại một đầu vào văn bản:Cấu trúc phản hồi
Phản hồi bao gồmid, model, results và usage. Mỗi mục trong results cho biết đầu vào tương ứng có bị gắn cờ hay không, các giá trị boolean của category, điểm số category và các loại đầu vào được áp dụng cho từng category. Với yêu cầu văn bản theo lô, results chứa một mục cho mỗi chuỗi đầu vào. Sử dụng usage cho các trường phục vụ thanh toán và giám sát.Ủy quyền
CometAPI API key used for model requests. Send it as Authorization: Bearer $COMETAPI_KEY.
Nội dung
Required moderation model ID. Use omni-moderation-latest for text and image moderation unless you have a specific moderation model requirement.
"omni-moderation-latest"
Content to check. Use a string for one text input, an array of strings for batch text checks, or OpenAI-style multimodal parts such as text plus image_url when the selected model supports it.
"I want to check this text before sending it to a model."
Phản hồi
Moderation decisions and token usage.
Moderation request ID.
"modr-1594"
Model used for moderation.
"omni-moderation-latest"
Moderation decisions. For batch text input, this array contains one result per input string.
Token usage for the moderation request. Additional provider accounting fields can be present.