Zum Hauptinhalt springen
POST
/
v1
/
moderations
curl https://api.cometapi.com/v1/moderations \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <COMETAPI_KEY>" \
  -d '{
  "model": "omni-moderation-latest",
  "input": "I want to bake cookies for my family."
}'
{
  "id": "modr-1594",
  "model": "omni-moderation-latest",
  "results": [
    {
      "flagged": false,
      "categories": {
        "harassment": false,
        "harassment/threatening": false,
        "hate": false,
        "hate/threatening": false,
        "illicit": false,
        "illicit/violent": false,
        "self-harm": false,
        "self-harm/intent": false,
        "self-harm/instructions": false,
        "sexual": false,
        "sexual/minors": false,
        "violence": false,
        "violence/graphic": false
      },
      "category_scores": {
        "harassment": 0.0001,
        "harassment/threatening": 0.0001,
        "hate": 0.0001,
        "hate/threatening": 0.0001,
        "illicit": 0.0001,
        "illicit/violent": 0.0001,
        "self-harm": 0.0001,
        "self-harm/intent": 0.0001,
        "self-harm/instructions": 0.0001,
        "sexual": 0.0001,
        "sexual/minors": 0.0001,
        "violence": 0.0001,
        "violence/graphic": 0.0001
      },
      "category_applied_input_types": {
        "harassment": [
          "text"
        ],
        "harassment/threatening": [
          "text"
        ],
        "hate": [
          "text"
        ],
        "hate/threatening": [
          "text"
        ],
        "illicit": [
          "text"
        ],
        "illicit/violent": [
          "text"
        ],
        "self-harm": [
          "text"
        ],
        "self-harm/intent": [
          "text"
        ],
        "self-harm/instructions": [
          "text"
        ],
        "sexual": [
          "text"
        ],
        "sexual/minors": [
          "text"
        ],
        "violence": [
          "text"
        ],
        "violence/graphic": [
          "text"
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 0,
    "total_tokens": 12,
    "input_tokens": 12,
    "output_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "input_tokens_details": null,
    "claude_cache_creation_1_h_tokens": 0,
    "claude_cache_creation_5_m_tokens": 0
  }
}

Documentation Index

Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt

Use this file to discover all available pages before exploring further.

Verwenden Sie diesen Endpunkt, um nutzergenerierte Inhalte zu prüfen, bevor Sie sie an einen Modell-Endpunkt senden. Senden Sie eine OpenAI-kompatible Moderationsanfrage mit einem model und einem input-Wert.
Verwenden Sie einen CometAPI API-Schlüssel im Bearer-Header: Authorization: Bearer <COMETAPI_KEY>.

Request-Body

FieldTypeRequiredDescription
inputstring oder arrayYesDer zu prüfende Inhalt. Verwenden Sie einen String für eine einzelne Texteingabe, ein Array von Strings für Batch-Textprüfungen oder multimodale Teile im OpenAI-Stil wie Text plus image_url.
modelstringYesModerationsmodell-ID. Verwenden Sie omni-moderation-latest für Text- und Bildmoderation, sofern Sie keine spezielle Anforderung an ein Moderationsmodell haben.
Für multimodale Moderation senden Sie multimodale Eingaben im OpenAI-Stil mit einem Modell, das dies unterstützt, wie z. B. omni-moderation-latest. Öffentliche Bild-URLs müssen von CometAPI-Servern heruntergeladen werden können. Für einen kopierbaren Bildtest verwenden Sie eine Base64-Daten-URL.

Anfragebeispiele

Senden Sie einen einzelnen Text-String, wenn Sie nur eine Texteingabe klassifizieren müssen:
curl https://api.cometapi.com/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <COMETAPI_KEY>" \
  -d '{
    "model": "omni-moderation-latest",
    "input": "I want to bake cookies for my family."
  }'
Senden Sie ein Array von Strings, wenn Sie mehrere Texteingaben in einer Anfrage prüfen möchten:
curl https://api.cometapi.com/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <COMETAPI_KEY>" \
  -d '{
    "model": "omni-moderation-latest",
    "input": [
      "I want to bake cookies.",
      "I want to kill someone."
    ]
  }'
Senden Sie Text plus eine Bild-URL, wenn Ihre Moderationseingabe ein Bild enthält, das CometAPI herunterladen kann:
curl https://api.cometapi.com/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <COMETAPI_KEY>" \
  -d '{
    "model": "omni-moderation-latest",
    "input": [
      { "type": "text", "text": "...text to classify goes here..." },
      {
        "type": "image_url",
        "image_url": {
          "url": "https://www.gstatic.com/webp/gallery/1.png"
        }
      }
    ]
  }'
Verwenden Sie eine Base64-Daten-URL, wenn Sie eine in sich geschlossene Bildanfrage benötigen:
curl https://api.cometapi.com/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <COMETAPI_KEY>" \
  -d '{
    "model": "omni-moderation-latest",
    "input": [
      { "type": "text", "text": "...text to classify goes here..." },
      {
        "type": "image_url",
        "image_url": {
          "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAADElEQVR4nGP4//8/AAX+Av4N70a4AAAAAElFTkSuQmCC"
        }
      }
    ]
  }'

Antwortformat

Die Antwort enthält id, model, results und usage. Jedes Element in results gibt an, ob die entsprechende Eingabe markiert wurde, enthält Kategorie-Boolean-Werte, Kategorie-Scores und auf jede Kategorie angewendete Eingabetypen. Bei einer Batch-Textanfrage enthält results ein Element pro Eingabe-String. Verwenden Sie usage für Abrechnungs- und Monitoring-Felder.

Autorisierungen

Authorization
string
header
erforderlich

CometAPI API key used for model requests. Send it as Authorization: Bearer <COMETAPI_KEY>.

Body

application/json
model
string
erforderlich

Required moderation model ID. Use omni-moderation-latest for text and image moderation unless you have a specific moderation model requirement.

Beispiel:

"omni-moderation-latest"

input
erforderlich

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.

Beispiel:

"I want to check this text before sending it to a model."

Antwort

Moderation decisions and token usage.

id
string
erforderlich

Moderation request ID.

Beispiel:

"modr-1594"

model
string
erforderlich

Model used for moderation.

Beispiel:

"omni-moderation-latest"

results
object[]
erforderlich

Moderation decisions. For batch text input, this array contains one result per input string.

usage
object
erforderlich

Token usage for the moderation request. Additional provider accounting fields can be present.