Prerequisites
You'll need an API key to use the Moderation API. To get one, you'll need to create a project.1. Install the SDK
Requires Python 3.10 or higher.
2. Submit content
Grab the API key from your project and begin submitting text, images, or other media to your project for moderation.3. Handle errors
The SDK raises specific exception types for different error scenarios:4. Use async
Every method has an async version with the suffix_async:
To retry failed requests, pass
retry_config when you create the client, or retries for one request. You can also set timeout_ms on the client or on one request.Dry-run mode: If you want to analyze production data but don't want to block content, enable "dry-run" in your project settings.
With dry-run enabled, the API still analyzes content but it always returns flagged: false - yet content still shows in the review queue. This way you can implement your moderation workflows and start testing your project configuration without actually blocking content.
3. Review flagged content (optional)
If the AI flags the content, it will appear in the Review inbox. Head to the review queue to validate that the content is submitted correctly.
Review queue for reviewing and improving automated moderation
All Done!
Congratulations! You've run your first moderation checks. Here are a few next steps:- Continue tweaking your project settings and models to find the best moderation outcomes.
- Add custom Guidelines to a channel for rules specific to your platform.
- Explore advanced features like context-aware moderation.
- If you have questions, reach out to our support team.