Official agent skill

Azure AI Contentsafety Java

by microsoft in microsoft/skills

Build content moderation applications with Azure AI Content Safety SDK for Java.

OfficialMITAuto-check passedAI & LLM Engineering

Install Azure AI Contentsafety Java

skills CLI
$ npx skills add microsoft/skills --skill azure-ai-contentsafety-java -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install microsoft/skills azure-ai-contentsafety-java --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/microsoft/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/plugins/azure-sdk-java/skills/azure-ai-contentsafety-java .claude/skills/azure-ai-contentsafety-java && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
azure-ai-contentsafety-java
GitHub stars
3.1k
Used in
6 other repos
Token cost
~2.1k tokens
SKILL.md length
187 words
Files
2 (incl. references)
Skills in repo
150
Repo updated
First seen
Licence
MIT

At a glance

Build content moderation applications with Azure AI Content Safety SDK for Java.

  • Works in 5 steps: Blocklist Delay: Changes take ~5 minutes… → Category Selection: Only request needed… → Severity Thresholds: Typically block… → …
  • Implementing text/image analysis
  • SKILL.md covers Installation, Client Creation, Key Concepts and Core Patterns, plus 5 more sections
  • Reaches learn.microsoft.com; needs CONTENT_SAFETY_KEY and AZURE_TOKEN_CREDENTIALS

What it does

Azure AI Contentsafety Java is an agent skill from microsoft/skills, published by the product's own GitHub organization. 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.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/examples.md`).

It sits in AI & LLM Engineering, covering LLM guardrails. It works with Java, Microsoft Azure and Azure AI Content Safety. The repository describes itself as: Skills, MCP servers, Custom Agents, Agents.md for SDKs to ground Coding Agents. The licence is MIT.

When your agent uses it

  • Implementing text/image analysis
  • Blocklist management
  • Harm detection for hate

Example prompts

  • “/azure-ai-contentsafety-java”

Requirements

  • A credential in CONTENT_SAFETY_KEY

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Blocklist Delay: Changes take ~5 minutes to take effect
  2. Category Selection: Only request needed categories to reduce latency
  3. Severity Thresholds: Typically block severity >= 4 for strict moderation
  4. Batch Processing: Process multiple items in parallel for throughput
  5. Caching: Cache blocklist results where appropriate

What it can do on your machine

Read from SKILL.md and the folder at commit 354361d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java, xml and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • learn.microsoft.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • CONTENT_SAFETY_KEY
    • AZURE_TOKEN_CREDENTIALS

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Azure AI Contentsafety Java loads about 2.1k tokens when it runs, and up to ~6.5k if it reads all its reference files. Until then it costs about 61 tokens; SKILL.md has 187 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~61
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from microsoft/skills at commit 354361d, republished under its MIT licence (© microsoft). 187 words, ~2,128 tokens.

Download SKILL.mdSave it as .claude/skills/azure-ai-contentsafety-java/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
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
metadata.version
1.0.0
metadata.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.

Installation

xml
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-ai-contentsafety</artifactId>
    <version>1.1.0-beta.1</version>
</dependency>

Client Creation

With API Key
java
import 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();
With DefaultAzureCredential
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
CategoryDescription
HateDiscriminatory language based on identity groups
SexualSexual content, relationships, acts
ViolencePhysical harm, weapons, injury
Self-harmSelf-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
java
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
java
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
java
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
java
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
java
ContentSafetyImageData imageData = new ContentSafetyImageData()
    .setBlobUrl("https://example.com/image.jpg");

AnalyzeImageResult result = contentSafetyClient.analyzeImage(
    new AnalyzeImageOptions(imageData));

Blocklist Management

Create or Update Blocklist
java
import 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");
}
Add Block Items
java
import 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());
}
List Blocklists
java
PagedIterable<TextBlocklist> blocklists = blocklistClient.listTextBlocklists();

for (TextBlocklist blocklist : blocklists) {
    System.out.printf("Blocklist: %s, Description: %s%n",
        blocklist.getName(),
        blocklist.getDescription());
}
Get Blocklist
java
TextBlocklist blocklist = blocklistClient.getTextBlocklist("my-blocklist");
System.out.println("Name: " + blocklist.getName());
List Block Items
java
PagedIterable<TextBlocklistItem> items = 
    blocklistClient.listTextBlocklistItems("my-blocklist");

