azure-ai-contentunderstanding-py – skill Viết lách & Nội dung cho agent AI
SDK Azure AI Content Understanding cho Python. Dùng để trích xuất nội dung đa phương thức từ tài liệu, hình ảnh, âm thanh và video.
Cài skill azure-ai-contentunderstanding-py bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-ai-contentunderstanding-py-08c4b.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /azure-ai-contentunderstanding-py – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-ai-contentunderstanding-py-08c4b.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $azure-ai-contentunderstanding-py – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-ai-contentunderstanding-py-08c4b.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /azure-ai-contentunderstanding-py – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-ai-contentunderstanding-py-08c4b.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /azure-ai-contentunderstanding-py – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Azure AI Content Understanding SDK for Python
Multimodal AI service that extracts semantic content from documents, video, audio, and image files for RAG and automated workflows.
Installation
pip install azure-ai-contentunderstandingEnvironment Variables
CONTENTUNDERSTANDING_ENDPOINT=https://<resource>.cognitiveservices.azure.com/Authentication
import os
from azure.ai.contentunderstanding import ContentUnderstandingClient
from azure.identity import DefaultAzureCredential
endpoint = os.environ["CONTENTUNDERSTANDING_ENDPOINT"]
credential = DefaultAzureCredential()
client = ContentUnderstandingClient(endpoint=endpoint, credential=credential)Core Workflow
Content Understanding operations are asynchronous long-running operations:
1. Begin Analysis — Start the analysis operation with begin_analyze() (returns a poller)
2. Poll for Results — Poll until analysis completes (SDK handles this with .result())
3. Process Results — Extract structured results from AnalyzeResult.contents
Prebuilt Analyzers
| Analyzer | Content Type | Purpose |
|----------|--------------|---------|
| prebuilt-documentSearch | Documents | Extract markdown for RAG applications |
| prebuilt-imageSearch | Images | Extract content from images |
| prebuilt-audioSearch | Audio | Transcribe audio with timing |
| prebuilt-videoSearch | Video | Extract frames, transcripts, summaries |
| prebuilt-invoice | Documents | Extract invoice fields |
Analyze Document
import os
from azure.ai.contentunderstanding import ContentUnderstandingClient
from azure.ai.contentunderstanding.models import AnalyzeInput
from azure.identity import DefaultAzureCredential
endpoint = os.environ["CONTENTUNDERSTANDING_ENDPOINT"]
client = ContentUnderstandingClient(
endpoint=endpoint,
credential=DefaultAzureCredential()
)
# Analyze document from URL
poller = client.begin_analyze(
analyzer_id="prebuilt-documentSearch",
inputs=[AnalyzeInput(url="https://example.com/document.pdf")]
)
result = poller.result()
# Access markdown content (contents is a list)
content = result.contents[0]
print(content.markdown)Access Document Content Details
from azure.ai.contentunderstanding.models import MediaContentKind, DocumentContent
content = result.contents[0]
if content.kind == MediaContentKind.DOCUMENT:
document_content: DocumentContent = content # type: ignore
print(document_content.start_page_number)Analyze Image
from azure.ai.contentunderstanding.models import AnalyzeInput
poller = client.begin_analyze(
analyzer_id="prebuilt-imageSearch",
inputs=[AnalyzeInput(url="https://example.com/image.jpg")]
)
result = poller.result()
content = result.contents[0]
print(content.markdown)Analyze Video
from azure.ai.contentunderstanding.models import AnalyzeInput
poller = client.begin_analyze(
analyzer_id="prebuilt-videoSearch",
inputs=[AnalyzeInput(url="https://example.com/video.mp4")]
)
result = poller.result()
# Access video content (AudioVisualContent)
content = result.contents[0]
# Get transcript phrases with timing
for phrase in content.transcript_phrases:
print(f"[{phrase.start_time} - {phrase.end_time}]: {phrase.text}")
# Get key frames (for video)
for frame in content.key_frames:
print(f"Frame at {frame.time}: {frame.description}")Analyze Audio
from azure.ai.contentunderstanding.models import AnalyzeInput
poller = client.begin_analyze(
analyzer_id="prebuilt-audioSearch",
inputs=[AnalyzeInput(url="https://example.com/audio.mp3")]
)
result = poller.result()
# Access audio transcript
content = result.contents[0]
for phrase in content.transcript_phrases:
print(f"[{phrase.start_time}] {phrase.text}")Custom Analyzers
Create custom analyzers with field schemas for specialized extraction:
# Create custom analyzer
analyzer = client.create_analyzer(
analyzer_id="my-invoice-analyzer",
analyzer={
"description": "Custom invoice analyzer",
"base_analyzer_id": "prebuilt-documentSearch",
"field_schema": {
"fields": {
"vendor_name": {"type": "string"},
"invoice_total": {"type": "number"},
"line_items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"description": {"type": "string"},
"amount": {"type": "number"}
}
}
}
}
}
}
)
# Use custom analyzer
from azure.ai.contentunderstanding.models import AnalyzeInput
poller = client.begin_analyze(
analyzer_id="my-invoice-analyzer",
inputs=[AnalyzeInput(url="https://example.com/invoice.pdf")]
)
result = poller.result()
# Access extracted fields
for content in result.contents or []:
fields = content.fields or {}
print(fields.get("vendor_name"))
print(fields.get("invoice_total"))Analyzer Management
# List all analyzers
analyzers = client.list_analyzers()
for analyzer in analyzers:
print(f"{analyzer.analyzer_id}: {analyzer.description}")
# Get specific analyzer
analyzer = client.get_analyzer("prebuilt-documentSearch")
# Delete custom analyzer
client.delete_analyzer("my-custom-analyzer")Async Client
import asyncio
import os
from azure.ai.contentunderstanding.aio import ContentUnderstandingClient
from azure.ai.contentunderstanding.models import AnalyzeInput
from azure.identity.aio import DefaultAzureCredential
async def analyze_document():
endpoint = os.environ["CONTENTUNDERSTANDING_ENDPOINT"]
credential = DefaultAzureCredential()
async with ContentUnderstandingClient(
endpoint=endpoint,
credential=credential
) as client:
poller = await client.begin_analyze(
analyzer_id="prebuilt-documentSearch",
inputs=[AnalyzeInput(url="https://example.com/doc.pdf")]
)
result = await poller.result()
content = result.contents[0]
return content.markdown
asyncio.run(analyze_document())Content Types
| Class | For | Provides |
|-------|-----|----------|
| DocumentContent | PDF, images, Office docs | Pages, tables, figures, paragraphs |
| AudioVisualContent | Audio, video files | Transcript phrases, timing, key frames |
Both derive from MediaContent which provides basic info and markdown representation.
Model Imports
from azure.ai.contentunderstanding.models import (
AnalyzeInput,
AnalyzeResult,
MediaContentKind,
DocumentContent,
AudioVisualContent,
)Client Types
| Client | Purpose |
|--------|---------|
| ContentUnderstandingClient | Sync client for all operations |
| ContentUnderstandingClient (aio) | Async client for all operations |
Best Practices
1. Use begin_analyze with AnalyzeInput — this is the correct method signature
2. Access results via result.contents[0] — results are returned as a list
3. Use prebuilt analyzers for common scenarios (document/image/audio/video search)
4. Create custom analyzers only for domain-specific field extraction
5. Use async client for high-throughput scenarios with azure.identity.aio credentials
6. Handle long-running operations — video/audio analysis can take minutes
7. Use URL sources when possible to avoid upload overhead
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
SDK/service versions differ: verify analyzer schemas and result fields against the pinned package; guard empty contents before indexing and missing extracted fields before use. These are fragments, not a full analyzer lifecycle. Close async clients and credentials with context managers, bound polling and report failures. Documents/audio/video leave the local environment; authorize sensitive transfer, redact extracted fields and validate outputs before financial/legal decisions. See [official SDK guide](https://learn.microsoft.com/en-us/python/api/overview/azure/ai-contentunderstanding-readme?view=azure-python-preview).
Skill liên quan
- azure-ai-translation-text-py – SDK Azure AI Text Translation để dịch văn bản thời gian thực, phiên âm…
- azure-ai-translation-ts – Dịch văn bản và tài liệu bằng client kiểu REST.
- content-creator – Skill chuyển hướng đã lỗi thời, định tuyến các yêu cầu 'content creator' cũ đến chuyên…
- content-humanizer – Làm cho nội dung do AI tạo ra nghe thật sự giống người — không chỉ được chỉnh sửa gọn…
- content-production – Quy trình sản xuất nội dung đầy đủ — đi từ trang trắng đến bài viết sẵn sàng xuất bản…
- content-strategy – Khi người dùng muốn lập chiến lược nội dung, quyết định nên tạo nội dung gì hoặc chọn…
- lora-qlora-recipes – Cấu hình tinh chỉnh có giám sát LoRA và QLoRA với các siêu tham số thực hành tốt nhất…
- contract-and-proposal-writer – Soạn tài liệu kinh doanh chuyên nghiệp, phù hợp theo khu vực pháp lý: hợp đồng…