curl --location 'https://api.ayrshare.com/api/validate/moderation' \
--header 'Authorization: Bearer API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"text": "Let'\''s kill '\''em all"
}'
const url = "https://api.ayrshare.com/api/validate/moderation";
const apiKey = "API_KEY"; // Replace with your actual API key
const data = {
text: "Let's kill 'em all",
};
fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.error("Error:", error));
import requests
url = 'https://api.ayrshare.com/api/validate/moderation'
api_key = 'API_KEY' # Replace with your actual API key
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
data = {
'text': "Let's kill 'em all"
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
result = response.json()
print(result)
else:
print(f"Error: {response.status_code}")
print(response.text)
<?php
$url = 'https://api.ayrshare.com/api/validate/moderation';
$apiKey = 'API_KEY'; // Replace with your actual API key
$data = [
'text' => "Let's kill 'em all"
];
$headers = [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode == 200) {
$result = json_decode($response, true);
print_r($result);
} else {
echo "Error: HTTP Code " . $httpCode . "\n";
echo $response;
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.ayrshare.com/api/validate/moderation"
apiKey := "API_KEY" // Replace with your actual API key
// Create the request body
requestBody, err := json.Marshal(map[string]string{
"text": "Let's kill 'em all",
})
if err != nil {
fmt.Println("Error creating request body:", err)
return
}
// Create a new request
req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Set headers
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
// Send the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
// Read the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
// Check the status code
if resp.StatusCode == http.StatusOK {
fmt.Println("Response:")
fmt.Println(string(body))
} else {
fmt.Printf("Error: Status Code %d\n", resp.StatusCode)
fmt.Println(string(body))
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Text.Json;
class Program
{
static async Task Main(string[] args)
{
string url = "https://api.ayrshare.com/api/validate/moderation";
string apiKey = "API_KEY"; // Replace with your actual API key
var data = new
{
text = "Let's kill 'em all"
};
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(JsonSerializer.Serialize(data), Encoding.UTF8, "application/json");
try
{
HttpResponseMessage response = await client.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response:");
Console.WriteLine(result);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
catch (HttpRequestException e)
{
Console.WriteLine($"Request error: {e.Message}");
Console.WriteLine($"InnerException: {e.InnerException?.Message}"); // Include inner exception details for more information
}
}
}
}
{
"status": "success",
"text": "Let's kill 'em all",
"moderation": [
{
"flagged": true,
"categories": {
"sexual": false,
"hate": false,
"harassment": false,
"self-harm": false,
"sexual/minors": false,
"hate/threatening": false,
"violence/graphic": false,
"self-harm/intent": false,
"self-harm/instructions": false,
"harassment/threatening": false,
"violence": true
},
"categoryScores": {
"sexual": 0.00002128273445123341,
"hate": 0.027735227718949318,
"harassment": 0.08523011207580566,
"self-harm": 0.0000021838018255948555,
"sexual/minors": 1.924875903114298e-7,
"hate/threatening": 0.0063302298076450825,
"violence/graphic": 0.00024857991957105696,
"self-harm/intent": 7.833968993509188e-7,
"self-harm/instructions": 8.686130570367823e-8,
"harassment/threatening": 0.07459623366594315,
"violence": 0.9833663702011108
}
}
]
}
{
"action": "generate",
"status": "error",
"code": 331,
"message": "There was an issue with the AI processing. Please try again and if the issue persists, contact us."
}
Validate
الإشراف على المحتوى
تحقق من المحتوى للتأكد من أنه ليس ضارًا أو غير لائق
POST
/
validate
/
moderation
curl --location 'https://api.ayrshare.com/api/validate/moderation' \
--header 'Authorization: Bearer API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"text": "Let'\''s kill '\''em all"
}'
const url = "https://api.ayrshare.com/api/validate/moderation";
const apiKey = "API_KEY"; // Replace with your actual API key
const data = {
text: "Let's kill 'em all",
};
fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.error("Error:", error));
import requests
url = 'https://api.ayrshare.com/api/validate/moderation'
api_key = 'API_KEY' # Replace with your actual API key
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
data = {
'text': "Let's kill 'em all"
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
result = response.json()
print(result)
else:
print(f"Error: {response.status_code}")
print(response.text)
<?php
$url = 'https://api.ayrshare.com/api/validate/moderation';
$apiKey = 'API_KEY'; // Replace with your actual API key
$data = [
'text' => "Let's kill 'em all"
];
$headers = [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode == 200) {
$result = json_decode($response, true);
print_r($result);
} else {
echo "Error: HTTP Code " . $httpCode . "\n";
echo $response;
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.ayrshare.com/api/validate/moderation"
apiKey := "API_KEY" // Replace with your actual API key
// Create the request body
requestBody, err := json.Marshal(map[string]string{
"text": "Let's kill 'em all",
})
if err != nil {
fmt.Println("Error creating request body:", err)
return
}
// Create a new request
req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Set headers
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
// Send the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
// Read the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
// Check the status code
if resp.StatusCode == http.StatusOK {
fmt.Println("Response:")
fmt.Println(string(body))
} else {
fmt.Printf("Error: Status Code %d\n", resp.StatusCode)
fmt.Println(string(body))
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Text.Json;
class Program
{
static async Task Main(string[] args)
{
string url = "https://api.ayrshare.com/api/validate/moderation";
string apiKey = "API_KEY"; // Replace with your actual API key
var data = new
{
text = "Let's kill 'em all"
};
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(JsonSerializer.Serialize(data), Encoding.UTF8, "application/json");
try
{
HttpResponseMessage response = await client.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response:");
Console.WriteLine(result);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
catch (HttpRequestException e)
{
Console.WriteLine($"Request error: {e.Message}");
Console.WriteLine($"InnerException: {e.InnerException?.Message}"); // Include inner exception details for more information
}
}
}
}
{
"status": "success",
"text": "Let's kill 'em all",
"moderation": [
{
"flagged": true,
"categories": {
"sexual": false,
"hate": false,
"harassment": false,
"self-harm": false,
"sexual/minors": false,
"hate/threatening": false,
"violence/graphic": false,
"self-harm/intent": false,
"self-harm/instructions": false,
"harassment/threatening": false,
"violence": true
},
"categoryScores": {
"sexual": 0.00002128273445123341,
"hate": 0.027735227718949318,
"harassment": 0.08523011207580566,
"self-harm": 0.0000021838018255948555,
"sexual/minors": 1.924875903114298e-7,
"hate/threatening": 0.0063302298076450825,
"violence/graphic": 0.00024857991957105696,
"self-harm/intent": 7.833968993509188e-7,
"self-harm/instructions": 8.686130570367823e-8,
"harassment/threatening": 0.07459623366594315,
"violence": 0.9833663702011108
}
}
]
}
{
"action": "generate",
"status": "error",
"code": 331,
"message": "There was an issue with the AI processing. Please try again and if the issue persists, contact us."
}
تم تصميم API الإشراف على المحتوى لمساعدة المطورين في تحديد المحتوى النصي الضار أو غير اللائق المحتمل.
تحلل نقطة النهاية هذه المدخلات النصية وتصنفها بناءً على أنواع مختلفة من المحتوى المثير للقلق.
الميزات الرئيسية
- الكشف التلقائي عن المحتوى الضار.
- فئات متعددة من النصوص الإشكالية.
- تكامل سهل لتصفية المحتوى.
كيف يعمل
عند إرسال نص إلى نقطة نهاية الإشراف، فإنها تستخدم نماذج OpenAI لتحليل المحتوى. ثم يعيد API نتائج تشير إلى ما إذا كان النص يقع ضمن أي من الفئات الإشكالية المحددة.فئات المحتوى الضار
يُصنف API النص إلى الفئات التالية:| الفئة | الوصف |
|---|---|
| hate | محتوى يعبر عن الكراهية أو يحرض عليها أو يروج لها استنادًا إلى العرق أو الجنس أو الإثنية أو الدين أو الجنسية أو التوجه الجنسي أو حالة الإعاقة أو الطبقة. المحتوى المليء بالكراهية الموجه ضد مجموعات غير محمية (مثل لاعبي الشطرنج) يعتبر تحرشًا. |
| hate/threatening | محتوى مليء بالكراهية يشمل أيضًا العنف أو الأذى الجسيم تجاه المجموعة المستهدفة على أساس العرق أو الجنس أو الإثنية أو الدين أو الجنسية أو التوجه الجنسي أو حالة الإعاقة أو الطبقة. |
| harassment | محتوى يعبر عن لغة التحرش أو يحرض عليها أو يروج لها ضد أي هدف. |
| harassment/threatening | محتوى تحرش يشمل أيضًا العنف أو الأذى الجسيم تجاه أي هدف. |
| self-harm | محتوى يروج أو يشجع على أفعال إيذاء الذات أو يصورها، مثل الانتحار والجرح واضطرابات الأكل. |
| self-harm/intent | محتوى يعبر فيه المتحدث عن انخراطه أو نيته الانخراط في أفعال إيذاء الذات، مثل الانتحار والجرح واضطرابات الأكل. |
| self-harm/instructions | محتوى يشجع على أداء أفعال إيذاء الذات، مثل الانتحار والجرح واضطرابات الأكل، أو يقدم تعليمات أو نصائح حول كيفية ارتكاب مثل هذه الأفعال. |
| sexual | محتوى يهدف إلى إثارة الإثارة الجنسية، مثل وصف النشاط الجنسي، أو يروج للخدمات الجنسية (باستثناء التثقيف الجنسي والصحة). |
| sexual/minors | محتوى جنسي يتضمن فردًا يقل عمره عن 18 عامًا. |
| violence | محتوى يصور الموت أو العنف أو الإصابة الجسدية. |
| violence/graphic | محتوى يصور الموت أو العنف أو الإصابة الجسدية بتفاصيل صارخة. |
الاستخدام وأفضل الممارسات
- الطول الأمثل للنص: للحصول على أفضل النتائج، نوصي بتقسيم النص الطويل إلى أجزاء أصغر. استهدف أجزاءً أقل من 2000 حرف لكل منها.
- التكامل: استخدم هذا API للإشارة تلقائيًا إلى المحتوى الإشكالي المحتمل في تطبيقاتك أو منتدياتك أو منصات المحتوى الذي ينشئه المستخدمون.
- الإجراء بناءً على النتائج: بناءً على مخرجات API، يمكنك تنفيذ الإجراءات المناسبة مثل تصفية المحتوى أو تحذيرات المستخدم أو عمليات المراجعة الإضافية.
معاملات الرأس
معاملات الجسم
النص المطلوب تحليله للإشراف.
عنوان URL للصورة. يجب أن يبدأ بـ
https://.curl --location 'https://api.ayrshare.com/api/validate/moderation' \
--header 'Authorization: Bearer API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"text": "Let'\''s kill '\''em all"
}'
const url = "https://api.ayrshare.com/api/validate/moderation";
const apiKey = "API_KEY"; // Replace with your actual API key
const data = {
text: "Let's kill 'em all",
};
fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.error("Error:", error));
import requests
url = 'https://api.ayrshare.com/api/validate/moderation'
api_key = 'API_KEY' # Replace with your actual API key
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
data = {
'text': "Let's kill 'em all"
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
result = response.json()
print(result)
else:
print(f"Error: {response.status_code}")
print(response.text)
<?php
$url = 'https://api.ayrshare.com/api/validate/moderation';
$apiKey = 'API_KEY'; // Replace with your actual API key
$data = [
'text' => "Let's kill 'em all"
];
$headers = [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode == 200) {
$result = json_decode($response, true);
print_r($result);
} else {
echo "Error: HTTP Code " . $httpCode . "\n";
echo $response;
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.ayrshare.com/api/validate/moderation"
apiKey := "API_KEY" // Replace with your actual API key
// Create the request body
requestBody, err := json.Marshal(map[string]string{
"text": "Let's kill 'em all",
})
if err != nil {
fmt.Println("Error creating request body:", err)
return
}
// Create a new request
req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Set headers
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
// Send the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
// Read the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
// Check the status code
if resp.StatusCode == http.StatusOK {
fmt.Println("Response:")
fmt.Println(string(body))
} else {
fmt.Printf("Error: Status Code %d\n", resp.StatusCode)
fmt.Println(string(body))
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Text.Json;
class Program
{
static async Task Main(string[] args)
{
string url = "https://api.ayrshare.com/api/validate/moderation";
string apiKey = "API_KEY"; // Replace with your actual API key
var data = new
{
text = "Let's kill 'em all"
};
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(JsonSerializer.Serialize(data), Encoding.UTF8, "application/json");
try
{
HttpResponseMessage response = await client.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response:");
Console.WriteLine(result);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
catch (HttpRequestException e)
{
Console.WriteLine($"Request error: {e.Message}");
Console.WriteLine($"InnerException: {e.InnerException?.Message}"); // Include inner exception details for more information
}
}
}
}
{
"status": "success",
"text": "Let's kill 'em all",
"moderation": [
{
"flagged": true,
"categories": {
"sexual": false,
"hate": false,
"harassment": false,
"self-harm": false,
"sexual/minors": false,
"hate/threatening": false,
"violence/graphic": false,
"self-harm/intent": false,
"self-harm/instructions": false,
"harassment/threatening": false,
"violence": true
},
"categoryScores": {
"sexual": 0.00002128273445123341,
"hate": 0.027735227718949318,
"harassment": 0.08523011207580566,
"self-harm": 0.0000021838018255948555,
"sexual/minors": 1.924875903114298e-7,
"hate/threatening": 0.0063302298076450825,
"violence/graphic": 0.00024857991957105696,
"self-harm/intent": 7.833968993509188e-7,
"self-harm/instructions": 8.686130570367823e-8,
"harassment/threatening": 0.07459623366594315,
"violence": 0.9833663702011108
}
}
]
}
{
"action": "generate",
"status": "error",
"code": 331,
"message": "There was an issue with the AI processing. Please try again and if the issue persists, contact us."
}
⌘I
