{"id":"a2d90456-7512-4b19-926e-f216b15bcff6","shortId":"Eeqt6n","kind":"skill","title":"azure-ai-contentsafety-java","tagline":"Build content moderation applications using the Azure AI Content Safety SDK for Java.","description":"# Azure AI Content Safety SDK for Java\n\nBuild content moderation applications using the Azure AI Content Safety SDK for Java.\n\n## Installation\n\n```xml\n<dependency>\n    <groupId>com.azure</groupId>\n    <artifactId>azure-ai-contentsafety</artifactId>\n    <version>1.1.0-beta.1</version>\n</dependency>\n```\n\n## Client Creation\n\n### With API Key\n\n```java\nimport com.azure.ai.contentsafety.ContentSafetyClient;\nimport com.azure.ai.contentsafety.ContentSafetyClientBuilder;\nimport com.azure.ai.contentsafety.BlocklistClient;\nimport com.azure.ai.contentsafety.BlocklistClientBuilder;\nimport com.azure.core.credential.KeyCredential;\n\nString endpoint = System.getenv(\"CONTENT_SAFETY_ENDPOINT\");\nString key = System.getenv(\"CONTENT_SAFETY_KEY\");\n\nContentSafetyClient contentSafetyClient = new ContentSafetyClientBuilder()\n    .credential(new KeyCredential(key))\n    .endpoint(endpoint)\n    .buildClient();\n\nBlocklistClient blocklistClient = new BlocklistClientBuilder()\n    .credential(new KeyCredential(key))\n    .endpoint(endpoint)\n    .buildClient();\n```\n\n### With DefaultAzureCredential\n\n```java\nimport com.azure.identity.DefaultAzureCredentialBuilder;\n\nContentSafetyClient client = new ContentSafetyClientBuilder()\n    .credential(new DefaultAzureCredentialBuilder().build())\n    .endpoint(endpoint)\n    .buildClient();\n```\n\n## Key Concepts\n\n### Harm Categories\n| Category | Description |\n|----------|-------------|\n| Hate | Discriminatory language based on identity groups |\n| Sexual | Sexual content, relationships, acts |\n| Violence | Physical harm, weapons, injury |\n| Self-harm | Self-injury, suicide-related content |\n\n### Severity Levels\n- Text: 0-7 scale (default outputs 0, 2, 4, 6)\n- Image: 0, 2, 4, 6 (trimmed scale)\n\n## Core Patterns\n\n### Analyze Text\n\n```java\nimport com.azure.ai.contentsafety.models.*;\n\nAnalyzeTextResult result = contentSafetyClient.analyzeText(\n    new AnalyzeTextOptions(\"This is text to analyze\"));\n\nfor (TextCategoriesAnalysis category : result.getCategoriesAnalysis()) {\n    System.out.printf(\"Category: %s, Severity: %d%n\",\n        category.getCategory(),\n        category.getSeverity());\n}\n```\n\n### Analyze Text with Options\n\n```java\nAnalyzeTextOptions options = new AnalyzeTextOptions(\"Text to analyze\")\n    .setCategories(Arrays.asList(\n        TextCategory.HATE,\n        TextCategory.VIOLENCE))\n    .setOutputType(AnalyzeTextOutputType.EIGHT_SEVERITY_LEVELS);\n\nAnalyzeTextResult result = contentSafetyClient.analyzeText(options);\n```\n\n### Analyze Text with Blocklist\n\n```java\nAnalyzeTextOptions options = new AnalyzeTextOptions(\"I h*te you and want to k*ll you\")\n    .setBlocklistNames(Arrays.asList(\"my-blocklist\"))\n    .setHaltOnBlocklistHit(true);\n\nAnalyzeTextResult result = contentSafetyClient.analyzeText(options);\n\nif (result.getBlocklistsMatch() != null) {\n    for (TextBlocklistMatch match : result.getBlocklistsMatch()) {\n        System.out.printf(\"Blocklist: %s, Item: %s, Text: %s%n\",\n            match.getBlocklistName(),\n            match.getBlocklistItemId(),\n            match.getBlocklistItemText());\n    }\n}\n```\n\n### Analyze Image\n\n```java\nimport com.azure.ai.contentsafety.models.*;\nimport com.azure.core.util.BinaryData;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\n// From file\nbyte[] imageBytes = Files.readAllBytes(Paths.get(\"image.png\"));\nContentSafetyImageData imageData = new ContentSafetyImageData()\n    .setContent(BinaryData.fromBytes(imageBytes));\n\nAnalyzeImageResult result = contentSafetyClient.analyzeImage(\n    new AnalyzeImageOptions(imageData));\n\nfor (ImageCategoriesAnalysis category : result.getCategoriesAnalysis()) {\n    System.out.printf(\"Category: %s, Severity: %d%n\",\n        category.getCategory(),\n        category.getSeverity());\n}\n```\n\n### Analyze Image from URL\n\n```java\nContentSafetyImageData imageData = new ContentSafetyImageData()\n    .setBlobUrl(\"https://example.com/image.jpg\");\n\nAnalyzeImageResult result = contentSafetyClient.analyzeImage(\n    new AnalyzeImageOptions(imageData));\n```\n\n## Blocklist Management\n\n### Create or Update Blocklist\n\n```java\nimport com.azure.core.http.rest.RequestOptions;\nimport com.azure.core.http.rest.Response;\nimport com.azure.core.util.BinaryData;\nimport java.util.Map;\n\nMap<String, String> description = Map.of(\"description\", \"Custom blocklist\");\nBinaryData resource = BinaryData.fromObject(description);\n\nResponse<BinaryData> response = blocklistClient.createOrUpdateTextBlocklistWithResponse(\n    \"my-blocklist\", resource, new RequestOptions());\n\nif (response.getStatusCode() == 201) {\n    System.out.println(\"Blocklist created\");\n} else if (response.getStatusCode() == 200) {\n    System.out.println(\"Blocklist updated\");\n}\n```\n\n### Add Block Items\n\n```java\nimport com.azure.ai.contentsafety.models.*;\nimport java.util.Arrays;\n\nList<TextBlocklistItem> items = Arrays.asList(\n    new TextBlocklistItem(\"badword1\").setDescription(\"Offensive term\"),\n    new TextBlocklistItem(\"badword2\").setDescription(\"Another term\")\n);\n\nAddOrUpdateTextBlocklistItemsResult result = blocklistClient.addOrUpdateBlocklistItems(\n    \"my-blocklist\",\n    new AddOrUpdateTextBlocklistItemsOptions(items));\n\nfor (TextBlocklistItem item : result.getBlocklistItems()) {\n    System.out.printf(\"Added: %s (ID: %s)%n\",\n        item.getText(),\n        item.getBlocklistItemId());\n}\n```\n\n### List Blocklists\n\n```java\nPagedIterable<TextBlocklist> blocklists = blocklistClient.listTextBlocklists();\n\nfor (TextBlocklist blocklist : blocklists) {\n    System.out.printf(\"Blocklist: %s, Description: %s%n\",\n        blocklist.getName(),\n        blocklist.getDescription());\n}\n```\n\n### Get Blocklist\n\n```java\nTextBlocklist blocklist = blocklistClient.getTextBlocklist(\"my-blocklist\");\nSystem.out.println(\"Name: \" + blocklist.getName());\n```\n\n### List Block Items\n\n```java\nPagedIterable<TextBlocklistItem> items = \n    blocklistClient.listTextBlocklistItems(\"my-blocklist\");\n\nfor (TextBlocklistItem item : items) {\n    System.out.printf(\"ID: %s, Text: %s%n\",\n        item.getBlocklistItemId(),\n        item.getText());\n}\n```\n\n### Remove Block Items\n\n```java\nList<String> itemIds = Arrays.asList(\"item-id-1\", \"item-id-2\");\n\nblocklistClient.removeBlocklistItems(\n    \"my-blocklist\",\n    new RemoveTextBlocklistItemsOptions(itemIds));\n```\n\n### Delete Blocklist\n\n```java\nblocklistClient.deleteTextBlocklist(\"my-blocklist\");\n```\n\n## Error Handling\n\n```java\nimport com.azure.core.exception.HttpResponseException;\n\ntry {\n    contentSafetyClient.analyzeText(new AnalyzeTextOptions(\"test\"));\n} catch (HttpResponseException e) {\n    System.out.println(\"Status: \" + e.getResponse().getStatusCode());\n    System.out.println(\"Error: \" + e.getMessage());\n    // Common codes: InvalidRequestBody, ResourceNotFound, TooManyRequests\n}\n```\n\n## Environment Variables\n\n```bash\nCONTENT_SAFETY_ENDPOINT=https://<resource>.cognitiveservices.azure.com/\nCONTENT_SAFETY_KEY=<your-api-key>\n```\n\n## Best Practices\n\n1. **Blocklist Delay**: Changes take ~5 minutes to take effect\n2. **Category Selection**: Only request needed categories to reduce latency\n3. **Severity Thresholds**: Typically block severity >= 4 for strict moderation\n4. **Batch Processing**: Process multiple items in parallel for throughput\n5. **Caching**: Cache blocklist results where appropriate\n\n## Trigger Phrases\n\n- \"content safety Java\"\n- \"content moderation Azure\"\n- \"analyze text safety\"\n- \"image moderation Java\"\n- \"blocklist management\"\n- \"hate speech detection\"\n- \"harmful content filter\"\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.","tags":["azure","contentsafety","java","antigravity","awesome","skills","sickn33","agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding"],"capabilities":["skill","source-sickn33","skill-azure-ai-contentsafety-java","topic-agent-skills","topic-agentic-skills","topic-ai-agent-skills","topic-ai-agents","topic-ai-coding","topic-ai-workflows","topic-antigravity","topic-antigravity-skills","topic-claude-code","topic-claude-code-skills","topic-codex-cli","topic-codex-skills"],"categories":["antigravity-awesome-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sickn33/antigravity-awesome-skills/azure-ai-contentsafety-java","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sickn33/antigravity-awesome-skills","source_repo":"https://github.com/sickn33/antigravity-awesome-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 34964 github stars · SKILL.md body (7,860 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-25T00:50:30.612Z","embedding":null,"createdAt":"2026-04-18T21:31:50.984Z","updatedAt":"2026-04-25T00:50:30.612Z","lastSeenAt":"2026-04-25T00:50:30.612Z","tsv":"'-7':151 '/image.jpg':322 '0':150,155,160 '1':484,540 '1.1.0':46 '2':156,161,488,550 '200':374 '201':367 '3':560 '4':157,162,566,570 '5':545,580 '6':158,163 'act':131 'action':621 'ad':415 'add':378 'addorupdatetextblocklistitemsopt':408 'addorupdatetextblocklistitemsresult':401 'ai':3,13,20,33,44 'analyz':168,182,195,206,219,267,310,595 'analyzeimageopt':296,327 'analyzeimageresult':292,323 'analyzetextopt':177,200,203,224,227,511 'analyzetextoutputtype.eight':212 'analyzetextresult':173,215,245 'anoth':399 'api':51 'applic':9,29,615 'appropri':586 'arrays.aslist':208,239,388,480 'ask':659 'azur':2,12,19,32,43,594 'azure-ai-contentsafeti':42 'azure-ai-contentsafety-java':1 'badword1':391 'badword2':397 'base':123 'bash':530 'batch':571 'best':538 'beta.1':47 'binarydata':352 'binarydata.frombytes':290 'binarydata.fromobject':354 'block':379,453,475,564 'blocklist':222,242,257,329,334,351,361,369,376,406,423,426,430,431,433,441,444,448,461,492,497,502,541,583,601 'blocklist.getdescription':439 'blocklist.getname':438,451 'blocklistcli':87,88 'blocklistclient.addorupdateblocklistitems':403 'blocklistclient.createorupdatetextblocklistwithresponse':358 'blocklistclient.deletetextblocklist':499 'blocklistclient.gettextblocklist':445 'blocklistclient.listtextblocklistitems':458 'blocklistclient.listtextblocklists':427 'blocklistclient.removeblocklistitems':489 'blocklistclientbuild':90 'boundari':667 'build':6,26,110 'buildclient':86,97,113 'byte':280 'cach':581,582 'catch':513 'categori':117,118,185,188,300,303,551,556 'category.getcategory':193,308 'category.getseverity':194,309 'chang':543 'clarif':661 'clear':634 'client':48,104 'code':524 'cognitiveservices.azure.com':534 'com.azure':41 'com.azure.ai.contentsafety.blocklistclient':59 'com.azure.ai.contentsafety.blocklistclientbuilder':61 'com.azure.ai.contentsafety.contentsafetyclient':55 'com.azure.ai.contentsafety.contentsafetyclientbuilder':57 'com.azure.ai.contentsafety.models':172,271,383 'com.azure.core.credential.keycredential':63 'com.azure.core.exception.httpresponseexception':507 'com.azure.core.http.rest.requestoptions':337 'com.azure.core.http.rest.response':339 'com.azure.core.util.binarydata':273,341 'com.azure.identity.defaultazurecredentialbuilder':102 'common':523 'concept':115 'content':7,14,21,27,34,67,73,129,146,531,535,589,592,607 'contentsafeti':4,45 'contentsafetycli':76,77,103 'contentsafetyclient.analyzeimage':294,325 'contentsafetyclient.analyzetext':175,217,247,509 'contentsafetyclientbuild':79,106 'contentsafetyimagedata':285,288,315,318 'core':166 'creat':331,370 'creation':49 'credenti':80,91,107 'criteria':670 'custom':350 'd':191,306 'default':153 'defaultazurecredenti':99 'defaultazurecredentialbuild':109 'delay':542 'delet':496 'describ':622,638 'descript':119,347,349,355,435 'detect':605 'discriminatori':121 'e':515 'e.getmessage':522 'e.getresponse':518 'effect':549 'els':371 'endpoint':65,69,84,85,95,96,111,112,533 'environ':528,650 'environment-specif':649 'error':503,521 'example.com':321 'example.com/image.jpg':320 'execut':617 'expert':655 'file':279 'files.readallbytes':282 'filter':608 'get':440 'getstatuscod':519 'group':126 'h':229 'handl':504 'harm':116,134,139,606 'hate':120,603 'httpresponseexcept':514 'id':417,467,483,487 'ident':125 'imag':159,268,311,598 'image.png':284 'imagebyt':281,291 'imagecategoriesanalysi':299 'imagedata':286,297,316,328 'import':54,56,58,60,62,101,171,270,272,274,276,336,338,340,342,382,384,506 'injuri':136,142 'input':664 'instal':39 'invalidrequestbodi':525 'item':259,380,387,409,412,454,457,464,465,476,482,486,575 'item-id':481,485 'item.getblocklistitemid':421,472 'item.gettext':420,473 'itemid':479,495 'java':5,18,25,38,53,100,170,199,223,269,314,335,381,424,442,455,477,498,505,591,600 'java.nio.file.files':275 'java.nio.file.paths':277 'java.util.arrays':385 'java.util.map':343 'k':235 'key':52,71,75,83,94,114,537 'keycredenti':82,93 'languag':122 'latenc':559 'level':148,214 'limit':626 'list':386,422,452,478 'll':236 'manag':330,602 'map':344 'map.of':348 'match':254,635 'match.getblocklistitemid':265 'match.getblocklistitemtext':266 'match.getblocklistname':264 'minut':546 'miss':672 'moder':8,28,569,593,599 'multipl':574 'my-blocklist':240,359,404,446,459,490,500 'n':192,263,307,419,437,471 'name':450 'need':555 'new':78,81,89,92,105,108,176,202,226,287,295,317,326,363,389,395,407,493,510 'null':251 'offens':393 'option':198,201,218,225,248 'output':154,644 'overview':625 'pagediter':425,456 'parallel':577 'paths.get':283 'pattern':167 'permiss':665 'phrase':588 'physic':133 'practic':539 'process':572,573 'reduc':558 'relat':145 'relationship':130 'remov':474 'removetextblocklistitemsopt':494 'request':554 'requestopt':364 'requir':663 'resourc':353,362 'resourcenotfound':526 'respons':356,357 'response.getstatuscode':366,373 'result':174,216,246,293,324,402,584 'result.getblocklistitems':413 'result.getblocklistsmatch':250,255 'result.getcategoriesanalysis':186,301 'review':656 'safeti':15,22,35,68,74,532,536,590,597,666 'scale':152,165 'scope':637 'sdk':16,23,36 'select':552 'self':138,141 'self-harm':137 'self-injuri':140 'setbloburl':319 'setblocklistnam':238 'setcategori':207 'setcont':289 'setdescript':392,398 'sethaltonblocklisthit':243 'setoutputtyp':211 'sever':147,190,213,305,561,565 'sexual':127,128 'skill':613,629 'skill-azure-ai-contentsafety-java' 'source-sickn33' 'specif':651 'speech':604 'status':517 'stop':657 'strict':568 'string':64,70,345,346 'substitut':647 'success':669 'suicid':144 'suicide-rel':143 'system.getenv':66,72 'system.out.printf':187,256,302,414,432,466 'system.out.println':368,375,449,516,520 'take':544,548 'task':633 'te':230 'term':394,400 'test':512,653 'text':149,169,180,196,204,220,261,469,596 'textblocklist':429,443 'textblocklistitem':390,396,411,463 'textblocklistmatch':253 'textcategoriesanalysi':184 'textcategory.hate':209 'textcategory.violence':210 'threshold':562 'throughput':579 'toomanyrequest':527 'topic-agent-skills' 'topic-agentic-skills' 'topic-ai-agent-skills' 'topic-ai-agents' 'topic-ai-coding' 'topic-ai-workflows' 'topic-antigravity' 'topic-antigravity-skills' 'topic-claude-code' 'topic-claude-code-skills' 'topic-codex-cli' 'topic-codex-skills' 'treat':642 'tri':508 'trigger':587 'trim':164 'true':244 'typic':563 'updat':333,377 'url':313 'use':10,30,611,627 'valid':652 'variabl':529 'violenc':132 'want':233 'weapon':135 'workflow':619 'xml':40","prices":[{"id":"65b931ee-518e-422d-b455-74f9a8dc6136","listingId":"a2d90456-7512-4b19-926e-f216b15bcff6","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sickn33","category":"antigravity-awesome-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T21:31:50.984Z"}],"sources":[{"listingId":"a2d90456-7512-4b19-926e-f216b15bcff6","source":"github","sourceId":"sickn33/antigravity-awesome-skills/azure-ai-contentsafety-java","sourceUrl":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-ai-contentsafety-java","isPrimary":false,"firstSeenAt":"2026-04-18T21:31:50.984Z","lastSeenAt":"2026-04-25T00:50:30.612Z"}],"details":{"listingId":"a2d90456-7512-4b19-926e-f216b15bcff6","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sickn33","slug":"azure-ai-contentsafety-java","github":{"repo":"sickn33/antigravity-awesome-skills","stars":34964,"topics":["agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity","antigravity-skills","claude-code","claude-code-skills","codex-cli","codex-skills","cursor","cursor-skills","developer-tools","gemini-cli","gemini-skills","kiro","mcp","skill-library"],"license":"mit","html_url":"https://github.com/sickn33/antigravity-awesome-skills","pushed_at":"2026-04-24T06:41:17Z","description":"Installable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.","skill_md_sha":"58a32e6ce170d5b06547938ad8b9bd186f1372d7","skill_md_path":"skills/azure-ai-contentsafety-java/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-ai-contentsafety-java"},"layout":"multi","source":"github","category":"antigravity-awesome-skills","frontmatter":{"name":"azure-ai-contentsafety-java","description":"Build content moderation applications using the Azure AI Content Safety SDK for Java."},"skills_sh_url":"https://skills.sh/sickn33/antigravity-awesome-skills/azure-ai-contentsafety-java"},"updatedAt":"2026-04-25T00:50:30.612Z"}}