abstrakt
Models
Featured
Sora 2 Pro
Featured

Sora 2 Pro

OpenAI's most advanced video generation model with photorealistic output and complex scene understanding.

Veo 3.1
New

Veo 3.1

Google DeepMind's flagship video model with exceptional motion consistency and cinematic quality.

Kling 2.6
Popular

Kling 2.6

Latest Kling model with enhanced character consistency, longer duration support, and improved physics.

Active

100+ AI Models

Access the best AI models from multiple providers through one unified API. Switch models without changing code.

Browse all models
Tools
Featured
AI Image Generator
Popular

AI Image Generator

Create stunning images from text descriptions using FLUX, Stable Diffusion, and more.

Text to Video
New

Text to Video

Transform your ideas into cinematic AI videos with Sora, Veo, and Kling models.

Text to Speech

Text to Speech

Convert text to natural-sounding speech with 30+ voices and emotional expression.

Active

20+ AI Tools

Ready-to-use tools for image, video, and audio generation. No code required — just upload and create.

Explore all tools
Tutorials
Featured
Build Your First AI App
Start Here

Build Your First AI App

Your first AI generation in 5 minutes. Set up your API key and create your first image.

Text-to-Image Masterclass

Text-to-Image Masterclass

Master prompting techniques, model selection, and advanced settings for stunning results.

Text-to-Video Fundamentals

Text-to-Video Fundamentals

Learn to create cinematic AI videos with proper motion, pacing, and storytelling.

Active

Learn AI Generation

Step-by-step guides to master AI image, video, and audio creation. From beginner to advanced.

View all tutorials
Sandbox
Docs
TutorialsAdvancedContent Safety and Filtering
IntermediateUpdated Dec 18, 2025

Content Safety and Filtering

Implement robust content moderation using AI to ensure user-generated content meets safety standards.

MP
Maya Patel
API Architect
7 min read

Why Content Safety Matters

AI-generated content needs moderation to:

  • Prevent harmful outputs
  • Comply with regulations
  • Protect your brand
  • Create safe user experiences

Built-in Safety Features

Abstrakt models include automatic safety filtering:

python
result = client.run("fal-ai/flux/dev", {
    "input": {
        "prompt": "A beautiful landscape",
        "safety_checker": True  # Enabled by default
    }
})

# Check if content was flagged
if result.nsfw_detected:
    print("Content was filtered")

Pre-Generation Filtering

Check prompts before generation:

python
def check_prompt_safety(prompt):
    """Check if prompt is safe before generation."""
    
    result = client.run("fal-ai/content-moderation", {
        "input": {"text": prompt}
    })
    
    return {
        "safe": result.safe,
        "categories": result.flagged_categories,
        "scores": result.category_scores
    }

# Usage
safety = check_prompt_safety(user_prompt)

if not safety["safe"]:
    raise ValueError(f"Unsafe content detected: {safety['categories']}")

Post-Generation Filtering

Check generated content:

python
def moderate_image(image_url):
    """Moderate a generated image."""
    
    result = client.run("fal-ai/image-moderation", {
        "input": {"image_url": image_url}
    })
    
    return {
        "safe": result.safe,
        "nsfw_score": result.nsfw_score,
        "violence_score": result.violence_score,
        "categories": result.flagged_categories
    }

Safety Categories

CategoryDescription
sexualAdult/explicit content
violenceGraphic violence
hateDiscriminatory content
self-harmSelf-injury content
illegalIllegal activities
harassmentBullying/harassment

Custom Blocklists

Create custom word/phrase blocklists:

python
BLOCKED_TERMS = [
    "specific_term_1",
    "specific_term_2",
    # Add your terms
]

def check_blocklist(prompt):
    """Check against custom blocklist."""
    prompt_lower = prompt.lower()
    
    for term in BLOCKED_TERMS:
        if term in prompt_lower:
            return False, term
    
    return True, None

# Usage
is_safe, blocked_term = check_blocklist(user_prompt)
if not is_safe:
    raise ValueError(f"Blocked term detected: {blocked_term}")

Implementing a Safety Pipeline

python
class SafetyPipeline:
    def __init__(self, client):
        self.client = client
        self.blocked_terms = set()
    
    def add_blocked_terms(self, terms):
        self.blocked_terms.update(terms)
    
    async def generate_safely(self, prompt):
        # Step 1: Check blocklist
        if not self._check_blocklist(prompt):
            raise SafetyError("Blocked term detected")
        
        # Step 2: AI moderation
        safety = await self._check_ai_safety(prompt)
        if not safety["safe"]:
            raise SafetyError(f"Unsafe: {safety['categories']}")
        
        # Step 3: Generate
        result = await self.client.run_async("fal-ai/flux/dev", {
            "input": {"prompt": prompt, "safety_checker": True}
        })
        
        # Step 4: Post-generation check
        if result.nsfw_detected:
            raise SafetyError("Generated content flagged")
        
        return result
    
    def _check_blocklist(self, prompt):
        return not any(term in prompt.lower() for term in self.blocked_terms)
    
    async def _check_ai_safety(self, prompt):
        result = await self.client.run_async("fal-ai/content-moderation", {
            "input": {"text": prompt}
        })
        return {"safe": result.safe, "categories": result.flagged_categories}

