🎯

azure-aigateway

🎯Skill

Helps you send all requests to your AI models and tools through Azure API Management, so you can control cost, block harmful content and limit traffic. It includes Azure command-line steps for setup and testing.

microsoft/azure-skills696,591 InstallsAdded Mar 4, 2026

Installation

$npx skills add microsoft/azure-skills --skill azure-aigateway

Run it in a terminal; it asks which AI coding tools to install it for (Claude Code, Codex, Cursor and more).

Uses skills.sh Β· Node.js 22.20+

After installing

Ask for related work and the agent uses it on its own, or call it yourself.

Run it (Claude Code)/azure-aigateway
Install by hand

Copy the whole skill folder from GitHub to the place below. Copying only SKILL.md can leave out files the skill uses.

Open the skill folder β†’
  • This project .claude/skills/azure-aigateway/
  • All projects ~/.claude/skills/azure-aigateway/

These paths are for Claude Code. For other tools, the command above puts it in the right place.

What this skill does

Overview

This skill sets up Azure API Management (APIM) as an AI gateway. An AI gateway is a single entry point that every request to your AI models, MCP tools (tools that AI agents can call) and agents passes through. You add policies, which are rules such as token limits or content checks, at this entry point and set everything up with the az command-line tool.

Key Features

  • Connect Azure OpenAI or AI Foundry models to the gateway and give it access with a managed identity (an Azure login for the service itself).
  • Limit how many tokens (the units AI models count text in) can be used per minute, and reuse earlier answers to similar questions with semantic caching.
  • Filter harmful content and detect jailbreak attempts, which are requests that try to make the AI ignore its rules.
  • Protect MCP tools with request rate limits and record token use as metrics.
  • Test the gateway with curl and find fixes for common errors such as 429 and 401.

Who is this for?

Use it when several apps share Azure OpenAI models and you need to control their cost and token use. It also fits when you must add safety filters or rate limits before your AI tools go live.

Summarized by AI from this skill's SKILL.md. Suggest a better one

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.

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

More from this repository10

🎯
microsoft-foundry🎯Skill

Helps you build, deploy, test, and manage AI agents and models on Microsoft Foundry, Microsoft's Azure service for AI. It guides the AI through each task with fixed steps.

🎯
azure-diagnostics🎯Skill

Helps you find and fix problems in apps running on Azure, such as crashes, slow responses, or connection failures. It checks things in a set order and can work only from logs you provide.

🎯
azure-prepare🎯Skill

azure-prepare gets a new or existing app ready to deploy to Azure with azd, Microsoft's command-line tool for Azure. It first writes a plan for your approval, then creates the setup files.

🎯
azure-deploy🎯Skill

azure-deploy puts your app on Azure after the azure-prepare and azure-validate skills have prepared and checked it. It runs the deployment, recovers from errors, and gives you the live web addresses.

🎯
azure-validate🎯Skill

azure-validate checks your Azure app before you deploy it, so you can catch setup and permission problems early. It runs after azure-prepare and before azure-deploy.

🎯
azure-resource-lookup🎯Skill

azure-resource-lookup finds and lists your Azure resources, such as web apps, virtual machines, and storage accounts, across your subscriptions. It only reads data and never changes anything.

🎯
azure-resource-visualizer🎯Skill

azure-resource-visualizer draws a diagram of an Azure resource group that shows how each resource connects to the others. It saves the diagram and notes in a markdown file.

🎯
azure-kusto🎯Skill

Lets Claude search and summarize large amounts of logs and app data stored in Azure Data Explorer. You ask what you want to know, and it writes and runs the queries for you.

🎯
azure-messaging🎯Skill

Helps you find and fix errors in apps that send and receive messages through Azure Event Hubs or Service Bus. It checks service health and Microsoft docs to suggest a fix.

🎯
azure-compute🎯Skill

A helper that sends your Azure virtual machine requests to the right step-by-step guide. It helps you choose, price, create and reserve cloud servers in Azure.