AI Gateway

Agent frameworks and SDKs

Labs to explore AI Models, MCP servers, and Agents with the AI Gateway powered by Azure API Management and Microsoft Foundry.

Your AI app calls the AI Gateway MCP server, which does the agent frameworks and SDKs work and sends the result back to the chat.

About AI Gateway

AI Gateway is the official MCP server from Azure-Samples, filed in our directory under agent frameworks and sdks. Labs to explore AI Models, MCP servers, and Agents with the AI Gateway powered by Azure API Management and Microsoft Foundry.

At a glance

Publisher
Azure-Samples, the company behind the product
Runs
See the README for setup
Written in
Jupyter Notebook
License
MIT
GitHub stars
1,017

How to set up AI Gateway

  1. Follow the install steps in the AI Gateway README; it is written in Jupyter Notebook, so have that toolchain ready.
  2. Check the AI Gateway README for keys or settings; the registry lists none that AI Gateway requires.
  3. Add AI Gateway to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the AI Gateway tools to confirm the connection.
  5. Run one read-only task with AI Gateway first, and keep your app asking before each tool call until the results look right.

AI Gateway compared with similar servers

  • Framework by QuantGeekDev has fewer GitHub stars than AI Gateway (1k against 1k); AI Gateway is official while Framework is a community server, and both run locally.
  • Tracekit MCP gateway by Cygnux-Labs has more GitHub stars than AI Gateway (1k against 1k); AI Gateway is official while Tracekit MCP gateway is a community server, and both run locally.
  • Figma MCP Bridge by gethopp has fewer GitHub stars than AI Gateway (985 against 1k); AI Gateway is official while Figma MCP Bridge is a community server, and both run locally.

Before you connect AI Gateway

  • Give AI Gateway its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each AI Gateway tool call until you trust what it does with them.
  • Treat text that AI Gateway fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for AI Gateway on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for AI Gateway

How marketing and sales teams put AI Gateway to work, by company size. Pick the size closest to yours and start AI Gateway on one use case.

Small business

  • A small business with a developer can use AI Gateway to build one focused agent, such as lead follow-up, without a big platform.
  • Technical founders can prototype marketing agents with AI Gateway and keep what works as a small, owned tool.
  • AI Gateway runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineering teams can use AI Gateway to build agents that combine CRM, analytics and content tools behind one workflow.
  • Marketing ops can standardize on AI Gateway so every agent they ship has the same logging, approvals and error handling.
  • Start AI Gateway on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can build on AI Gateway with their own identity, policy and evaluation layers, so agents meet the same bar as other software.
  • Platform teams can use AI Gateway to give business units a governed way to ship agents without each one starting from scratch.
  • Because AI Gateway comes from Azure-Samples, the company behind the product, it follows that product's own auth and permissions, which security teams usually prefer.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

AI Gateway README

From Azure-Samples/AI-Gateway on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

✨ AI Gateway Labs

Explore the enterprise-grade gateway for managing AI Models, Tools, and Agents


📰 New! The AI Gateway Dev Portal is now live, A starting point for building your own developer portal on top of Azure API Management AI Gateway's. Fork it, open it in VS Code with GitHub Copilot (or any coding agent), and shape it to fit your needs!

Why AI Gateway?

Building production-ready AI applications requires more than just calling model APIs. You need security, reliability, observability, and cost control, without slowing down innovation.

AI Gateway powered by Azure API Management provides:

  • 🔐 Security, OAuth 2.0, managed identities, content safety filtering
  • ⚡ Performance, Load balancing, semantic caching, request routing
  • 📊 Observability, Token metrics, built-in logging, tracing
  • 💰 Cost Control, Rate limiting, quota management, FinOps framework
  • 🔌 Extensibility, MCP protocol support, function calling, multi-model routing

📚 Explore the Labs

🔗 Browse all 30+ labs at aka.ms/ai-gateway/labs

Each lab is a hands-on Jupyter notebook with step-by-step instructions, Bicep infrastructure templates, and APIM policies you can deploy to your Azure subscription.

🧠 AI Gateway for Models

Manage and control access to Large Language Models with enterprise-grade policies.

Lab Description
Backend Pool Load Balancing Distribute requests across multiple model endpoints
Token Rate Limiting Control token consumption with rate limiting policies
Semantic Caching Cache responses using vector similarity for faster, cheaper completions
Model Routing Route requests to different backends based on model and version
FinOps Framework Manage AI budgets with automated quota controls

🔧 AI Gateway for Tools

Enable secure tool access with MCP protocol and function calling capabilities.

Lab Description
Model Context Protocol (MCP) Plug & play tools with OAuth credential management
MCP Client Authorization Implement MCP with the client authorization flow
Function Calling Use OpenAI function calling with Azure Functions backend
Realtime Audio + MCP Combine realtime voice API with MCP tools

🤖 AI Gateway for Agents

Build and control agentic applications with orchestration frameworks.