for (TextBlocklistItem item : items) {
    System.out.printf("ID: %s, Text: %s%n",
        item.getBlocklistItemId(),
        item.getText());
}
Remove Block Items
java
List<String> itemIds = Arrays.asList("item-id-1", "item-id-2");

blocklistClient.removeBlocklistItems(
    "my-blocklist",
    new RemoveTextBlocklistItemsOptions(itemIds));
Delete Blocklist
java
blocklistClient.deleteTextBlocklist("my-blocklist");

Error Handling

java
import 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
}

Environment Variables

bash
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

  1. Blocklist Delay: Changes take ~5 minutes to take effect
  2. Category Selection: Only request needed categories to reduce latency
  3. Severity Thresholds: Typically block severity >= 4 for strict moderation
  4. Batch Processing: Process multiple items in parallel for throughput
  5. 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"

© microsoft, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in .github/plugins/azure-sdk-java/skills/azure-ai-contentsafety-java of microsoft/skills.

  • SKILL.md
  • references/examples.md

Open the folder on GitHubat commit 354361d

Used in 6 other repositories

We found 15 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 6 other GitHub owners. This page covers the copy in microsoft/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Azure AI Contentsafety Java next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Azure AI Contentsafety Java compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Azure AI Contentsafety Java this skillmicrosoft/skills3.1k6 repos~2.1kAutomated safety check: PassMIT
Cost Governancemicrosoft/GitHub-Copilot-for-Azure255—~476Automated safety check: PassMIT
Hardening Cloud Posturetrilwu/secskills156—~1.9kAutomated safety check: PassMIT
Extend Commands APIredis/lettuce5.8k—~7.7kAutomated safety check: NotesMIT
Writing Javadocredis/lettuce5.8k—~809Automated safety check: PassMIT
Azsdk Common Generate SDK LocallyAzure/azure-sdk-for-android121—~1.5kAutomated safety check: PassMIT

