本地运行需先装 Node.js 和 npm;默认监听 8787 端口(API 在 /v1,控制台在 /public/);调用时需自行提供各模型厂商的 API Key。
gateway
Portkey-AIMIT更新放缓一个高性能 AI 网关,用统一 API 把请求路由到 1600+ 大模型,并内置 50+ 安全护栏,省去多模型接入和内容风控的重复开发。
A blazing fast AI Gateway with integrated guardrails. Route to 1,600+ LLMs, 50+ AI Guardrails with 1 fast & friendly API.
npx @portkey-ai/gatewayREADME 未说明显存或 GPU 要求;本地运行只需 Node.js 和 npm,也可部署到 Docker、Cloudflare Workers、Replit 等。
开源 AI 网关,用一个兼容 OpenAI 的 API 统一路由到上千个模型并加护栏
一个高性能 AI 网关,用统一 API 把请求路由到 1600+ 大模型,并内置 50+ 安全护栏,省去多模型接入和内容风控的重复开发。
核心能力
- 用统一 OpenAI 兼容接口路由 1600+ 语言、视觉、音频、图像模型
- 通过 Configs 配置自动重试与 fallback 避免服务中断
- 支持负载均衡与条件路由来扩展 AI 应用
- 内置 50+ 护栏拦截输入输出内容
- 自带本地 Gateway Console 集中查看请求日志
容易踩的坑
- v1.15.2最新正式版2026-01-12 · 2026-01-12 08:46 UTC
What's Changed
- Qualifire | Update Guardrails by @yuval-qf in https://github.com/Portkey-AI/gateway/pull/1483
- feat: update readme by removing 2024 report and AI engineering hours by @siddharthsambharia-portkey in https://github.com/Portkey-AI/gateway/pull/1493
- fix: support azure blob for batches by @b4s36t4 in https://github.com/Portkey-AI/gateway/pull/1496
- fix: allow custom scope work with azure agents by @b4s36t4 in https://github.com/Portkey-AI/gateway/pull/1495
- make anthropic beta header usage consistent by @narengogi in https://github.com/Portkey-AI/gateway/pull/1491
- [bug/behaviour] only execute enabled checks when sequential guardrails are enabled by @narengogi in https://github.com/Portkey-AI/gateway/pull/1492
- fix: Bump Vercel Cookbook package versions by @beast-nev in https://github.com/Portkey-AI/gateway/pull/1497
- 1.15.2 by @VisargD in https://github.com/Portkey-AI/gateway/pull/1499
New Contributors
- @beast-nev made their first contribution in https://github.com/Portkey-AI/gateway/pull/1497
Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.15.1...v1.15.2
- v1.15.12025-12-24 · 2025-12-24 13:16 UTC
查看更新说明
What's Changed
- fix: gemini minimal reasoning effort by @narengogi in https://github.com/Portkey-AI/gateway/pull/1486
- feat: azure checks for protected material and sheild prompt by @b4s36t4 in https://github.com/Portkey-AI/gateway/pull/1480
- fix: use correct url for batches by @b4s36t4 in https://github.com/Portkey-AI/gateway/pull/1488
- 1.15.1 by @VisargD in https://github.com/Portkey-AI/gateway/pull/1489
Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.15.0...v1.15.1
- v1.15.02025-12-23 · 2025-12-23 14:21 UTC
查看更新说明
What's Changed
- Thinking level support for Gemini 3 Pro by @maciej-nexos in https://github.com/Portkey-AI/gateway/pull/1444
- anthropic models on azure by @narengogi in https://github.com/Portkey-AI/gateway/pull/1456
- Add IO Intelligence provider support by @eminaruk in https://github.com/Portkey-AI/gateway/pull/1451
- feat: gemini 3 in openrouter by @stefan-jiroveanu in https://github.com/Portkey-AI/gateway/pull/1454
- fix(docs): broken links by @juzhiyuan in https://github.com/Portkey-AI/gateway/pull/1470
- feat(provider): add AI Badgr OpenAI-compatible provider by @miguelmanlyx in https://github.com/Portkey-AI/gateway/pull/1472
- concatenate multple text parts for gemini models by @narengogi in https://github.com/Portkey-AI/gateway/pull/1466
- feat: Add support for Anthropic advanced tool use beta features by @roh26it in https://github.com/Portkey-AI/gateway/pull/1452
- feat: support azure v1 api & send deployment-name for responses by @b4s36t4 in https://github.com/Portkey-AI/gateway/pull/1467
- allow anthropic beta header for all routes on anthropic provider by @narengogi in https://github.com/Portkey-AI/gateway/pull/1463
- oracle provider by @narengogi in https://github.com/Portkey-AI/gateway/pull/1461
- add hallucination eval by @joshweimer-patronusai in https://github.com/Portkey-AI/gateway/pull/1434
- feat: add openai compatible response support for anthropic on azure by @arturfromtabnine in https://github.com/Portkey-AI/gateway/pull/1465
- improvements for nano banana by @narengogi in https://github.com/Portkey-AI/gateway/pull/1476
- fix(anthropic): add support for tool_choice=none by @ShivamB25 in https://github.com/Portkey-AI/gateway/pull/1477
- feat: add thinking parameter to OllamaChatCompleteConfig by @siddharthsambharia-portkey in https://github.com/Portkey-AI/gateway/pull/1415
- fix: type issues with transform type update by @b4s36t4 in https://github.com/Portkey-AI/gateway/pull/1479
- feat: add Not Null plugin to check for null or empty response content by @Samveg12 in https://github.com/Portkey-AI/gateway/pull/1481
- feat: add support for google maps grounding by @b4s36t4 in https://github.com/Portkey-AI/gateway/pull/1478
- Add OVHcloud AI Endpoints provider by @eliasto in https://github.com/Portkey-AI/gateway/pull/1471
- execute guardrails sequentially by @narengogi in https://github.com/Portkey-AI/gateway/pull/1475
- 1.15.0 by @VisargD in https://github.com/Portkey-AI/gateway/pull/1482
New Contributors
- @maciej-nexos made their first contribution in https://github.com/Portkey-AI/gateway/pull/1444
- @eminaruk made their first contribution in https://github.com/Portkey-AI/gateway/pull/1451
- @stefan-jiroveanu made their first contribution in https://github.com/Portkey-AI/gateway/pull/1454
- @juzhiyuan made their first contribution in https://github.com/Portkey-AI/gateway/pull/1470
- @miguelmanlyx made their first contribution in https://github.com/Portkey-AI/gateway/pull/1472
- @joshweimer-patronusai made their first contribution in https://github.com/Portkey-AI/gateway/pull/1434
- @ShivamB25 made their first contribution in https://github.com/Portkey-AI/gateway/pull/1477
- @Samveg12 made their first contribution in https://github.com/Portkey-AI/gateway/pull/1481
- @eliasto made their first contribution in https://github.com/Portkey-AI/gateway/pull/1471
Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.14.3...v1.15.0
- v1.14.32025-11-26 · 2025-11-26 16:18 UTC
查看更新说明
What's Changed
- fix google throught signature by @narengogi in https://github.com/Portkey-AI/gateway/pull/1450
- 1.14.3 by @VisargD in https://github.com/Portkey-AI/gateway/pull/1457
Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.14.2...v1.14.3
- v1.14.22025-11-21 · 2025-11-21 12:42 UTC
查看更新说明
What's Changed
- fix headers in streaming response for cached results by @narengogi in https://github.com/Portkey-AI/gateway/pull/1447
- 1.14.2 by @VisargD in https://github.com/Portkey-AI/gateway/pull/1448
Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.14.1...v1.14.2
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
[!IMPORTANT] :rocket: Gateway 2.0 (Pre-Release) Portkey's core enterprise gateway is merging into open-source with our 2.0 release. You can try the pre-release branch here. Read more about what's next for Portkey in our Series A announcement.
🆕 Portkey Models - Open-source LLM pricing for 2,300+ models across 40+ providers. Explore →
AI Gateway
Route to 250+ LLMs with 1 fast & friendly API
Docs | Enterprise | Hosted Gateway | Changelog | API Reference
The AI Gateway is designed for fast, reliable & secure routing to 1600+ language, vision, audio, and image models. It is a lightweight, open-source, and enterprise-ready solution that allows you to integrate with any language model in under 2 minutes.
- Blazing fast (<1ms latency) with a tiny footprint (122kb)
- Battle tested, with over 10B tokens processed everyday
- Enterprise-ready with enhanced security, scale, and custom deployments
What can you do with the AI Gateway?
- Integrate with any LLM in under 2 minutes - Quickstart
- Prevent downtimes through automatic retries and fallbacks
- Scale AI apps with load balancing and conditional routing
- Protect your AI deployments with guardrails
- Go beyond text with multi-modal capabilities
- Explore agentic workflow integrations
- Manage MCP servers with enterprise auth & observability using MCP Gateway
[!TIP] Starring this repo helps more developers discover the AI Gateway 🙏🏻
Quickstart (2 mins)
1. Setup your AI Gateway
# Run the gateway locally (needs Node.js and npm)
npx @portkey-ai/gateway
The Gateway is running on
http://localhost:8787/v1The Gateway Console is running on
http://localhost:8787/public/
2. Make your first request
# pip install -qU portkey-ai
from portkey_ai import Portkey
# OpenAI compatible client
client = Portkey(
provider="openai", # or 'anthropic', 'bedrock', 'groq', etc
Authorization="sk-***" # the provider API key
)
# Make a request through your AI Gateway
client.chat.completions.create(
messages=[{"role": "user", "content": "What's the weather like?"}],
model="gpt-4o-mini"
)
Supported Libraries: JS Python REST OpenAI SDKs Langchain LlamaIndex Autogen CrewAI More..
On the Gateway Console (http://localhost:8787/public/) you can see all of your local logs in one place.
3. Routing & Guardrails
Configs in the LLM gateway allow you to create routing rules, add reliability and setup guardrails.
config = {
"retry": {"attempts": 5},
"output_guardrails": [{
"default.contains": {"operator": "none", "words": ["Apple"]},
"deny": True
}]
}
# Attach the config to the client
client = client.with_options(config=config)
client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Reply randomly with Apple or Bat"}]
)
# This would always response with "Bat" as the guardrail denies all replies containing "Apple". The retry config would retry 5 times before giving up.
You can do a lot more stuff with configs in your AI gateway. Jump to examples →
Enterprise Version (Private deployments)
AWS Azure GCP OpenShift Kubernetes
The LLM Gateway's enterprise version offers advanced capabilities for org management, governance, security and more out of the box. View Feature Comparison →
The enterprise deployment architecture for supported platforms is available here - Enterprise Private Cloud Deployments
MCP Gateway
MCP Gateway provides a centralized control plane for managing MCP (Model Context Protocol) servers across your organization.
- Authentication — Single auth layer at the gateway. Users authenticate once; your MCP servers receive verified requests
- Access Control — Control which teams and users can access which servers and tools. Revoke access instantly
- Observability — Every tool call logged with full context: who called what, parameters, response, latency
- Identity Forwarding — Forward user identity (email, team, roles) to MCP servers automatically
Works with Claude Desktop, Cursor, VS Code, and any MCP-compatible client. Get started →
Core Features
Reliable Routing
- Fallbacks: Fallback to another provider or model on failed requests using the LLM gateway. You can specify the errors on which to trigger the fallback. Improves reliability of your application.
- Automatic Retries: Automatically retry failed requests up to 5 times. An exponential backoff strategy spaces out retry attempts to prevent network overload.
- Load Balancing: Distribute LLM requests across multiple API keys or AI providers with weights to ensure high availability and optimal performance.
- Request Timeouts: Manage unruly LLMs & latencies by setting up granular request timeouts, allowing automatic termination of requests that exceed a specified duration.
- Multi-modal LLM Gateway: Call vision, audio (text-to-speech & speech-to-text), and image generation models from multiple providers — all using the familiar OpenAI signature
- Realtime APIs: Call realtime APIs launched by OpenAI through the integrate websockets server.
Security & Accuracy
- Guardrails: Verify your LLM inputs and outputs to adhere to your specified checks. Choose from the 40+ pre-built guardrails to ensure compliance with security and accuracy standards. You can bring your own guardrails or choose from our many partners.
- Secure Key Management: Use your own keys or generate virtual keys on the fly.
- Role-based access control: Granular access control for your users, workspaces and API keys.
- Compliance & Data Privacy: The AI gateway is SOC2, HIPAA, GDPR, and CCPA compliant.
Cost Management
- Smart caching: Cache responses from LLMs to reduce costs and improve latency. Supports simple and semantic* caching.
- Usage analytics: Monitor and analyze your AI and LLM usage, including request volume, latency, costs and error rates.
- Provider optimization*: Automatically switch to the most cost-effective provider based on usage patterns and pricing models.
Collaboration & Workflows
- Agents Support: Seamlessly integrate with popular agent frameworks to build complex AI applications. The gateway seamlessly integrates with Autogen, CrewAI, LangChain, LlamaIndex, Phidata, Control Flow, and even Custom Agents.
- Prompt Template Management*: Create, manage and version your prompt templates collaboratively through a universal prompt playground.
Portkey Models
Open-source LLM pricing database for 40+ providers - used by the Gateway for cost tracking.
Cookbooks
☄️ Trending
- Use models from Nvidia NIM with AI Gateway
- Monitor CrewAI Agents with Portkey!
- Comparing Top 10 LMSYS Models with AI Gateway.
🚨 Latest
- Create Synthetic Datasets using Nemotron
- Use the LLM Gateway with Vercel's AI SDK
- Monitor Llama Agents with Portkey's LLM Gateway
Supported Providers
Explore Gateway integrations with 45+ providers and 8+ agent frameworks.
| Provider | Support | Stream | |
|---|---|---|---|
| OpenAI | ✅ | ✅ | |
| Azure OpenAI | ✅ | ✅ | |
| Anyscale | ✅ | ✅ | |
| Google Gemini | ✅ | ✅ | |
| Anthropic | ✅ | ✅ | |
| Cohere | ✅ | ✅ | |
| Together AI | ✅ | ✅ | |
| Perplexity | ✅ | ✅ | |
| Mistral | ✅ | ✅ | |
| Nomic | ✅ | ✅ | |
| AI21 | ✅ | ✅ | |
| Stability AI | ✅ | ✅ | |
| DeepInfra | ✅ | ✅ | |
| Ollama | ✅ | ✅ | |
| Novita AI | ✅ | ✅ |
Agents
Gateway seamlessly integrates with popular agent frameworks. Read the documentation here.
| Framework | Call 200+ LLMs | Advanced Routing | Caching | Logging & Tracing* | Observability* | Prompt Management* |
|---|---|---|---|---|---|---|
| Autogen | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| CrewAI | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| LangChain | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Phidata | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Llama Index | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Control Flow | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Build Your Own Agents | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| IO Intelligence | ✅ | ✅ |
*Available on the hosted app. For detailed documentation click here.
Gateway Enterprise Version
Make your AI app more reliable and forward compatible, while ensuring complete data security and privacy.
✅ Secure Key Management - for role-based access control and tracking ✅ Simple & Semantic Caching - to serve repeat queries faster & save costs ✅ Access Control & Inbound Rules - to control which IPs and Geos can connect to your deployments ✅ PII Redaction - to automatically remove sensitive data from your requests to prevent indavertent exposure ✅ SOC2, ISO, HIPAA, GDPR Compliances - for best security practices ✅ Professional Support - along with feature prioritization
Schedule a call to discuss enterprise deployments
Contributing
The easiest way to contribute is to pick an issue with the good first issue tag 💪. Read the contribution guidelines here.
Bug Report? File here | Feature Request? File here
Getting Started with the Community
Join our weekly AI Engineering Hours every Friday (8 AM PT) to:
- Meet other contributors and community members
- Learn advanced Gateway features and implementation patterns
- Share your experiences and get help
- Stay updated with the latest development priorities
Join the next session → | Meeting notes
Community
Join our growing community around the world, for help, ideas, and discussions on AI.
- View our official Blog
- Chat with us on Discord
- Follow us on Twitter
- Connect with us on LinkedIn
- Read the documentation in Japanese
- Visit us on YouTube
- Join our Dev community