azure-aigateway

bởi microsoft

Cấu hình Azure API Management như một AI Gateway cho các mô hình AI, công cụ MCP và agent. KHI NÀO: bộ nhớ đệm ngữ nghĩa, giới hạn token, an toàn nội dung, cân bằng tải, quản trị mô hình AI, giới hạn tốc độ MCP, phát hiện jailbreak, thêm backend Azure OpenAI, thêm mô hình AI Foundry, kiểm tra AI gateway, chính sách LLM, cấu hình backend AI, số liệu token, kiểm soát chi phí AI, chuyển đổi API sang MCP, nhập OpenAPI vào gateway.

npx skills add https://github.com/microsoft/skills --skill azure-aigateway

Azure AI Gateway

Configure Azure API Management (APIM) as an AI Gateway for governing AI models, MCP tools, and agents.

To deploy APIM, use the azure-prepare skill. See APIM deployment guide.

When to Use This Skill

CategoryTriggers
Model Governance"semantic caching", "token limits", "load balance AI", "track token usage"
Tool Governance"rate limit MCP", "protect my tools", "configure my tool", "convert API to MCP"
Agent Governance"content safety", "jailbreak detection", "filter harmful content"
Configuration"add Azure OpenAI backend", "configure my model", "add AI Foundry model"
Testing"test AI gateway", "call OpenAI through gateway"

Quick Reference

PolicyPurposeDetails
azure-openai-token-limitCost controlModel Policies
azure-openai-semantic-cache-lookup/store60-80% cost savingsModel Policies
azure-openai-emit-token-metricObservabilityModel Policies
llm-content-safetySafety & complianceAgent Policies
rate-limit-by-keyMCP/tool protectionTool Policies

Get Gateway Details

# Get gateway URL
az apim show --name <apim-name> --resource-group <rg> --query "gatewayUrl" -o tsv

# List backends (AI models)
az apim backend list --service-name <apim-name> --resource-group <rg> \
  --query "[].{id:name, url:url}" -o table

# Get subscription key
az apim subscription keys list \
  --service-name <apim-name> --resource-group <rg> --subscription-id <sub-id>

Test AI Endpoint

GATEWAY_URL=$(az apim show --name <apim-name> --resource-group <rg> --query "gatewayUrl" -o tsv)

curl -X POST "${GATEWAY_URL}/openai/deployments/<deployment>/chat/completions?api-version=2024-02-01" \
  -H "Content-Type: application/json" \
  -H "Ocp-Apim-Subscription-Key: <key>" \
  -d '{"messages": [{"role": "user", "content": "Hello"}], "max_tokens": 100}'

Common Tasks

Add AI Backend

See references/patterns.md for full steps.

# Discover AI resources
az cognitiveservices account list --query "[?kind=='OpenAI']" -o table

# Create backend
az apim backend create --service-name <apim> --resource-group <rg> \
  --backend-id openai-backend --protocol http --url "https://<aoai>.openai.azure.com/openai"

# Grant access (managed identity)
az role assignment create --assignee <apim-principal-id> \
  --role "Cognitive Services User" --scope <aoai-resource-id>

Apply AI Governance Policy

Recommended policy order in <inbound>:

  1. Authentication - Managed identity to backend
  2. Semantic Cache Lookup - Check cache before calling AI
  3. Token Limits - Cost control
  4. Content Safety - Filter harmful content
  5. Backend Selection - Load balancing
  6. Metrics - Token usage tracking

See references/policies.md for complete example.


Troubleshooting

IssueSolution
Token limit 429Increase tokens-per-minute or add load balancing
No cache hitsLower score-threshold to 0.7
Content false positivesIncrease category thresholds (5-6)
Backend auth 401Grant APIM "Cognitive Services User" role

See references/troubleshooting.md for details.


References

SDK Quick References

Thêm skills từ microsoft

a365-code-validator
microsoft
Xác thực và tùy chọn sửa mã quan sát của Agent 365 để tác nhân thực sự phát ra dữ liệu đo từ xa MAC Activity. Sử dụng khi dữ liệu đo từ xa của tác nhân Agent 365 không…
a365-setup
microsoft
Điểm vào cho việc đăng ký và thiết lập CLI tổng quát của Agent 365 (A365) — sử dụng kỹ năng này bất cứ khi nào người dùng muốn "thiết lập A365", "đăng ký agent", "tạo…
aca-sandboxes
microsoft
Use when the user wants to create, manage, or operate Azure Container Apps sandboxes — hardware-isolated microVMs driven by the `aca` CLI. USE FOR: create…
accessibility
microsoft
Kỹ năng trợ năng chính cho VS Code. BẮT BUỘC cho công việc tính năng mới và đóng góp, và cũng áp dụng cho các bản cập nhật giao diện hiện có. Bao gồm trợ giúp trợ năng…
accessibility
microsoft
Điểm truy cập kỹ năng trợ năng tổng hợp cho WCAG 2.2, ARIA Authoring Practices, trợ năng nhận thức, Section 508, EN 301 549 và Trợ năng…
accessibility-aria-expert
microsoft
Phát hiện và sửa các vấn đề về khả năng tiếp cận trong giao diện web React/Fluent UI. Sử dụng khi xem xét mã để đảm bảo tương thích với trình đọc màn hình, sửa nhãn ARIA, đảm bảo…
action-item-extractor
microsoft
Trích xuất các mục hành động kèm chủ sở hữu, thời hạn và mức độ ưu tiên từ nội dung cuộc họp
activate-site
microsoft
Kiểm tra plugin: Chạy node "${CLAUDE_PLUGIN_ROOT}/scripts/check-version.js" — nếu nó xuất ra thông báo, hãy hiển thị cho người dùng trước khi tiếp tục.