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.

v1.15.2发布于 2026-01-12 08:46 UTC13,360star +21 / 7 天1,377fork同步于 2026-11-10 11:27 UTC

怎么上手

由 README 提炼,执行前请确认
npx @portkey-ai/gateway
硬件要求按 README 说明

README 未说明显存或 GPU 要求;本地运行只需 Node.js 和 npm,也可部署到 Docker、Cloudflare Workers、Replit 等。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

开源 AI 网关,用一个兼容 OpenAI 的 API 统一路由到上千个模型并加护栏

一个高性能 AI 网关,用统一 API 把请求路由到 1600+ 大模型,并内置 50+ 安全护栏,省去多模型接入和内容风控的重复开发。

核心能力

  • 用统一 OpenAI 兼容接口路由 1600+ 语言、视觉、音频、图像模型
  • 通过 Configs 配置自动重试与 fallback 避免服务中断
  • 支持负载均衡与条件路由来扩展 AI 应用
  • 内置 50+ 护栏拦截输入输出内容
  • 自带本地 Gateway Console 集中查看请求日志

容易踩的坑

本地运行需先装 Node.js 和 npm;默认监听 8787 端口(API 在 /v1,控制台在 /public/);调用时需自行提供各模型厂商的 API Key。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.15.2
  1. v1.15.2最新正式版2026-01-12 · 2026-01-12 08:46 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.15.1...v1.15.2

  2. v1.15.12025-12-24 · 2025-12-24 13:16 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.15.0...v1.15.1

  3. v1.15.02025-12-23 · 2025-12-23 14:21 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.14.3...v1.15.0

  4. v1.14.32025-11-26 · 2025-11-26 16:18 UTC
    查看更新说明
  5. v1.14.22025-11-21 · 2025-11-21 12:42 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/Portkey-AI/gateway/compare/v1.14.1...v1.14.2

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    [!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

    License Discord Twitter npm version Better Stack Badge

    Ask DeepWiki

    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?

    [!TIP] Starring this repo helps more developers discover the AI Gateway 🙏🏻

    star-2

    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/v1

    The 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

    Portkey Models

    Open-source LLM pricing database for 40+ providers - used by the Gateway for cost tracking.

    GitHub | Model Explorer

    Cookbooks

    ☄️ Trending

    🚨 Latest

    View all cookbooks →

    Supported Providers

    Explore Gateway integrations with 45+ providers and 8+ agent frameworks.

    ProviderSupportStream
    OpenAI✅✅
    Azure OpenAI✅✅
    Anyscale✅✅
    Google Gemini✅✅
    Anthropic✅✅
    Cohere✅✅
    Together AI✅✅
    Perplexity✅✅
    Mistral✅✅
    Nomic✅✅
    AI21✅✅
    Stability AI✅✅
    DeepInfra✅✅
    Ollama✅✅
    Novita AI✅✅

    View the complete list of 200+ supported models here

    Agents

    Gateway seamlessly integrates with popular agent frameworks. Read the documentation here.

    FrameworkCall 200+ LLMsAdvanced RoutingCachingLogging & 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.

    Rubeus Social Share (4)