الانتقال إلى المحتوى الرئيسي
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
  }
}
استخدم نقطة النهاية هذه لفحص المحتوى الذي ينشئه المستخدم قبل إرساله إلى نقطة نهاية model. أرسل طلب moderation متوافقًا مع OpenAI مع قيمة model وقيمة input.
استخدم مفتاح API من CometAPI في ترويسة bearer: Authorization: Bearer $COMETAPI_KEY.

نص الطلب

الحقلالنوعمطلوبالوصف
inputstring أو arrayنعمالمحتوى المطلوب فحصه. استخدم string لإدخال نصي واحد، أو array من strings لفحص نصوص متعددة دفعة واحدة، أو أجزاء متعددة الوسائط بأسلوب OpenAI مثل النص مع image_url.
modelstringنعمmodel ID الخاص بـ moderation. استخدم omni-moderation-latest لفحص النصوص والصور ما لم يكن لديك متطلب محدد لنموذج moderation.
بالنسبة إلى moderation متعدد الوسائط، أرسل إدخالًا متعدد الوسائط بأسلوب OpenAI مع نموذج يدعمه، مثل omni-moderation-latest. يجب أن تكون روابط الصور العامة قابلة للتنزيل بواسطة خوادم CometAPI. ولاختبار صورة قابل للنسخ، استخدم عنوان URL لبيانات base64.

أمثلة الطلب

أرسل string نصية واحدة عندما تحتاج فقط إلى تصنيف إدخال نصي واحد:
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."
  }'
أرسل array من strings عندما تريد فحص عدة مدخلات نصية في طلب واحد:
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."
    ]
  }'
أرسل نصًا مع رابط URL لصورة عندما يتضمن إدخال moderation صورة يمكن لـ CometAPI تنزيلها:
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"
        }
      }
    ]
  }'
استخدم عنوان URL لبيانات base64 عندما تحتاج إلى طلب صورة مكتفٍ ذاتيًا:
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"
        }
      }
    ]
  }'

شكل الاستجابة

تتضمن الاستجابة id وmodel وresults وusage. يوضح كل عنصر في results ما إذا كان الإدخال المطابق قد تم تمييزه، وقيم الفئات المنطقية، ودرجات الفئات، وأنواع الإدخال المطبقة على كل فئة. بالنسبة إلى طلب نصي دفعي، يحتوي results على عنصر واحد لكل string إدخال. استخدم usage لحقول الفوترة والمراقبة.

التفويضات

Authorization
string
header
مطلوب

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

الجسم

application/json
model
string
مطلوب

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

مثال:

"omni-moderation-latest"

input
مطلوب

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.

id
string
مطلوب

Moderation request ID.

مثال:

"modr-1594"

model
string
مطلوب

Model used for moderation.

مثال:

"omni-moderation-latest"

results
object[]
مطلوب

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

usage
object
مطلوب

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