Understanding Azure Content Safety Text Moderation API

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this segment, you will explore the Azure Safety Content Text Moderation API and how to use it in Python using client SDK in detail. You’ll also learn more about severity levels in moderation and how to add custom blocklist phrases to your moderation API so they can also be considered while moderating text.

Understanding Azure Safety Content Text Moderation API

For text moderation, Azure Safety Content provides two types of API:

Understanding the Azure AI Content Safety Client Python Library

The first step to using a content safety client is to create an instance of it. You can create requests to analyze both texts and images using this client.

Understanding AnalyzeTextOptions

AnalyzeTextOptions object is used to construct the request for text analyses. It also allows you to customize text analysis requests to suit your specific needs. It has the following properties:

Processing Analyses Response

Once the analyses of text content is finished, you can use the response received from the method client.analyze_text to decide whether to approve the content or block it.

Add custom blocklist phrases

If required, you can further customize the text moderation API results to detect blocklist terms that meet your platform needs. You’ll first need to add the blocklist terms to your moderation resource. Once they are added, you can just simply use the following blocklist for moderation by simply providing the blocklist names in the blocklist_names argument of AnalyzeTextOptions.

See forum comments
Download course materials from Github
Previous: Exploring Text Moderation in Content Safety Studio Next: Implementing Text Moderation Using Azure Content Safety API