Handling Flagged Content

python
@app.post("/generate")
async def generate_endpoint(request: GenerateRequest):
    try:
        result = await safety_pipeline.generate_safely(request.prompt)
        return {"image_url": result.images[0].url}
    
    except SafetyError as e:
        # Log for review
        log_safety_incident(request.user_id, request.prompt, str(e))
        
        return {
            "error": "content_policy_violation",
            "message": "Your request couldn't be processed due to our content policy."
        }

Logging & Monitoring

python
def log_safety_incident(user_id, prompt, reason):
    """Log safety incidents for review."""
    incident = {
        "user_id": user_id,
        "prompt": prompt,
        "reason": reason,
        "timestamp": datetime.utcnow(),
        "reviewed": False
    }
    
    # Save to database
    db.safety_incidents.insert_one(incident)
    
    # Alert if needed
    if should_alert(user_id):
        send_alert(f"Multiple safety violations from {user_id}")

Best Practices

  1. Layer defenses - Use multiple checks
  2. Log everything - Enable review and improvement
  3. Human review - Have moderators review edge cases
  4. Update regularly - Keep blocklists current
  5. Clear policies - Communicate guidelines to users

Next Steps

  • Set up webhooks for async moderation
  • Learn RAG patterns
  • Explore API basics
#safety#moderation#content-filtering#trust
PreviousRAG with Vector DatabasesNextPrompt Engineering Masterclass
On This Page
  • Why Content Safety Matters
  • Built-in Safety Features
  • Pre-Generation Filtering
  • Post-Generation Filtering
  • Safety Categories
  • Custom Blocklists
  • Implementing a Safety Pipeline
  • Handling Flagged Content
  • Logging & Monitoring
  • Best Practices
  • Next Steps
Related Guides
Webhook Configuration

Handle async AI jobs with webhook callbacks.

REST API Basics

Master the REST API with curl examples and response patterns.

Was this page helpful?

abstrakt
abstrakt

The unified abstraction layer for the next generation of AI applications. Build faster with any model.

Start Here+
  • Quickstart
  • Get API Key
  • Try Playground
  • View Pricing
Image Tools+
  • AI Image Generator
  • Image to Image
  • Remove Background
  • Image Upscaler
  • Object Remover
  • Style Transfer
  • Image Enhancer
  • AI Art Generator
Video Tools+
  • Text to Video
  • Image to Video
  • AI Video Generator
  • Video Upscaler
  • Video Enhancer
  • Frame Interpolation
Audio Tools+
  • Text to Speech
  • Speech to Text
  • AI Music Generator
  • Voice Cloning
  • Audio Enhancer
  • Sound Effects
Tutorials+
  • Getting Started
  • Image Generation
  • Video Generation
  • Audio Generation
  • Advanced Topics
  • AI Glossary
  • All Tutorials
Models+
  • FLUX Schnell
  • FLUX Dev
  • Fast SDXL
  • Stable Diffusion 3
  • MiniMax Video
  • Kling AI
  • Ideogram
  • More Models
Company+
  • About Us
  • Pricing
  • Documentation
  • Tutorials
  • Blog
  • Contact
  • Changelog
  • Status
  • Careers
  • Privacy Policy
  • Terms of Service
  • Cookie Policy

Image Tools

  • AI Image Generator
  • Image to Image
  • Remove Background
  • Image Upscaler
  • Object Remover
  • Style Transfer
  • Image Enhancer
  • AI Art Generator

Video Tools

  • Text to Video
  • Image to Video
  • AI Video Generator
  • Video Upscaler
  • Video Enhancer
  • Frame Interpolation

Audio Tools

  • Text to Speech
  • Speech to Text
  • AI Music Generator
  • Voice Cloning
  • Audio Enhancer
  • Sound Effects

Tutorials

  • Getting Started
  • Image Generation
  • Video Generation
  • Audio Generation
  • Advanced Topics
  • AI Glossary
  • All Tutorials

Start Here

  • Quickstart
  • Get API Key
  • Try Playground
  • View Pricing

Models

  • FLUX Schnell
  • FLUX Dev
  • Fast SDXL
  • Stable Diffusion 3
  • MiniMax Video
  • Kling AI
  • Ideogram
  • More Models

Company

  • About Us
  • Pricing
  • Documentation
  • Tutorials
  • Blog
  • Contact
  • Changelog
  • Status
  • Careers
  • Privacy Policy
  • Terms of Service
  • Cookie Policy
abstrakt

The unified abstraction layer for the next generation of AI applications.

© 2026 abstrakt. All rights reserved.

SYS.ONLINE|API.ACTIVE|v1.2.0