Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Build content moderation applications using the Azure AI Content Safety SDK for Java.
.claude/skills/azure-ai-contentsafety-java/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-13 | ✗→✓ | ▲ Improved | — | — |
| case-04 | ✗→✓ | ▲ Improved | — | — |
| case-19 | ✗→✓ | ▲ Improved | — | — |
| case-12 | ✗→✓ | ▲ Improved | — | — |
Build content moderation applications using the Azure AI Content Safety SDK for Java.
xml<dependency> <groupId>com.azure</groupId> <artifactId>azure-ai-contentsafety</artifactId> <version>1.1.0-beta.1</version> </dependency>
javaimport com.azure.ai.contentsafety.ContentSafetyClient; import com.azure.ai.contentsafety.ContentSafetyClientBuilder; import com.azure.ai.contentsafety.BlocklistClient; import com.azure.ai.contentsafety.BlocklistClientBuilder; import com.azure.core.credential.KeyCredential; String endpoint = System.getenv("CONTENT_SAFETY_ENDPOINT"); String key = System.getenv("CONTENT_SAFETY_KEY"); ContentSafetyClient contentSafetyClient = new ContentSafetyClientBuilder() .credential(new KeyCredential(key)) .endpoint(endpoint) .buildClient(); BlocklistClient blocklistClient = new BlocklistClientBuilder() .credential(new KeyCredential(key)) .endpoint(endpoint) .buildClient();
javaimport com.azure.identity.DefaultAzureCredentialBuilder; ContentSafetyClient client = new ContentSafetyClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .endpoint(endpoint) .buildClient();
| 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 |
javaimport 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()); }
javaAnalyzeTextOptions options = new AnalyzeTextOptions("Text to analyze") .setCategories(Arrays.asList( TextCategory.HATE, TextCategory.VIOLENCE)) .setOutputType(AnalyzeTextOutputType.EIGHT_SEVERITY_LEVELS); AnalyzeTextResult result = contentSafetyClient.analyzeText(options);
javaAnalyzeTextOptions 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()); } }
javaimport 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()); }
javaContentSafetyImageData imageData = new ContentSafetyImageData() .setBlobUrl("https://example.com/image.jpg"); AnalyzeImageResult result = contentSafetyClient.analyzeImage( new AnalyzeImageOptions(imageData));
javaimport com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; import java.util.Map; Map<String, String> description = Map.of("description", "Custom blocklist"); BinaryData resource = BinaryData.fromObject(description); Response<BinaryData> response = blocklistClient.createOrUpdateTextBlocklistWithResponse( "my-blocklist", resource, new RequestOptions()); if (response.getStatusCode() == 201) { System.out.println("Blocklist created"); } else if (response.getStatusCode() == 200) { System.out.println("Blocklist updated"); }
javaimport com.azure.ai.contentsafety.models.*; import java.util.Arrays; List<TextBlocklistItem> items = Arrays.asList( new TextBlocklistItem("badword1").setDescription("Offensive term"), new TextBlocklistItem("badword2").setDescription("Another term") ); AddOrUpdateTextBlocklistItemsResult result = blocklistClient.addOrUpdateBlocklistItems( "my-blocklist", new AddOrUpdateTextBlocklistItemsOptions(items)); for (TextBlocklistItem item : result.getBlocklistItems()) { System.out.printf("Added: %s (ID: %s)%n", item.getText(), item.getBlocklistItemId()); }
javaPagedIterable<TextBlocklist> blocklists = blocklistClient.listTextBlocklists(); for (TextBlocklist blocklist : blocklists) { System.out.printf("Blocklist: %s, Description: %s%n", blocklist.getName(), blocklist.getDescription()); }
javaTextBlocklist blocklist = blocklistClient.getTextBlocklist("my-blocklist"); System.out.println("Name: " + blocklist.getName());
javaPagedIterable<TextBlocklistItem> items = blocklistClient.listTextBlocklistItems("my-blocklist"); for (TextBlocklistItem item : items) { System.out.printf("ID: %s, Text: %s%n", item.getBlocklistItemId(), item.getText()); }
javaList<String> itemIds = Arrays.asList("item-id-1", "item-id-2"); blocklistClient.removeBlocklistItems( "my-blocklist", new RemoveTextBlocklistItemsOptions(itemIds));
javablocklistClient.deleteTextBlocklist("my-blocklist");
javaimport com.azure.core.exception.HttpResponseException; try { contentSafetyClient.analyzeText(new AnalyzeTextOptions("test")); } catch (HttpResponseException e) { System.out.println("Status: " + e.getResponse().getStatusCode()); System.out.println("Error: " + e.getMessage()); // Common codes: InvalidRequestBody, ResourceNotFound, TooManyRequests }
bashCONTENT_SAFETY_ENDPOINT=https://<resource>.cognitiveservices.azure.com/ CONTENT_SAFETY_KEY=<your-api-key>
This skill is applicable to execute the workflow or actions described in the overview.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +36 percentage points is the difference between those two pass rates over the 22 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.