Lab Description
AI Agent Service Explore Foundry Agent Service with multi-service control
OpenAI Agents SDK Use OpenAI Agents with Azure OpenAI and APIM-managed tools
Gemini MCP Agents Integrate Google Gemini models with MCP tools
A2A Enabled Agents A2A-enabled Agents with models and MCP plug & play tools

🚀 Quick Start

Prerequisites
  • Python 3.12+
  • uv (fast Python package manager), install via curl -LsSf https://astral.sh/uv/install.sh | sh (Linux/macOS) or powershell -c "irm https://astral.sh/uv/install.ps1 | iex" (Windows)
  • VS Code with Jupyter extension
  • Azure Subscription with Contributor + RBAC Administrator roles
  • Azure CLI authenticated to your subscription
Get Started
# Clone the repository
git clone https://github.com/Azure-Samples/AI-Gateway.git
cd AI-Gateway

# Create the virtual environment and install dependencies
uv sync
uv pip install -r pyproject.toml

# Open VS Code and start with a lab
code .

When opening a notebook, select the .venv interpreter created by uv sync as the Jupyter kernel.

Or launch instantly with GitHub Codespaces ☁️

🔨 Developer Tools

The tools/ folder provides utilities for testing and development:

Tool Description
Tracing Invoke AI Foundry APIs with tracing enabled
Streaming Test streaming responses from AI models
Rate Limit Tester Validate rate limiting configurations
Mock Server OpenAI API mock for local development and testing
OAuth Client Test OAuth authentication flows

👩‍💻 Build Your Own Labs with AI

This repository includes Copilot Agent Skills that help you create new labs using AI-assisted development in VS Code.

Available Skills
Skill Description
lab-creator Scaffolds new labs with notebooks, Bicep, and policies
apim-bicep Generates Azure Bicep templates for APIM resources
apim-terraform Generates Terraform configurations for APIM
apim-policies Creates APIM XML policies for AI gateway scenarios
apim-kql Generates queries in KQL to control models, tools and agents
mcp-builder Builds MCP servers for tool integration
Example: Create a New Lab

Open this repo in VS Code with GitHub Copilot and use this prompt:

Create a new lab called "multi-model-failover" that demonstrates how to 
implement automatic failover between different AI models when the primary 
model is unavailable or throttled. Include:
- A backend pool with priority-based routing
- Retry policy with exponential backoff
- Circuit breaker pattern for unhealthy backends
- Built-in LLM logging to track usage across all backends
- Test the model with a LangChain agent: https://docs.langchain.com/oss/python/langchain/agents
Use gpt-4.1-mini as primary and gpt-4.1-nano as fallback, deploy to Sweden Central.

Copilot will generate the complete lab structure including:

  • 📓 Jupyter notebook with step-by-step instructions
  • 🦾 Bicep infrastructure template
  • ⚙️ APIM policy XML
  • 📖 README documentation
  • 🧹 Cleanup notebook

🏛️ Well-Architected Framework

Labs are designed following Azure Well-Architected Framework principles:

Pillar Labs
Security Access controlling, Content safety, Private connectivity
Reliability Backend pool load balancing, Token rate limiting
Performance Semantic caching, Model routing
Operations Built-in logging, Token metrics emitting
Cost FinOps framework, Semantic caching

📕 Enterprise AI Gateway e-Book

Download the Enterprise AI Gateway e-Book for comprehensive end-to-end view of the Enterprise AI Gateway pattern, explaining why a centralized governance layer is essential for organizations adopting AI at scale and how it can be practically implemented using Azure API Management and Microsoft Foundry.
It describes the AI Gateway as a control plane that mediates all interactions between AI apps and agents and the underlying models, data, and tools, enabling consistent enforcement of security, safety, cost controls, resiliency, scalability, observability, and governance. Overall, the e-Book positions the Enterprise AI Gateway as a foundational architectural component that allows enterprises to innovate rapidly with AI while maintaining trust, compliance, visibility, and control.

🎬 Conferences & Webcasts

Learn from experts through these videos covering AI Gateway concepts and implementations.

📖 Resources

🤝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

License

MIT

Questions about AI Gateway

What is the AI Gateway MCP server?

Labs to explore AI Models, MCP servers, and Agents with the AI Gateway powered by Azure API Management and Microsoft Foundry. AI Gateway is published by Azure-Samples, the company behind the product, on GitHub at Azure-Samples/AI-Gateway, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the AI Gateway MCP server?

AI Gateway doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (Azure-Samples/AI-Gateway). Like most servers, AI Gateway ends with a command or URL you paste into your AI app's MCP config.

Does AI Gateway need an API key?

The registry lists no required keys for AI Gateway. Check the AI Gateway README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is AI Gateway an official MCP server?

Yes. AI Gateway is published by Azure-Samples, the company that makes the product it connects to, so it follows that product's own API and auth.

What license is AI Gateway under?

AI Gateway is released under the MIT license, according to its GitHub repository. The license covers the code of AI Gateway; the service it connects to has its own terms.