{"id":"75ceea4a-6d99-444d-a03b-27c990e9f193","shortId":"xVP8Sv","kind":"skill","title":"azure-aigateway","tagline":"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,","description":"# Azure AI Gateway\n\nConfigure Azure API Management (APIM) as an AI Gateway for governing AI models, MCP tools, and agents.\n\n> **To deploy APIM**, use the **azure-prepare** skill. See [APIM deployment guide](https://learn.microsoft.com/azure/api-management/get-started-create-service-instance).\n\n## When to Use This Skill\n\n| Category | Triggers |\n|----------|----------|\n| **Model Governance** | \"semantic caching\", \"token limits\", \"load balance AI\", \"track token usage\" |\n| **Tool Governance** | \"rate limit MCP\", \"protect my tools\", \"configure my tool\", \"convert API to MCP\" |\n| **Agent Governance** | \"content safety\", \"jailbreak detection\", \"filter harmful content\" |\n| **Configuration** | \"add Azure OpenAI backend\", \"configure my model\", \"add AI Foundry model\" |\n| **Testing** | \"test AI gateway\", \"call OpenAI through gateway\" |\n\n---\n\n## Quick Reference\n\n| Policy | Purpose | Details |\n|--------|---------|---------|\n| `azure-openai-token-limit` | Cost control | [Model Policies](references/policies.md#token-rate-limiting) |\n| `azure-openai-semantic-cache-lookup/store` | 60-80% cost savings | [Model Policies](references/policies.md#semantic-caching) |\n| `azure-openai-emit-token-metric` | Observability | [Model Policies](references/policies.md#token-metrics) |\n| `llm-content-safety` | Safety & compliance | [Agent Policies](references/policies.md#content-safety) |\n| `rate-limit-by-key` | MCP/tool protection | [Tool Policies](references/policies.md#request-rate-limiting) |\n\n---\n\n## Get Gateway Details\n\n```bash\n# Get gateway URL\naz apim show --name <apim-name> --resource-group <rg> --query \"gatewayUrl\" -o tsv\n\n# List backends (AI models)\naz apim backend list --service-name <apim-name> --resource-group <rg> \\\n  --query \"[].{id:name, url:url}\" -o table\n\n# Get subscription key\naz apim subscription keys list \\\n  --service-name <apim-name> --resource-group <rg> --subscription-id <sub-id>\n```\n\n---\n\n## Test AI Endpoint\n\n```bash\nGATEWAY_URL=$(az apim show --name <apim-name> --resource-group <rg> --query \"gatewayUrl\" -o tsv)\n\ncurl -X POST \"${GATEWAY_URL}/openai/deployments/<deployment>/chat/completions?api-version=2024-02-01\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Ocp-Apim-Subscription-Key: <key>\" \\\n  -d '{\"messages\": [{\"role\": \"user\", \"content\": \"Hello\"}], \"max_tokens\": 100}'\n```\n\n---\n\n## Common Tasks\n\n### Add AI Backend\n\nSee [references/patterns.md](references/patterns.md#pattern-1-add-ai-model-backend) for full steps.\n\n```bash\n# Discover AI resources\naz cognitiveservices account list --query \"[?kind=='OpenAI']\" -o table\n\n# Create backend\naz apim backend create --service-name <apim> --resource-group <rg> \\\n  --backend-id openai-backend --protocol http --url \"https://<aoai>.openai.azure.com/openai\"\n\n# Grant access (managed identity)\naz role assignment create --assignee <apim-principal-id> \\\n  --role \"Cognitive Services User\" --scope <aoai-resource-id>\n```\n\n### Apply AI Governance Policy\n\nRecommended policy order in `<inbound>`:\n\n1. **Authentication** - Managed identity to backend\n2. **Semantic Cache Lookup** - Check cache before calling AI\n3. **Token Limits** - Cost control\n4. **Content Safety** - Filter harmful content\n5. **Backend Selection** - Load balancing\n6. **Metrics** - Token usage tracking\n\nSee [references/policies.md](references/policies.md#combining-policies) for complete example.\n\n---\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| Token limit 429 | Increase `tokens-per-minute` or add load balancing |\n| No cache hits | Lower `score-threshold` to 0.7 |\n| Content false positives | Increase category thresholds (5-6) |\n| Backend auth 401 | Grant APIM \"Cognitive Services User\" role |\n\nSee [references/troubleshooting.md](references/troubleshooting.md) for details.\n\n---\n\n## References\n\n- [**Detailed Policies**](references/policies.md) - Full policy examples\n- [**Configuration Patterns**](references/patterns.md) - Step-by-step patterns\n- [**Troubleshooting**](references/troubleshooting.md) - Common issues\n- [AI-Gateway Samples](https://github.com/Azure-Samples/AI-Gateway)\n- [GenAI Gateway Docs](https://learn.microsoft.com/azure/api-management/genai-gateway-capabilities)\n\n## SDK Quick References\n\n- **Content Safety**: [Python](references/sdk/azure-ai-contentsafety-py.md) | [TypeScript](references/sdk/azure-ai-contentsafety-ts.md)\n- **API Management**: [Python](references/sdk/azure-mgmt-apimanagement-py.md) | [.NET](references/sdk/azure-mgmt-apimanagement-dotnet.md)","tags":["azure","aigateway","skills","microsoft","agent-skills"],"capabilities":["skill","source-microsoft","skill-azure-aigateway","topic-agent-skills"],"categories":["azure-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/microsoft/azure-skills/azure-aigateway","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add microsoft/azure-skills","source_repo":"https://github.com/microsoft/azure-skills","install_from":"skills.sh"}},"qualityScore":"0.950","qualityRationale":"deterministic score 0.95 from registry signals: · indexed on github topic:agent-skills · official publisher · 1014 github stars · SKILL.md body (4,455 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T18:53:16.596Z","embedding":null,"createdAt":"2026-04-18T20:23:26.932Z","updatedAt":"2026-05-18T18:53:16.596Z","lastSeenAt":"2026-05-18T18:53:16.596Z","tsv":"'-01':306 '-02':305 '-1':336 '-6':480 '-80':173 '/azure-samples/ai-gateway)':520 '/azure/api-management/genai-gateway-capabilities)':526 '/azure/api-management/get-started-create-service-instance).':82 '/chat/completions':300 '/openai':381 '/openai/deployments':299 '/store':171 '0.7':472 '1':404 '100':326 '2':410 '2024':304 '3':419 '4':424 '401':483 '429':454 '5':430,479 '6':435 '60':172 'access':383 'account':351 'add':36,40,127,134,329,338,461 'add-ai-model-backend':337 'agent':18,66,117,201 'ai':10,13,28,41,45,48,57,61,98,135,140,241,278,330,339,347,397,418,515 'ai-gateway':514 'aigateway':3 'api':6,52,114,302,536 'api-vers':301 'apim':54,69,77,229,244,264,284,315,361,485 'appli':396 'application/json':311 'assign':388 'assigne':390 'auth':482 'authent':405 'az':228,243,263,283,349,360,386 'azur':2,5,37,47,51,73,128,152,166,183 'azure-aigateway':1 'azure-openai-emit-token-metr':182 'azure-openai-semantic-cache-lookup':165 'azure-openai-token-limit':151 'azure-prepar':72 'backend':39,130,240,245,331,341,359,362,371,375,409,431,481 'backend-id':370 'balanc':27,97,434,463 'bash':224,280,345 'cach':21,93,169,181,412,415,465 'call':142,417 'categori':88,477 'check':414 'cognit':392,486 'cognitiveservic':350 'combin':444 'combining-polici':443 'common':327,512 'complet':447 'complianc':200 'configur':4,50,110,126,131,502 'content':24,119,125,197,205,309,322,425,429,473,530 'content-safeti':204 'content-typ':308 'control':157,423 'convert':113 'cost':156,174,422 'creat':358,363,389 'curl':294 'd':318 'deploy':68,78 'detail':150,223,494,496 'detect':35,122 'discov':346 'doc':523 'emit':185 'endpoint':279 'exampl':448,501 'fals':474 'filter':123,427 'foundri':42,136 'full':343,499 'gateway':11,46,49,58,141,145,222,226,281,297,516,522 'gatewayurl':236,291 'genai':521 'get':221,225,260 'github.com':519 'github.com/azure-samples/ai-gateway)':518 'govern':30,60,91,103,118,398 'grant':382,484 'group':234,252,273,289,369 'guid':79 'h':307,312 'harm':124,428 'hello':323 'hit':466 'http':377 'id':254,276,372 'ident':385,407 'increas':455,476 'issu':450,513 'jailbreak':34,121 'key':211,262,266,317 'kind':354 'learn.microsoft.com':81,525 'learn.microsoft.com/azure/api-management/genai-gateway-capabilities)':524 'learn.microsoft.com/azure/api-management/get-started-create-service-instance).':80 'limit':23,33,95,105,155,164,209,220,421,453 'list':239,246,267,352 'llm':196 'llm-content-safeti':195 'load':26,96,433,462 'lookup':170,413 'lower':467 'manag':7,53,384,406,537 'max':324 'mcp':15,31,63,106,116 'mcp/tool':212 'messag':319 'metric':187,194,436 'minut':459 'model':14,29,43,62,90,133,137,158,176,189,242,340 'name':231,249,255,270,286,366 'net':540 'o':237,258,292,356 'observ':188 'ocp':314 'ocp-apim-subscription-key':313 'openai':38,129,143,153,167,184,355,374 'openai-backend':373 'openai.azure.com':380 'openai.azure.com/openai':379 'order':402 'pattern':335,503,509 'per':458 'polici':148,159,177,190,202,215,399,401,445,497,500 'posit':475 'post':296 'prepar':74 'protect':107,213 'protocol':376 'purpos':149 'python':532,538 'queri':235,253,290,353 'quick':146,528 'rate':32,104,163,208,219 'rate-limit-by-key':207 'recommend':400 'refer':147,495,529 'references/patterns.md':333,334,504 'references/policies.md':160,178,191,203,216,441,442,498 'references/sdk/azure-ai-contentsafety-py.md':533 'references/sdk/azure-ai-contentsafety-ts.md':535 'references/sdk/azure-mgmt-apimanagement-dotnet.md':541 'references/sdk/azure-mgmt-apimanagement-py.md':539 'references/troubleshooting.md':491,492,511 'request':218 'request-rate-limit':217 'resourc':233,251,272,288,348,368 'resource-group':232,250,271,287,367 'role':320,387,391,489 'safeti':25,120,198,199,206,426,531 'sampl':517 'save':175 'scope':395 'score':469 'score-threshold':468 'sdk':527 'see':76,332,440,490 'select':432 'semant':20,92,168,180,411 'semantic-cach':179 'servic':248,269,365,393,487 'service-nam':247,268,364 'show':230,285 'skill':75,87 'skill-azure-aigateway' 'solut':451 'source-microsoft' 'step':344,506,508 'step-by-step':505 'subscript':261,265,275,316 'subscription-id':274 'tabl':259,357 'task':328 'test':44,138,139,277 'threshold':470,478 'token':22,94,100,154,162,186,193,325,420,437,452,457 'token-metr':192 'token-rate-limit':161 'tokens-per-minut':456 'tool':16,64,102,109,112,214 'topic-agent-skills' 'track':99,439 'trigger':89 'troubleshoot':449,510 'tsv':238,293 'type':310 'typescript':534 'url':227,256,257,282,298,378 'usag':101,438 'use':70,85 'user':321,394,488 'version':303 'x':295","prices":[{"id":"369c7cc8-4399-4c0d-99d5-9430cdc572e1","listingId":"75ceea4a-6d99-444d-a03b-27c990e9f193","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"microsoft","category":"azure-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T20:23:26.932Z"}],"sources":[{"listingId":"75ceea4a-6d99-444d-a03b-27c990e9f193","source":"github","sourceId":"microsoft/azure-skills/azure-aigateway","sourceUrl":"https://github.com/microsoft/azure-skills/tree/main/skills/azure-aigateway","isPrimary":false,"firstSeenAt":"2026-04-18T21:57:06.252Z","lastSeenAt":"2026-05-18T18:53:16.596Z"},{"listingId":"75ceea4a-6d99-444d-a03b-27c990e9f193","source":"skills_sh","sourceId":"microsoft/azure-skills/azure-aigateway","sourceUrl":"https://skills.sh/microsoft/azure-skills/azure-aigateway","isPrimary":true,"firstSeenAt":"2026-04-18T20:23:26.932Z","lastSeenAt":"2026-05-07T22:40:11.837Z"}],"details":{"listingId":"75ceea4a-6d99-444d-a03b-27c990e9f193","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"microsoft","slug":"azure-aigateway","github":{"repo":"microsoft/azure-skills","stars":1014,"topics":["agent-skills"],"license":"mit","html_url":"https://github.com/microsoft/azure-skills","pushed_at":"2026-05-18T14:38:04Z","description":"Official agent plugin providing skills and MCP server configurations for Azure scenarios.","skill_md_sha":"a8df9f45fae25501acf7fee988047f808d191fa5","skill_md_path":"skills/azure-aigateway/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/microsoft/azure-skills/tree/main/skills/azure-aigateway"},"layout":"multi","source":"github","category":"azure-skills","frontmatter":{"name":"azure-aigateway","license":"MIT","description":"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.","compatibility":"Requires Azure CLI (az) for configuration and testing"},"skills_sh_url":"https://skills.sh/microsoft/azure-skills/azure-aigateway"},"updatedAt":"2026-05-18T18:53:16.596Z"}}