Quickstart: Protected material detection for text
The Protected Material for Text feature provides a comprehensive solution for managing risks associated with AI-generated content (English content only). By detecting and preventing the display of protected material, organizations can ensure compliance with intellectual property laws, maintain content originality, and protect their reputations. Protected material refers to content that matches known text from copyrighted sources, such as song lyrics, articles, recipes, or other selected web content.
The key objectives of the Protected Material Detection for Text feature for AI-generated content are:
- To detect and prevent the display of protected content generated by AI models.
- To enable organizations to manage risks associated with AI-generated content.
- To ensure that AI-generated content complies with legal, ethical, and content policy guidelines.
For more information about protected material detection, see the Protected material detection concept page. For API input limits, see the Input requirements section of the Overview.
Prerequisites
- An Azure subscription - Create one for free
- Once you have your Azure subscription, create a Content Safety resource in the Azure portal to get your key and endpoint. Enter a unique name for your resource, select your subscription, and select a resource group, supported region (see Region availability), and supported pricing tier. Then select Create.
- The resource takes a few minutes to deploy. After it finishes, Select go to resource. In the left pane, under Resource Management, select Subscription Key and Endpoint. The endpoint and either of the keys are used to call APIs.
- cURL installed
Analyze text for protected material detection
The following section walks through a sample request with cURL. Paste the command below into a text editor, and make the following changes.
- Replace
<endpoint>
with the endpoint URL associated with your resource. - Replace
<your_subscription_key>
with one of the keys that come with your resource. - Optionally, replace the
"text"
field in the body with your own text you'd like to analyze.Tip
See Input requirements for maximum text length limitations. Protected material detection is meant to be run on LLM completions, not user prompts.
curl --location --request POST '<endpoint>/contentsafety/text:detectProtectedMaterial?api-version=2024-09-01' \
--header 'Ocp-Apim-Subscription-Key: <your_subscription_key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"text": "Kiss me out of the bearded barley Nightly beside the green, green grass Swing, swing, swing the spinning step You wear those shoes and I will wear that dress Oh, kiss me beneath the milky twilight Lead me out on the moonlit floor Lift your open hand Strike up the band and make the fireflies dance Silver moon's sparkling So, kiss me Kiss me down by the broken tree house Swing me upon its hanging tire Bring, bring, bring your flowered hat We'll take the trail marked on your father's map."
}'
The below fields must be included in the url:
Name | Required? | Description | Type |
---|---|---|---|
API Version | Required | This is the API version to be checked. The current version is: api-version=2024-09-01. Example: <endpoint>/contentsafety/text:detectProtectedMaterial?api-version=2024-09-01 |
String |
The parameters in the request body are defined in this table:
Name | Required? | Description | Type |
---|---|---|---|
text | Required | This is the raw text to be checked. Other non-ascii characters can be included. | String |
See the following sample request body:
{
"text": "string"
}
Open a command prompt window and run the cURL command.
Interpret the API response
You should see the protected material detection results displayed as JSON data in the console output. For example:
{
"protectedMaterialAnalysis": {
"detected": true
}
}
The JSON fields in the output are defined here:
Name | Description | Type |
---|---|---|
protectedMaterialAnalysis | Each output class that the API predicts. | String |
detected | Whether protected material was detected or not. | Boolean |
Clean up resources
If you want to clean up and remove an Azure AI services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it.
Related content
- Protected material detection concepts
- Configure filters for each category and test on datasets using Content Safety Studio, export the code and deploy.