Build content moderation applications with Azure AI Content Safety SDK for Java. Use when implementing text/image analysis, blocklist management, or harm detection for hate, violence, sexual content,
Install
The skill file stays in the publisher's repository.
Paste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add microsoft/skills --skill azure-ai-contentsafety-java -a cursor -y
Build content moderation applications with Azure AI Content Safety SDK for Java. Use when implementing text/image analysis, blocklist management, or harm detection for hate, violence, sexual content, and self-harm.
Questions
How do I install azure-ai-contentsafety-java?
Download .github/plugins/azure-sdk-java/skills/azure-ai-contentsafety-java/SKILL.md from the publisher, or copy the path and open the repository. PlugMCP lists the skill and does not host the file.
Where does azure-ai-contentsafety-java live?
The publisher keeps it at https://github.com/microsoft/skills.
Which agents can use azure-ai-contentsafety-java?
Claude, Cursor, and Codex can read a SKILL.md you add from the publisher's repository.
Build content moderation applications with Azure AI Content Safety SDK for Java. Use when implementing text/image analysis, blocklist management, or harm detection for hate, violence, sexual content, and self-harm.
name: azure-ai-contentsafety-java
description: Build content moderation applications with Azure AI Content Safety SDK for Java. Use when implementing text/image analysis, blocklist management, or harm detection for hate, violence, sexual content, and self-harm.
license: MIT
metadata:
author: Microsoft
version: "1.0.0"
package: com.azure:azure-ai-contentsafety
Azure AI Content Safety SDK for Java
Build content moderation applications using the Azure AI Content Safety SDK for Java.
import com.azure.core.credential.TokenCredential;
import com.azure.identity.AzureIdentityEnvVars;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.identity.ManagedIdentityCredentialBuilder;
TokenCredential credential = new DefaultAzureCredentialBuilder()
.requireEnvVars(AzureIdentityEnvVars.AZURE_TOKEN_CREDENTIALS)
.build();
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#credential-classes
// TokenCredential credential = new ManagedIdentityCredentialBuilder().build();
ContentSafetyClient client = new ContentSafetyClientBuilder()
.credential(credential)
.endpoint(endpoint)
.buildClient();
Key Concepts
Harm Categories
Category
Description
Hate
Discriminatory language based on identity groups
Sexual
Sexual content, relationships, acts
Violence
Physical harm, weapons, injury
Self-harm
Self-injury, suicide-related content
Severity Levels
Text: 0-7 scale (default outputs 0, 2, 4, 6)
Image: 0, 2, 4, 6 (trimmed scale)
Core Patterns
Analyze Text
import com.azure.ai.contentsafety.models.*;
AnalyzeTextResult result = contentSafetyClient.analyzeText(
new AnalyzeTextOptions("This is text to analyze"));
for (TextCategoriesAnalysis category : result.getCategoriesAnalysis()) {
System.out.printf("Category: %s, Severity: %d%n",
category.getCategory(),
category.getSeverity());
}
Analyze Text with Options
AnalyzeTextOptions options = new AnalyzeTextOptions("Text to analyze")
.setCategories(Arrays.asList(
TextCategory.HATE,
TextCategory.VIOLENCE))
.setOutputType(AnalyzeTextOutputType.EIGHT_SEVERITY_LEVELS);
AnalyzeTextResult result = contentSafetyClient.analyzeText(options);
Analyze Text with Blocklist
AnalyzeTextOptions options = new AnalyzeTextOptions("I h*te you and want to k*ll you")
.setBlocklistNames(Arrays.asList("my-blocklist"))
.setHaltOnBlocklistHit(true);
AnalyzeTextResult result = contentSafetyClient.analyzeText(options);
if (result.getBlocklistsMatch() != null) {
for (TextBlocklistMatch match : result.getBlocklistsMatch()) {
System.out.printf("Blocklist: %s, Item: %s, Text: %s%n",
match.getBlocklistName(),
match.getBlocklistItemId(),
match.getBlocklistItemText());
}
}
Analyze Image
import com.azure.ai.contentsafety.models.*;
import com.azure.core.util.BinaryData;
import java.nio.file.Files;
import java.nio.file.Paths;
// From file
byte[] imageBytes = Files.readAllBytes(Paths.get("image.png"));
ContentSafetyImageData imageData = new ContentSafetyImageData()
.setContent(BinaryData.fromBytes(imageBytes));
AnalyzeImageResult result = contentSafetyClient.analyzeImage(
new AnalyzeImageOptions(imageData));
for (ImageCategoriesAnalysis category : result.getCategoriesAnalysis()) {
System.out.printf("Category: %s, Severity: %d%n",
category.getCategory(),
category.getSeverity());
}
Analyze Image from URL
ContentSafetyImageData imageData = new ContentSafetyImageData()
.setBlobUrl("https://example.com/image.jpg");
AnalyzeImageResult result = contentSafetyClient.analyzeImage(
new AnalyzeImageOptions(imageData));
CONTENT_SAFETY_ENDPOINT=https://<resource>.cognitiveservices.azure.com/ # Required for all auth methods
CONTENT_SAFETY_KEY=<your-api-key> # Only required for AzureKeyCredential auth
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
Best Practices
Blocklist Delay: Changes take ~5 minutes to take effect
Category Selection: Only request needed categories to reduce latency
Severity Thresholds: Typically block severity >= 4 for strict moderation
Batch Processing: Process multiple items in parallel for throughput
Caching: Cache blocklist results where appropriate
Trigger Phrases
"content safety Java"
"content moderation Azure"
"analyze text safety"
"image moderation Java"
"blocklist management"
"hate speech detection"
"harmful content filter"
How do I install azure-ai-contentsafety-java?
Download .github/plugins/azure-sdk-java/skills/azure-ai-contentsafety-java/SKILL.md from the publisher, or copy the path and open the repository. PlugMCP lists the skill and does not host the file.
Where does azure-ai-contentsafety-java live?
The publisher keeps it at https://github.com/microsoft/skills.
Which agents can use azure-ai-contentsafety-java?
Claude, Cursor, and Codex can read a SKILL.md you add from the publisher's repository.