Przejdź do głównej treści
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.

Użyj tego endpointu, aby sprawdzać treści generowane przez użytkowników przed wysłaniem ich do endpointu modelu. Wyślij żądanie moderacji zgodne z OpenAI z wartością model i input.
Użyj klucza API CometAPI w nagłówku bearer: Authorization: Bearer <COMETAPI_KEY>.

Treść żądania

FieldTypeRequiredDescription
inputstring or arrayYesTreść do sprawdzenia. Użyj string dla pojedynczego wejścia tekstowego, tablicy stringów do wsadowego sprawdzania tekstu lub części multimodalnych w stylu OpenAI, takich jak tekst plus image_url.
modelstringYesmodel ID moderacji. Użyj omni-moderation-latest do moderacji tekstu i obrazów, chyba że masz konkretne wymagania dotyczące modelu moderacji.
W przypadku moderacji multimodalnej wyślij dane wejściowe multimodalne w stylu OpenAI z modelem, który je obsługuje, takim jak omni-moderation-latest. Publiczne adresy URL obrazów muszą być możliwe do pobrania przez serwery CometAPI. Jeśli chcesz użyć obrazu testowego, który można łatwo skopiować, użyj adresu URL danych base64.

Przykłady żądań

Wyślij pojedynczy ciąg tekstowy, gdy chcesz sklasyfikować tylko jedno wejście tekstowe:
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."
  }'
Wyślij tablicę ciągów tekstowych, gdy chcesz sprawdzić wiele wejść tekstowych w jednym żądaniu:
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."
    ]
  }'
Wyślij tekst wraz z adresem URL obrazu, gdy dane wejściowe moderacji obejmują obraz, który CometAPI może pobrać:
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"
        }
      }
    ]
  }'
Użyj adresu URL danych base64, gdy potrzebujesz samowystarczalnego żądania obrazu:
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"
        }
      }
    ]
  }'

Kształt odpowiedzi

Odpowiedź zawiera id, model, results oraz usage. Każdy element w results informuje, czy odpowiadające mu dane wejściowe zostały oznaczone, zawiera wartości logiczne kategorii, wyniki kategorii oraz typy danych wejściowych zastosowane do każdej kategorii. W przypadku wsadowego żądania tekstowego results zawiera jeden element dla każdego wejściowego ciągu tekstowego. Użyj usage do pól związanych z rozliczeniami i monitorowaniem.

Autoryzacje

Authorization
string
header
wymagane

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

Treść

application/json
model
string
wymagane

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

Przykład:

"omni-moderation-latest"

input
wymagane

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.

Przykład:

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

Odpowiedź

Moderation decisions and token usage.

id
string
wymagane

Moderation request ID.

Przykład:

"modr-1594"

model
string
wymagane

Model used for moderation.

Przykład:

"omni-moderation-latest"

results
object[]
wymagane

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

usage
object
wymagane

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