AI-Gateway

作者 Azure-Samples已验证

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

976
Stars
497
Forks
Jupyter Notebook
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/Azure-Samples/AI-Gateway

快速入门

使用 AI-Gateway 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

✨ AI Gateway Labs

Open Source GitHub Stars Open in GitHub Codespaces

AI-Gateway Labs

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


AI-Gateway flow

Azure

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

LabDescription
Backend Pool Load BalancingDistribute requests across multiple model endpoints
Token Rate LimitingControl token consumption with rate limiting policies
Semantic CachingCache responses using vector similarity for faster, cheaper completions
Model RoutingRoute requests to different backends based on model and version
FinOps FrameworkManage AI budgets with automated quota controls

🔧 AI Gateway for Tools

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

LabDescription
Model Context Protocol (MCP)Plug & play tools with OAuth credential management
MCP Client AuthorizationImplement MCP with the client authorization flow
Function CallingUse OpenAI function calling with Azure Functions backend
Realtime Audio + MCPCombine realtime voice API with MCP tools

🤖 AI Gateway for Agents

Build and control agentic applications with orchestration frameworks.

LabDescription
AI Agent ServiceExplore Foundry Agent Service with multi-service control
OpenAI Agents SDKUse OpenAI Agents with Azure OpenAI and APIM-managed tools
Gemini MCP AgentsIntegrate Google Gemini models with MCP tools
A2A Enabled AgentsA2A-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:

ToolDescription
TracingInvoke AI Foundry APIs with tracing enabled
StreamingTest streaming responses from AI models
Rate Limit TesterValidate rate limiting configurations
Mock ServerOpenAI API mock for local development and testing
OAuth ClientTest 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

SkillDescription
lab-creatorScaffolds new labs with notebooks, Bicep, and policies
apim-bicepGenerates Azure Bicep templates for APIM resources
apim-terraformGenerates Terraform configurations for APIM
apim-policiesCreates APIM XML policies for AI gateway scenarios
apim-kqlGenerates queries in KQL to control models, tools and agents
mcp-builderBuilds 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:

PillarLabs
SecurityAccess controlling, Content safety, Private connectivity
ReliabilityBackend pool load balancing, Token rate limiting
PerformanceSemantic caching, Model routing
OperationsBuilt-in logging, Token metrics emitting
CostFinOps framework, Semantic caching

📕 Enterprise AI Gateway e-Book

Enterprise AI Gateway eBook

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.

Build 2025Reactor Jan 2025MCP WorkflowsSupercharge your API's
Ignite 2024Reactor Nov 2024Content SafetySemantic Caching
Token Emit MetricGenAI GatewayControl AI ServicesJohn Savill
Houssem DellaiTurbo360A2A MCP Multiagents

📖 Resources

🤝 Contributing

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

License

MIT

APIM Love

常见问题

What is AI-Gateway?

AI-Gateway is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by Azure-Samples. Labs to explore AI Models, MCP servers, and Agents with the AI Gateway powered by Azure API Management and Microsoft Foundry 🚀. It has 976 GitHub stars.

Is AI-Gateway safe to use?

Yes. AI-Gateway passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install AI-Gateway?

Clone the repository with "git clone https://github.com/Azure-Samples/AI-Gateway" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is AI-Gateway written in?

AI-Gateway is primarily written in Jupyter Notebook. It is open-source under Azure-Samples on GitHub, so you can review or fork the full source.

Are there alternatives to AI-Gateway?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh AI-Gateway against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情