azure-ai-contentsafety
Microsoft Azure AI Content Safety Client Library for Python
What it is and what it does
This package is a Python client for Azure AI Content Safety, a cloud-hosted service that classifies text and images for harmful content. It provides two main clients—ContentSafetyClient for analyzing content and BlocklistClient for managing custom term blocklists—and wraps REST calls to Azure's moderation APIs. The service recognizes four harm categories (hate, sexual, violence, self-harm) and returns severity ratings on a 0–7 scale; text supports full granularity while images return mapped levels (0, 2, 4, 6).
You authenticate using either an API key or Microsoft Entra ID credentials, then call analyze methods to scan text or image URLs. The package handles request serialization and response parsing, abstracting away HTTP details. It's designed for applications that need to filter user-generated or AI-generated content at scale—e.g., moderation workflows, safety compliance, or content filtering in multi-tenant platforms. The blocklist APIs let you supplement the default classifiers with domain-specific terms, useful when the built-in categories don't capture your use case.
Use it for:
- Moderate user-generated comments or posts in social platforms or forums before publishing.
- Screen AI-generated text or images for harmful output in chatbot or generative AI applications.
- Build compliance workflows that flag content for manual review based on severity thresholds.
- Create custom blocklists for industry-specific harmful terms (e.g., medical misinformation, financial scams).
- Analyze bulk content archives to identify and categorize harmful material across historical data.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Detects harmful content in text and images by classifying them across categories like sexual content, violence, hate, and self-harm with severity ratings, and manages custom blocklists for domain-specific screening.
Yes, if you need content moderation and are already using Azure. The package is stable (1.0.0), actively maintained, has no known vulnerabilities, and integrates cleanly with Azure authentication patterns. However, you must have an Azure subscription and Content Safety resource; the client library alone does not provide moderation—it calls a cloud service. Evaluate Azure's pricing and API quotas for your use case before committing.
Install
azure-ai-contentsafety on PyPI
pip
pip install azure-ai-contentsafetyuv
uv add azure-ai-contentsafetypoetry
poetry add azure-ai-contentsafetyInstalling azure-ai-contentsafety
Before you install
Low install friction with a pure-Python wheel distribution. Actively maintained as of 2026-08-14 with no known vulnerabilities. Depends on three stable, widely-used packages: azure-core, isodate, and typing-extensions.
License in practice
MIT License permits unrestricted use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install azure-ai-contentsafety
from azure.core.credentials import AzureKeyCredential
from azure.ai.contentsafety import ContentSafetyClient
endpoint = "https://<subdomain>.cognitiveservices.azure.com/"
credential = AzureKeyCredential("<api_key>")
client = ContentSafetyClient(endpoint, credential)
result = client.analyze_text(text="sample text to analyze")
Requires an active Azure AI Content Safety resource and API key or Entra ID credentials; the service is cloud-hosted and cannot be used offline.
Verify before relying
- Whether the service requires an active Azure subscription and incurs per-request costs beyond the client library itself.
- Performance characteristics and latency expectations for text and image analysis at scale.
- Whether custom blocklists persist across sessions or require reinitialization.
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — isodate, azure-core, typing-extensions |
| Maintenance | actively maintained — 976 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,053,001/month — #4,437 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: azure_ai_contentsafety-1.0.0-py3-none-any.whl
Keywords: azure, azure sdk
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
azure-ai-textanalyticsProvides Python bindings to Azure's cloud-based…
permissive · top 15,000 on PyPI
azure-ai-documentintelligencePython client for Azure AI Document…
permissive · top 5,000 on PyPI
azure-ai-vision-imageanalysisCalls Azure's Computer Vision service to…
permissive · top 15,000 on PyPI
azure-ai-formrecognizerExtracts text, structure, and key-value pairs…
permissive · top 5,000 on PyPI
azure-ai-language-questionansweringPython client library for Azure's Question…
permissive · top 15,000 on PyPI
azure-ai-evaluationEvaluates generative AI application outputs…
permissive · top 15,000 on PyPI
azure-ai-inferenceUnified client library for chat completions,…
permissive · top 5,000 on PyPI
azure-ai-translation-textProvides a Python client for Azure's neural…
unclear · top 15,000 on PyPI
azure-ai-language-conversationsA Python client library for Azure…
permissive · top 15,000 on PyPI
detoxifyDetoxify classifies text comments for toxic…
permissive · top 15,000 on PyPI