帮助你将 Azure API 管理配置为 AI 网关,统一治理模型、工具与代理访问。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "azure-aigateway" 技能: 1. 下载 https://raw.githubusercontent.com/microsoft/GitHub-Copilot-for-Azure/main/plugin/skills/azure-aigateway/SKILL.md 2. 保存为 ~/.claude/skills/azure-aigateway/SKILL.md 3. 装好后重载技能,告诉我可以用了
请指导我把 Azure API Management 配置为 AI Gateway,用于 Azure OpenAI。需要包含语义缓存、令牌限制、内容安全、负载均衡和成本控制策略,并给出实施步骤。
一套分步骤配置方案,包含关键策略、网关设置要点和落地建议。
我有一个现有 API 的 OpenAPI 规范,请说明如何把它导入 Azure AI Gateway,并转换为可供代理调用的 MCP 工具,同时补充速率限制与安全治理配置。
导入与转换流程说明,包含 MCP 化步骤、策略示例和安全控制建议。
请帮我设计 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.
| Category | Triggers |
|---|---|
| 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" |
| Policy | Purpose | Details |
|---|---|---|
azure-openai-token-limit | Cost control | Model Policies |
azure-openai-semantic-cache-lookup/store | 60-80% cost savings | Model Policies |
azure-openai-emit-token-metric | Observability | Model Policies |
llm-content-safety | Safety & compliance | Agent Policies |
rate-limit-by-key | MCP/tool protection | Tool Policies |
# 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>
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}'
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>
Recommended policy order in <inbound>:
See references/policies.md for complete example.
| Issue | Solution |
|---|---|
| Token limit 429 | Increase tokens-per-minute or add load balancing |
| No cache hits | Lower score-threshold to 0.7 |
| Content false positives | Increase category thresholds (5-6) |
| Backend auth 401 | Grant APIM "Cognitive Services User" role |
See references/troubleshooting.md for details.
…
分析并精简 Markdown 内容,降低 token 消耗并提升 AI 处理效率。
通过 Azure OpenAI 生成与编辑图片,便于在工作流中调用视觉创作能力。