Azure aigateway

by microsoft· MIT license· ★ 1,599 on GitHub

Configure Azure API Management as an AI Gateway for AI models, MCP tools, and agents. WHEN: semantic caching, token limit, content safety, load balancing, AI model governance, MCP rate limiting, jailbreak detection, add Azure OpenAI…

SkillFreeInfrastructure & ops

Overview

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

Install

Claude Codenpx skills add microsoft/azure-skills --skill azure-aigateway -g -a claude-code
Claude Code (degit)npx degit microsoft/azure-skills/skills/azure-aigateway#main ~/.claude/skills/azure-aigateway
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md; everything else is plain files.
Any agent via Agent Alley MCPConnect once, then ask: “use azure-aigateway”.

Files included

  • SKILL.md4.9 KB
Read SKILL.md here
microsoft/main1 file shown
SKILL.md
Show the full text130 lines

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

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"

Quick Reference

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

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.


References

SDK Quick References

1---
2name: azure-aigateway
3description: "Configure Azure API Management as an AI Gateway for AI models, MCP tools, and agents. WHEN: semantic caching, token limit, content safety, load balancing, AI model governance, MCP rate limiting, jailbreak detection, add Azure OpenAI backend, add AI Foundry model, test AI gateway, LLM policies, configure AI backend, token metrics, AI cost control, convert API to MCP, import OpenAPI to gateway."
4license: MIT
5metadata:
6 author: Microsoft
7 version: "3.2.1"
8compatibility: Requires Azure CLI (az) for configuration and testing
9---
10 
11# Azure AI Gateway
12 
13Configure Azure API Management (APIM) as an AI Gateway for governing AI models, MCP tools, and agents.
14 
15> **To deploy APIM**, use the **azure-prepare** skill. See [APIM deployment guide](https://learn.microsoft.com/azure/api-management/get-started-create-service-instance).
16 
17## When to Use This Skill
18 
19| Category | Triggers |
20|----------|----------|
21| **Model Governance** | "semantic caching", "token limits", "load balance AI", "track token usage" |
22| **Tool Governance** | "rate limit MCP", "protect my tools", "configure my tool", "convert API to MCP" |
23| **Agent Governance** | "content safety", "jailbreak detection", "filter harmful content" |
24| **Configuration** | "add Azure OpenAI backend", "configure my model", "add AI Foundry model" |
25| **Testing** | "test AI gateway", "call OpenAI through gateway" |
26 
27---
28 
29## Quick Reference
30 
31| Policy | Purpose | Details |
32|--------|---------|---------|
33| `azure-openai-token-limit` | Cost control | [Model Policies](references/policies.md#token-rate-limiting) |
34| `azure-openai-semantic-cache-lookup/store` | 60-80% cost savings | [Model Policies](references/policies.md#semantic-caching) |
35| `azure-openai-emit-token-metric` | Observability | [Model Policies](references/policies.md#token-metrics) |
36| `llm-content-safety` | Safety & compliance | [Agent Policies](references/policies.md#content-safety) |
37| `rate-limit-by-key` | MCP/tool protection | [Tool Policies](references/policies.md#request-rate-limiting) |
38 
39---
40 
41## Get Gateway Details
42 
43```bash
44# Get gateway URL
45az apim show --name <apim-name> --resource-group <rg> --query "gatewayUrl" -o tsv
46 
47# List backends (AI models)
48az apim backend list --service-name <apim-name> --resource-group <rg> \
49 --query "[].{id:name, url:url}" -o table
50 
51# Get subscription key
52az apim subscription keys list \
53 --service-name <apim-name> --resource-group <rg> --subscription-id <sub-id>
54```
55 
56---
57 
58## Test AI Endpoint
59 
60```bash
61GATEWAY_URL=$(az apim show --name <apim-name> --resource-group <rg> --query "gatewayUrl" -o tsv)
62 
63curl -X POST "${GATEWAY_URL}/openai/deployments/<deployment>/chat/completions?api-version=2024-02-01" \
64 -H "Content-Type: application/json" \
65 -H "Ocp-Apim-Subscription-Key: <key>" \
66 -d '{"messages": [{"role": "user", "content": "Hello"}], "max_tokens": 100}'
67```
68 
69---
70 
71## Common Tasks
72 
73### Add AI Backend
74 
75See [references/patterns.md](references/patterns.md#pattern-1-add-ai-model-backend) for full steps.
76 
77```bash
78# Discover AI resources
79az cognitiveservices account list --query "[?kind=='OpenAI']" -o table
80 
81# Create backend
82az apim backend create --service-name <apim> --resource-group <rg> \
83 --backend-id openai-backend --protocol http --url "https://<aoai>.openai.azure.com/openai"
84 
85# Grant access (managed identity)
86az role assignment create --assignee <apim-principal-id> \
87 --role "Cognitive Services User" --scope <aoai-resource-id>
88```
89 
90### Apply AI Governance Policy
91 
92Recommended policy order in `<inbound>`:
93 
941. **Authentication** - Managed identity to backend
952. **Semantic Cache Lookup** - Check cache before calling AI
963. **Token Limits** - Cost control
974. **Content Safety** - Filter harmful content
985. **Backend Selection** - Load balancing
996. **Metrics** - Token usage tracking
100 
101See [references/policies.md](references/policies.md#combining-policies) for complete example.
102 
103---
104 
105## Troubleshooting
106 
107| Issue | Solution |
108|-------|----------|
109| Token limit 429 | Increase `tokens-per-minute` or add load balancing |
110| No cache hits | Lower `score-threshold` to 0.7 |
111| Content false positives | Increase category thresholds (5-6) |
112| Backend auth 401 | Grant APIM "Cognitive Services User" role |
113 
114See [references/troubleshooting.md](references/troubleshooting.md) for details.
115 
116---
117 
118## References
119 
120- [**Detailed Policies**](references/policies.md) - Full policy examples
121- [**Configuration Patterns**](references/patterns.md) - Step-by-step patterns
122- [**Troubleshooting**](references/troubleshooting.md) - Common issues
123- [AI-Gateway Samples](https://github.com/Azure-Samples/AI-Gateway)
124- [GenAI Gateway Docs](https://learn.microsoft.com/azure/api-management/genai-gateway-capabilities)
125 
126## SDK Quick References
127 
128- **Content Safety**: [Python](references/sdk/azure-ai-contentsafety-py.md) | [TypeScript](references/sdk/azure-ai-contentsafety-ts.md)
129- **API Management**: [Python](references/sdk/azure-mgmt-apimanagement-py.md) | [.NET](references/sdk/azure-mgmt-apimanagement-dotnet.md)
130 
View all files on GitHub →

Similar skills

See all →
Azure app onboardEnd-to-end orchestrator: from a business idea, app idea, or existing app to running Azure deployment with cost estimates and pre-deploy approval. Analyzes your app, auto-detects the right Azure services, scaffolds infrastructure code, and deploys — tailored to your app, not a template. Handles moving existing apps to Azure without rewriting or with minimal changes. WHEN: bring your app to Azure, plan my app, cost to run, is my code ready to deploy, deploy my app to the cloud, deploy all my services, what Azure services do I need, plan my Azure deployment, deploy my new app to Azure, one-click deploy, I have an app and want it on Azure, migrate my app to Azure, help me get started, build an app, no code yet, starter project. DO NOT USE FOR: use azd for deployment(use azure-deploy), optimizing existing costs (use cost-optimization), code readiness checks only (use azure-app-onboard-prereq).by microsoft · ★ 3.1kAzure App Onboard Prereq — Repository EvaluationAssess whether source code is ready to deploy to Azure — the check BEFORE infrastructure work. Evaluates build health, app completeness, dependencies and local services, stack compatibility, and deployment feasibility. Answers questions about what your app needs before it can be deployed — frameworks, dependencies, and configuration. Checks whether dependencies are compatible and identifies deployment blockers and unsupported frameworks. WHEN: "evaluate my repo", "is my app ready to deploy", "what does my app need to deploy", "what do I need before deploying", "does my app need", "can I ship this to Azure", "scan my repo for issues", "is this app deployable", "check if my app is ready for Azure", "do I need a Dockerfile", "what's blocking my deployment", "are there any blockers", "are my dependencies compatible", "does Azure support my framework", "what needs to change before deploying", "check my app configuration".by microsoft · ★ 3.1kAzure Data Explorer (Kusto) Query & AnalyticsQuery and analyze data in Azure Data Explorer (Kusto/ADX) using KQL for log analytics, telemetry, and time series analysis. WHEN: KQL queries, Kusto database queries, Azure Data Explorer, ADX clusters, log analytics, time series data, IoT telemetry, anomaly detection.by microsoft · ★ 1.6kDocker MCP gatewayDocker's own CLI plugin: run any server from the Docker MCP Catalog in its own container, behind one connection, with secrets kept out of env vars.by docker · ★ 1.6kElisymOpen infrastructure for AI agents to discover and pay each otherby elisymlabs · ★ 17Technical Codebase Discovery & Onboarding PromptA prompt designed to guide a deep technical analysis of a code repository to accelerate developer onboarding. It instructs an AI to analyze the entire codebase and generate a structured Markdown document covering architecture, technology stack, key components, execution and data flows, integrations, testing, security, and build/deployment, serving as a technical reference guide.by Valdecir Carvalho

More from microsoft

Playwright MCPMicrosoft's browser automation server: your AI opens pages, clicks, fills forms and reads the page through the accessibility tree.by microsoft · ★ 37.5kSkillOpt-Sleep: usage-driven self-evolution for a local Claude agentUse when the user wants their Claude agent to self-improve from past usage, asks about a nightly/offline 'sleep' or 'dream' cycle, memory/skill consolidation, or says things like 'make my agent better the more I use it', 'review my past sessions', 'learn my prby microsoft · ★ 17.3kAzure app onboardEnd-to-end orchestrator: from a business idea, app idea, or existing app to running Azure deployment with cost estimates and pre-deploy approval. Analyzes your app, auto-detects the right Azure services, scaffolds infrastructure code, and deploys — tailored to your app, not a template. Handles moving existing apps to Azure without rewriting or with minimal changes. WHEN: bring your app to Azure, plan my app, cost to run, is my code ready to deploy, deploy my app to the cloud, deploy all my services, what Azure services do I need, plan my Azure deployment, deploy my new app to Azure, one-click deploy, I have an app and want it on Azure, migrate my app to Azure, help me get started, build an app, no code yet, starter project. DO NOT USE FOR: use azd for deployment(use azure-deploy), optimizing existing costs (use cost-optimization), code readiness checks only (use azure-app-onboard-prereq).by microsoft · ★ 3.1kAzure App Onboard Prereq — Repository EvaluationAssess whether source code is ready to deploy to Azure — the check BEFORE infrastructure work. Evaluates build health, app completeness, dependencies and local services, stack compatibility, and deployment feasibility. Answers questions about what your app needs before it can be deployed — frameworks, dependencies, and configuration. Checks whether dependencies are compatible and identifies deployment blockers and unsupported frameworks. WHEN: "evaluate my repo", "is my app ready to deploy", "what does my app need to deploy", "what do I need before deploying", "does my app need", "can I ship this to Azure", "scan my repo for issues", "is this app deployable", "check if my app is ready for Azure", "do I need a Dockerfile", "what's blocking my deployment", "are there any blockers", "are my dependencies compatible", "does Azure support my framework", "what needs to change before deploying", "check my app configuration".by microsoft · ★ 3.1kAzure Compliance & Security AuditingRun Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.by microsoft · ★ 3.1kAzure Data Explorer (Kusto) Query & AnalyticsQuery and analyze data in Azure Data Explorer (Kusto/ADX) using KQL for log analytics, telemetry, and time series analysis. WHEN: KQL queries, Kusto database queries, Azure Data Explorer, ADX clusters, log analytics, time series data, IoT telemetry, anomaly detection.by microsoft · ★ 1.6k

Your agent, with every skill.

Connect once. Free when signed in.

Connect MCP