モデレーションを作成する
CometAPI の POST /v1/moderations を使用して、OpenAI 互換のモデレーションリクエストでテキストまたはマルチモーダル入力をチェックします。
model と input の値を含む OpenAI 互換のモデレーションリクエストを送信します。
Authorization: Bearer $COMETAPI_KEY。リクエスト本文
| Field | Type | Required | Description |
|---|---|---|---|
input | string or array | Yes | チェックするコンテンツです。1 つのテキスト入力には文字列を、複数のテキストをまとめてチェックする場合は文字列の配列を、またはテキストと image_url のような OpenAI 形式のマルチモーダル要素を使用します。 |
model | string | Yes | モデレーションの model ID です。特定のモデレーションモデル要件がない限り、テキストと画像のモデレーションには omni-moderation-latest を使用します。 |
omni-moderation-latest のような対応モデルを使って OpenAI 形式のマルチモーダル入力を送信します。公開画像 URL は CometAPI サーバーからダウンロード可能である必要があります。画像をコピー可能なテストにするには、base64 の data URL を使用します。
リクエスト例
テキスト入力が 1 つだけで分類したい場合は、単一のテキスト文字列を送信します。レスポンス形式
レスポンスにはid、model、results、usage が含まれます。results の各項目には、対応する入力がフラグ付けされたかどうか、カテゴリごとの真偽値、カテゴリスコア、各カテゴリに適用された入力タイプが含まれます。バッチテキストリクエストでは、results に入力文字列ごとに 1 項目が含まれます。課金と監視の項目には usage を使用します。承認
CometAPI API key used for model requests. Send it as Authorization: Bearer $COMETAPI_KEY.
ボディ
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."
レスポンス
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.