Skip to main content
The SDK provides built-in content moderation capabilities that detect potentially harmful content and expose violation details through response data. How you handle these violations is entirely up to your application’s requirements and policies.

Quick Start

Enable content moderation by setting the compliance option to true:
Performance Note: Enabling compliance checking adds a small amount of latency to requests as content is analyzed for violations. While minimal, consider this when designing real-time applications.

Configuration Options

Global Compliance Setting

Enable moderation for all chat interactions:

Per-Message Compliance

Control moderation on a per-message basis:

Violation Detection

When compliance checking is enabled, the response includes violation information that your application can use:

Content Violation Categories

The system can detect and report the following categories of potentially harmful content:

Streaming with Moderation

Content moderation works with both streaming and non-streaming responses. For streaming responses, compliance violations are available in the chunk data:

Non-Streaming with Moderation

For non-streaming responses, compliance violations are available in the response object:

Event-Driven Chat with Moderation

When using chat.send(), compliance violations are available in the messageComplete event:

Application Examples

Flexible Violation Handling

Educational Approach

Moderation Queue

Error Handling

Handle moderation failures gracefully:

Key Points

  • Violation Detection: The system detects and reports violations, but doesn’t automatically block content
  • Application Control: Your application decides how to handle each type of violation
  • Flexible Policies: Implement content policies that match your application’s needs
  • User Experience: Choose between blocking, warning, educating, or queuing for review
  • Escalation: Decide which violations require immediate action vs. review
  • Logging: Track violations for analysis and policy improvement

Next Steps

Event System

Learn about the SDK’s event system for chat and image generation

Chat Completions

Integrate moderation with chat features

Streaming Responses

Handle violations in real-time streaming

REST API Moderation

Direct API moderation implementation