LLM Skills
~/catalog/cloud & sdks//SKILL
Cloud & SDKsGitHub source

Azure ai content safety (python)

/SKILL

SDK Azure AI Content Safety for Python. Detects harmful content in text and images using multi-class classification.

sickn33sickn33
45.0k
May 22, 2026
MIT License
// skill content

--- name: azure-ai-contentsafety-py description: Azure AI Content Safety SDK for Python. Use it to detect harmful content in text and images using multi-severity classification. risk: unknown source: community date_added: '2026-02-27' --- # Azure AI Content Safety SDK for Python Detect harmful user-generated and AI-generated content in applications. ## Installation ``bash pip install azure-ai-contentsafety ` ## Environment Variables `bash CONTENT_SAFETY_ENDPOINT=https://<resource>.cognitiveservices.azure.com CONTENT_SAFETY_KEY=<your-api-key> ` ## Authentication ### API Key `python from azure.ai.contentsafety import ContentSafetyClient from azure.core.credentials import AzureKeyCredential import os client = ContentSafetyClient( endpoint=os.environ["CONTENT_SAFETY_ENDPOINT"], credential=AzureKeyCredential(os.environ["CONTENT_SAFETY_KEY"]) ) ` ### Entra ID `python from azure.ai.contentsafety import ContentSafetyClient from azure.identity import DefaultAzureCredential client = ContentSafetyClient( endpoint=os.environ["CONTENT_SAFETY_ENDPOINT"], credential=DefaultAzureCredential() ) ` ## Analyze Text `python from azure.ai.contentsafety import ContentSafetyClient from azure.ai.contentsafety.models import AnalyzeTextOptions, TextCategory from azure.core.credentials import AzureKeyCredential client = ContentSafetyClient(endpoint, AzureKeyCredential(key)) request = AnalyzeTextOptions(text="Your text content to analyze") response = client.analyze_text(request) # Check each category for category in [TextCategory.HATE, TextCategory.SELF_HARM, TextCategory.SEXUAL, TextCategory.VIOLENCE]: result = next((r for r in response.categories_analysis if r.category == category), None) if result: print(f"{category}: severity {result.severity}") ` ## Analyze Image `python from azure.ai.contentsafety import ContentSafetyClient from azure.ai.contentsafety.models import AnalyzeImageOptions, ImageData from azure.core.credentials import AzureKeyCredential import base64 client = ContentSafetyClient(endpoint, AzureKeyCredential(key)) # From file with open("image.jpg", "rb") as f: image_data = base64.b64encode(f.read()).decode("utf-8") request = AnalyzeImageOptions( image=ImageData(content=image_data) ) response = client.analyze_image(request) for result in response.categories_analysis: print(f"{result.category}: severity {result.severity}") ` ### Image from URL `python from azure.ai.contentsafety.models import AnalyzeImageOptions, ImageData request = AnalyzeImageOptions( image=ImageData(blob_url="https://example.com/image.jpg") ) response = client.analyze_image(request) ` ## Text Blocklist Management ### Create Blocklist `python from azure.ai.contentsafety import BlocklistClient from azure.ai.contentsafety.models import TextBlocklist from azure.core.credentials import AzureKeyCredential blocklist_client = BlocklistClient(endpoint, AzureKeyCredential(key)) blocklist = TextBlocklist( blocklist_name="my-blocklist", description="Custom terms to block" ) result = blocklist_client.create_or_update_text_blocklist( blocklist_name="my-blocklist", options=blocklist ) ` ### Add Block Items `python from azure.ai.contentsafety.models import AddOrUpdateTextBlocklistItemsOptions, TextBlocklistItem items = AddOrUpdateTextBlocklistItemsOptions( blocklist_items=[ TextBlocklistItem(text="blocked-term-1"), TextBlocklistItem(text="blocked-term-2") ] ) result = blocklist_client.add_or_update_blocklist_items( blocklist_name="my-blocklist", options=items ) ` ### Analyze with Blocklist `python from azure.ai.contentsafety.models import AnalyzeTextOptions request = AnalyzeTextOptions( text="Text containing blocked-term-1", blocklist_names=["my-blocklist"], halt_on_blocklist_hit=True ) response = client.analyze_text(request) if response.blocklists_match: for match in response.blocklists_match: print(f"Blocked: {match.blocklist_item_text}") `` ## Severity Levels Text analysis returns 4 severity levels (0, 2, 4, 6) by default. For 8 levels (0:7):

// original public source
sickn33/antigravity-awesome-skills
/skills/azure-ai-contentsafety-py/SKILL.md
License: MIT License
Independent project, not affiliated with Anthropic. This skill remains the property of its original author.
// install this skill
Paste this command in your terminal at the root of your project:
mkdir -p .claude/commands && curl -o ".claude/commands/SKILL.md" "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/skills/azure-ai-contentsafety-py/SKILL.md"
Then in Claude Code, type /SKILL to activate it.
open_in_newOpen original source
// save
Save available after sign in.
loginSign in to save
// information
Creatorsickn33
Stars 45.0k
CategoryCloud & SDKs
LicenseMIT License
UpdatedMay 22, 2026
Format.md
AccessFree
// similar

Skills Cloud & SDKs

View allarrow_forward