OpenAI Moderasyonlar
RunAPI'nin OpenAI uyumlu Moderations işlemi aracılığıyla bir istek gönderin.
Genel Bakış
RunAPI'nin OpenAI uyumlu Moderations işlemini, uyumlu bir model ve protokolün istek ile yanıt şekilleriyle kullanın.
Hızlı başlangıç
- Bir API anahtarı oluşturun ve RUNAPI_API_KEY olarak ayarlayın.
- Uyumlu bir model seçin, ardından belgelenen yol parametrelerini ve JSON gövdesini gönderin.
- Bu işlem için gösterilen JSON yanıtını veya sunucu tarafından gönderilen olayları okuyun ve protokol hatalarını işleyin.
Uç Nokta
- Temel URL
https://runapi.ai- Sözleşme sürümü
v1- Tercih edilen kimlik doğrulama
Authorization: Bearer YOUR_API_TOKEN
Kimlik doğrulama taşıyıcıları
RunAPI aşağıda listelenen her taşıyıcıyı kabul eder. Oluşturulan örnekler, protokolün tercih ettiği başlığı kullanır.
- header - Tercih edilen
Authorization: Bearer YOUR_API_TOKEN- header
x-api-key: YOUR_API_TOKEN
Uyumlu modeller
Güncel fiyatlandırma, hız sınırları ve ticari kullanım ayrıntıları için bir model sayfası açın.
1 uyumlu model göster
İstek sözleşmesi
Yalnızca hem genel protokol hem de RunAPI destek kanıtı olan alanlar listelenmektedir. Ek JSON gövde alanları doğrudan iletilir.
JSON gövdesi2 alan
input["string", "array"]Sınıflandırılacak metin veya karışık metin ve görüntü içeriği.
modelstringRunAPI moderasyon modeli tanımlayıcısı; varsayılan değer omni-moderation-latest.
İstek örneği
{
"input": [
{
"text": "A peaceful landscape.",
"type": "text"
},
{
"image_url": {
"url": "https://runapi.ai/icon.png"
},
"type": "image_url"
}
]
}
Eş zamanlı yanıt
Şema
{
"additionalProperties": true,
"properties": {
"id": {
"minLength": 1,
"type": "string"
},
"model": {
"minLength": 1,
"type": "string"
},
"results": {
"items": {
"additionalProperties": true,
"properties": {
"categories": {
"additionalProperties": true,
"type": "object"
},
"category_applied_input_types": {
"additionalProperties": true,
"type": "object"
},
"category_scores": {
"additionalProperties": true,
"type": "object"
},
"flagged": {
"type": "boolean"
}
},
"required": [
"flagged",
"categories",
"category_scores"
],
"type": "object"
},
"minItems": 1,
"type": "array"
}
},
"required": [
"id",
"model",
"results"
],
"type": "object"
}
Örnek
{
"id": "modr_123",
"model": "omni-moderation-latest",
"results": [
{
"categories": {
"sexual": false,
"violence": false
},
"category_applied_input_types": {
"sexual": [
"text",
"image"
],
"violence": [
"text",
"image"
]
},
"category_scores": {
"sexual": 0.0002,
"violence": 0.0001
},
"flagged": false
}
]
}
Protokol hatası: invalid_request
Şema
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Örnek
{
"error": {
"code": null,
"message": "input is required",
"param": "input",
"type": "invalid_request_error"
}
}
Oluşturulan Kod Örnekleri
Her cURL, JavaScript ve Python örneği, protokole özgü bir SDK gerektirmeden bu sözleşmedeki doğrulanmış isteği gönderir.
Yükle
pip install requests
import requests
response = requests.post(
"https://runapi.ai/v1/moderations",
headers={"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"},
json={"input": [{"type": "text", "text": "A peaceful landscape."}, {"type": "image_url", "image_url": {"url": "https://runapi.ai/icon.png"}}]}
)
response.raise_for_status()
print(response.json())