azure-aigateway

Configure Azure API Management as an AI gateway for models, MCP tools, and agents.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/merceralex397-collab/alex-stack --skill azure-aigateway-merceralex397-collab
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: azure-aigateway
Source: https://github.com/merceralex397-collab/alex-stack/tree/main/dev/azure-profile/azure-skills-main/azure-skills-main/.github/plugins/azure-skills/skills/azure-aigateway
Command: npx skills add https://github.com/merceralex397-collab/alex-stack --skill azure-aigateway-merceralex397-collab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Governing AI model traffic—controlling token costs, caching responses, filtering harmful content, and load balancing across backends—requires complex Azure API Management policy configuration that is error-prone when done manually. ## Core Features & Use Cases - AI Backend Configuration: Add Azure OpenAI or AI Foundry models as APIM backends with managed identity authentication and RBAC setup via Azure CLI. - Governance Policies: Apply token rate limits, semantic caching, token usage metrics, content safety, and jailbreak detection policies in the correct order. - Tool & Agent Protection: Rate-limit MCP tool calls per agent, convert existing APIs to MCP tools, and load balance across multiple AI regions with retry logic. - Use Case: You want to cut Azure OpenAI costs and prevent abuse. Use this Skill to add a semantic cache lookup, a per-subscription token limit, and content safety filtering to your APIM gateway, then test the endpoint with curl. ## Quick Start Ask the AI to add an Azure OpenAI backend to your APIM instance and apply a token limit policy with semantic caching enabled.

Frequently Asked Questions about azure-aigateway

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Azure API Management as an AI gateway?▼

Create an APIM backend pointing to your Azure OpenAI endpoint, enable managed identity on APIM, grant it the Cognitive Services User role, and import the OpenAI API specification. Then apply governance policies like token limits and semantic caching in the inbound section.

How to set up semantic caching for Azure OpenAI in APIM?▼

Add azure-openai-semantic-cache-lookup in the inbound policy and azure-openai-semantic-cache-store in outbound, with an embeddings backend and Azure Cache for Redis Enterprise with RediSearch. Use a score-threshold around 0.8; note it does not work with streaming responses.

Does APIM semantic caching work with streaming responses?▼

No. Semantic caching and token metrics policies are not compatible with streaming responses using "stream": true. Use non-streaming requests for cost control scenarios that rely on caching.

Why does my APIM AI gateway return 401 from the backend?▼

A 401 usually means managed identity is not enabled on APIM, the Cognitive Services User role is missing, or the authentication resource is wrong. Verify identity with az apim show, check role assignments, and wait 5-10 minutes for RBAC propagation.

How do I fix 429 token limit errors in Azure API Management?▼

Increase the tokens-per-minute value, load balance across multiple Azure OpenAI backends, or enable semantic caching to reduce token consumption. If the 429 comes from Azure OpenAI itself, raise the deployment TPM quota or add retry with backoff.

Can I rate limit MCP tool calls per agent in APIM?▼

Yes. Use the rate-limit-by-key policy with a counter-key derived from an agent identifier header such as X-Agent-Id. This throttles calls per agent and can return remaining-calls and Retry-After headers.