skillfed

azure-ai-contentsafety

Microsoft Azure AI Content Safety Client Library for Python

azure-ai-contentsafety v1.0.0 1.1M downloads/30d#4,437 on PyPI5,588
Permissive license MIT License Active released

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-contentsafety

uv

uv add azure-ai-contentsafety

poetry

poetry add azure-ai-contentsafety

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

content moderation apitext and image safety detectionharmful content classificationazure content safetycontent blocklist managementhate violence sexual content detectionai content moderation
content-moderationazure-sdkharm-detection

More Artificial Intelligence packages

litellm

LiteLLM provides a unified Python interface to…

permissive · top 100 on PyPI

huggingface-hub

Client library and CLI tool for downloading,…

permissive · top 100 on PyPI

langchain

LangChain provides a framework for building…

permissive · top 1,000 on PyPI

hf-xet

hf-xet provides chunk-based deduplication and…

permissive · top 1,000 on PyPI

tokenizers

Tokenizers converts raw text into token…

permissive · top 1,000 on PyPI

transformers

Transformers provides a unified framework for…

permissive · top 1,000 on PyPI

azure-ai-textanalytics

Provides Python bindings to Azure's cloud-based…

permissive · top 15,000 on PyPI

azure-ai-documentintelligence

Python client for Azure AI Document…

permissive · top 5,000 on PyPI

azure-ai-vision-imageanalysis

Calls Azure's Computer Vision service to…

permissive · top 15,000 on PyPI

azure-ai-formrecognizer

Extracts text, structure, and key-value pairs…

permissive · top 5,000 on PyPI

azure-ai-language-questionanswering

Python client library for Azure's Question…

permissive · top 15,000 on PyPI

azure-ai-evaluation

Evaluates generative AI application outputs…

permissive · top 15,000 on PyPI

azure-ai-inference

Unified client library for chat completions,…

permissive · top 5,000 on PyPI

azure-ai-translation-text

Provides a Python client for Azure's neural…

unclear · top 15,000 on PyPI

azure-ai-language-conversations

A Python client library for Azure…

permissive · top 15,000 on PyPI

detoxify

Detoxify classifies text comments for toxic…

permissive · top 15,000 on PyPI

Further reading