Similar skills

  • Cost Governance

    microsoft/GitHub-Copilot-for-Azure

    Official

    Govern Azure costs with budgets, alerts, tags, and policy restrictions.

    255 GitHub stars~476 tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Hardening Cloud Posture

    trilwu/secskills

    Proactively harden a cloud account or organization before an incident — prioritizing IAM and identity risk over checkbox findings, closing the exposures that become attack paths (public storage…

    156 GitHub stars~1.9k tokensUpdated 1 mo ago
    SecurityAuto-check passed
  • Extend Commands API

    redis/lettuce

    Official

    Add or extend Redis commands in the Lettuce client API end-to-end — a new core command, a family of new commands, an extension to an existing command's options, or a module/area command…

    5.8k GitHub stars~7.7k tokensUpdated today
    DatabasesAuto-check: notes
  • Writing Javadoc

    redis/lettuce

    Official

    A skill your agent uses when writing or editing Javadoc for Lettuce public API — new methods, classes, deprecations, or when a reviewer asks to fix or improve doc comments.

    5.8k GitHub stars~809 tokensUpdated today
    DatabasesAuto-check passed
  • Azsdk Common Generate SDK Locally

    Azure/azure-sdk-for-android

    Official

    Generate, build, and test Azure SDKs locally from TypeSpec with automatic customization.

    121 GitHub stars~1.5k tokensUpdated 4 mo ago
    DevelopmentAuto-check passed
  • Azure Upgrade

    microsoft/GitHub-Copilot-for-Azure

    Official

    Assess and upgrade Azure workloads between plans, tiers, or SKUs, or modernize Azure SDK dependencies in source code.

    255 GitHub starsUsed in 1 repo~1.5k tokens
    DatabasesAuto-check passed

More from microsoft/skills

All 150 skills in this repo
  • Official

    Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.

    3.1k GitHub starsUsed in 6 repos~2.8k tokens
    Auto-check passed
  • Official

    Python guidance for the Azure AI Search SDK covering vector, hybrid and semantic search, index management and indexers, with Entra ID authentication preferred over keys.

    3.1k GitHub starsUsed in 6 repos~4.4k tokens
    Auto-check passed
  • Official

    Covers producer, consumer, and checkpoint-store setup for Azure Event Hubs streaming in Python, with Entra ID auth and partition targeting.

    3.1k GitHub starsUsed in 1 repo~2.3k tokens
    Auto-check passed
  • Pydantic Models Py

    microsoft/skills

    Official

    Create Pydantic models following the multi-model pattern with Base, Create, Update, Response, and InDB variants.

    3.1k GitHub starsUsed in 6 repos~496 tokens
    Auto-check passed
  • Official

    Builds podcast-style audio narration from text with Azure OpenAI's GPT Realtime Mini over WebSocket, from a Python FastAPI backend to a React player.

    3.1k GitHub starsUsed in 1 repo~947 tokens
    Auto-check passed
  • Frontend UI Dark TS

    microsoft/skills

    Official

    Build dark-themed React applications using Tailwind CSS with custom theming, glassmorphism effects, and Framer Motion animations.

    3.1k GitHub starsUsed in 5 repos~3.6k tokens
    Auto-check passed

Questions about Azure AI Contentsafety Java

What does Azure AI Contentsafety Java do?

Build content moderation applications with Azure AI Content Safety SDK for Java. Azure AI Contentsafety Java is an agent skill from microsoft/skills, published by the product's own GitHub organization. Build content moderation applications with Azure AI Content Safety SDK for Java.

When should I use Azure AI Contentsafety Java?

Azure AI Contentsafety Java fits situations like: implementing text/image analysis; blocklist management; harm detection for hate.

How do I install Azure AI Contentsafety Java in Claude Code?

Run `npx skills add microsoft/skills --skill azure-ai-contentsafety-java -a claude-code`. Or copy the skill folder (.github/plugins/azure-sdk-java/skills/azure-ai-contentsafety-java in microsoft/skills) into .claude/skills/azure-ai-contentsafety-java in your project. Claude Code loads it when a task matches its description.

How do I install Azure AI Contentsafety Java in Codex?

Run `npx skills add microsoft/skills --skill azure-ai-contentsafety-java -a codex`. Or copy the skill folder (.github/plugins/azure-sdk-java/skills/azure-ai-contentsafety-java in microsoft/skills) into .agents/skills/azure-ai-contentsafety-java in your project. Codex loads it when a task matches its description.

Can I use Azure AI Contentsafety Java in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add microsoft/skills --skill azure-ai-contentsafety-java -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/azure-ai-contentsafety-java, .gemini/skills/azure-ai-contentsafety-java, .github/skills/azure-ai-contentsafety-java and .opencode/skills/azure-ai-contentsafety-java in your project.

What does Azure AI Contentsafety Java need to run?

Going by SKILL.md and its folder, Azure AI Contentsafety Java needs credentials named CONTENT_SAFETY_KEY and AZURE_TOKEN_CREDENTIALS. Our summary lists: A credential in CONTENT_SAFETY_KEY.

Does Azure AI Contentsafety Java access the network?

SKILL.md names 1 domain. In commands or code: learn.microsoft.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Azure AI Contentsafety Java safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Azure AI Contentsafety Java use?

Azure AI Contentsafety Java is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Azure AI Contentsafety Java use?

About 2.1k tokens (SKILL.md is roughly 8.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.4k tokens, read only when the agent opens those files.

What are the alternatives to Azure AI Contentsafety Java?

Skills that share tags, products or a category with Azure AI Contentsafety Java: Cost Governance (microsoft/GitHub-Copilot-for-Azure, 255 stars), Hardening Cloud Posture (trilwu/secskills, 156 stars), Extend Commands API (redis/lettuce, 5.8k stars) and Writing Javadoc (redis/lettuce, 5.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Azure AI Contentsafety Java?

microsoft (a GitHub organization, an official publisher) maintains it in microsoft/skills, which has 3,086 GitHub stars. The repository holds 150 skills in this directory. The repository was last updated on October 6, 2026.

Source: microsoft/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.