import ModerationAPI from "@moderation-api/sdk";
// Configure your client using environment variable MODAPI_SECRET_KEY
const moderationApi = new ModerationAPI();
// Submit object (complex data) for moderation
const result = await moderationApi.content.submit({
content: {
type: "object",
data: {
title: { type: "text", text: "Post title" },
body: { type: "text", text: "Post content" },
thumbnail: { type: "image", url: "https://example.com/thumb.jpg" },
},
},
contentId: "post-789",
authorId: "user-123",
metadata: {
customField: "value",
},
});
// Check if content was flagged
if (result.evaluation.flagged) {
console.warn("Object content flagged");
// Block or require review
}
// Use the API's recommendation
switch (result.recommendation.action) {
case "reject":
console.log("Object should be rejected");
break;
case "review":
console.log("Object needs manual review");
break;
case "allow":
console.log("Object is approved");
break;
}