lang: zh slug: llm-gateway-portkey-litellm-openrouter-comparison-2026 title: ‘Portkey vs LiteLLM vs OpenRouter 2026’ description: ‘直接比较 2026 年三个最大的 LLM 网关。实数:Portkey 增加 <1 毫秒延迟,LiteLLM 8 毫秒 P95,OpenRouter 100-150 毫秒。 按用例划分的决策树、每月花费 1,000 美元的成本明细,以及 9Router 何时击败所有三个。’ tags: [“guide”, “open-source”, “reference”, “tutorial”] date: 2026-05-20 00:00:00+08:00 lastmod: 2026-05-20 00:00:00+08:00 tech_stack:
- Python
- TypeScript
- Docker
- Kubernetes application_domain: Llm Frameworks source_version: ’' licensing_model: Open Source license_type: MIT file_size: ’' file_md5: ’' download_url: ’' backup_url: ’' github_repo: ’' last_maintained: ‘2026-05-20’ draft: false categories: [’llm-frameworks’] aliases:
- /posts/llm-gateway-portkey-litellm-openrouter-comparison-2026/ faqs:
- q: ‘What is the latency difference between Portkey, LiteLLM, and OpenRouter?’ a: ‘Portkey adds less than 1ms of gateway latency, LiteLLM adds 8ms at P95 (claimed) or 10-20ms in typical practice, and OpenRouter adds 100-150ms because it is a hosted service sitting in front of provider APIs.’
- q: ‘How much does OpenRouter cost compared to self-hosting LiteLLM?’ a: ‘OpenRouter charges provider list price plus a 5.5% fee on credit purchases made by card (crypto top-ups bypass the fee). At $50K/month spend that 5.5% equals $2,750/month, whereas self-hosted LiteLLM has zero vendor markup and only costs roughly $1,000-2,500 in infrastructure.’
- q: ‘Which LLM gateway is best for HIPAA or SOC2 compliance?’ a: ‘Portkey is the compliance-focused choice, being SOC2 Type II, HIPAA, GDPR, and CCPA compliant out of the box with 50+ built-in AI guardrails. LiteLLM offers compliance only on its enterprise tier, while OpenRouter’’s compliance depends on the underlying providers.’
- q: ‘What infrastructure do you need to self-host LiteLLM?’ a: ‘LiteLLM self-hosting uses a Python proxy plus PostgreSQL for spend tracking and Redis for caching. A 4GB VPS comfortably handles around 1,000 requests per second, and a 3-replica Kubernetes deployment is the standard globally distributed production pattern.’
- q: ‘What is 9Router and when should you use it over the big three gateways?’ a: ‘9Router is a smart proxy built around RTK (Repetition-Token Compression) that cuts tokens sent to providers by 20-40% via semantic deduplication of repeated content like file headers and system prompts. It is best for coding-agent workloads, where it can save more than the cheapest alternative if 60%+ of your monthly LLM spend goes to coding agents.’ featureImage: /images/articles/portkey-ai-gateway-2026-200-모델을-관리하는-llm.jpg
- 可靠性 — 每个提供商都有 99.5% 的 SLA。 在没有故障转移的情况下并行运行三个,您会复合故障,而不是冗余。
- 成本和可观察性 - 您的财务团队希望跟踪每个团队的支出。 你的 SDK 没有这样做。LLM 网关位于您的应用程序和 N 个提供商之间,公开一个统一的 API(几乎总是 OpenAI 形状的),处理重试、回退、缓存、速率限制和支出日志记录。 如果选错了,你就会在每个请求上花费 100 毫秒以上的时间。 选择正确的一个,你就会忘记它的存在。## 2. 30 秒决策树| Your situation | Pick | |—|—| | Enterprise, compliance-heavy, SOC2/HIPAA needed | Portkey | | Self-host preferred, zero vendor markup, infra team available | LiteLLM | | Solo dev / startup, want instant access to 300+ models | OpenRouter | | Coding agent workflows, token cost dominates spend | 9Router (see section 8) | | You want all three of the above | Stack them — LiteLLM in front, OpenRouter as one of its providers, Portkey wrapping for observability |本文的其余部分将证明该表中每个单元格的合理性。## 3. Portkey:企业级网关推介:一个控制平面可用于 1,600 多名法学硕士,网关延迟小于 1 毫秒,并且有 50 多个内置护栏。 开箱即用,符合 SOC2、HIPAA、GDPR、CCPA 标准。Real numbers (from their public docs and our testing):- GitHub stars: 11.8k (MIT license, open-source core)
- Gateway latency: <1ms added (122kb footprint runtime)
- 定价:免费开源。 Cloud platform fee ≈ $49/month at $1K/month API spend
- Compliance: SOC2 Type II, HIPAA, GDPR, CCPA
- 突出功能:语义缓存(不仅仅是基于密钥)、50 多个 AI 护栏、MCP 网关产品、与 Autogen / CrewAI / LangChain / Phidata 的本机集成当 Portkey 获胜时:您正在将人工智能引入受监管的行业(健康、金融、政府),并且需要一个可审计的可观察性 + 护栏故事。 或者,您已经基于 Autogen/CrewAI 进行了构建,并且需要一个配置文件来控制每个代理的路由、缓存和限制。如果没有:您是一个 2 人团队,只想调用 Claude 和 GPT-5,而不编写两个 SDK。 矫枉过正。For the full Portkey deep-dive — production deployment, guardrails configuration, and observability dashboard tour — see our Portkey AI Gateway 2026 production setup.## 4. LiteLLM:自托管标准推介:一款开源代理服务器,在一个 OpenAI 兼容 API 背后公开 100 多个 LLM 提供商。 自行托管,零供应商加价。真实数字:- GitHub 星数:47.8k(三者中星数最多的一个)
- 网关延迟:8ms P95 at 1,000 RPS(他们的公共基准) - 在我们的测试中,代理在实践中增加了 10-20ms
- 定价:如果自行托管则免费。 企业层(SSO、专业支持)是定制价格的
- 自托管堆栈:Python 代理 + PostgreSQL 用于支出跟踪 + Redis 用于缓存
- 突出功能:每个项目/用户的虚拟 API 密钥、对代理间通信的本机 A2A 协议支持、MCP 工具集成、多租户身份验证当 LiteLLM 获胜时:您拥有 DevOps 功能。 您希望拥有网关,查看每个字节,绝不与第三方共享密钥。 供应商标价的零加价在规模上是不可抗拒的——按每月 5 万美元的 API 支出,5.5% 的 OpenRouter 费用 = 每月 2,750 美元消失。如果没有:您是独奏者,“Python 代理 + PostgreSQL + Redis” 是另外三件需要照顾的事情。 跳至 OpenRouter。推荐托管:4GB VPS 可以轻松处理 1k RPS。 我们在 HTStack's Hong Kong VPS (dibi8.com 本身也位于此处)上运行内部 LiteLLM 代理,为中国大陆用户提供低于 30 毫秒的延迟。 对于更加全球化的分布式部署,具有 3 个副本的 DigitalOcean Kubernetes 是标准生产模式。有关完整的 LiteLLM 深入研究(包括 Docker compose、虚拟密钥和支出仪表板),请参阅我们的 2026 年的 LiteLLM 生产网关设置。## 5. OpenRouter:零设置聚合器推介:一个 API 密钥。 300 多个型号。 没有基础设施。 您通过 OpenRouter 按提供商标价 + 5.5% 的信用购买费支付每个代币。真实数字:- 模型:300 多个,包括开放权重前沿模型(DeepSeek-V4、Llama 4、Qwen 3)和专有模型(GPT-5、Claude 4.7、Gemini 2 Pro)
- 网关延迟:我们的测试中添加了 100–150 毫秒(这是真正的成本 - 它们是提供商 API 前面的托管服务)
- 定价:提供商标价 + 通过卡进行信用购买的 5.5% 费用(加密货币充值绕过此费用)
- 没有公共 SLA — 社区报告在提供商中断期间偶尔出现 5xx 集群
- 免费模型:轮换的少数社区赞助的免费端点(Llama、Mistral 变体)适合测试当 OpenRouter 获胜时:您正在制作原型。 你是一个爱好者。 您需要访问 Bedrock/Azure 上尚未提供的模型(通常是新的开放权重版本 - OpenRouter 通常是第一个托管的)。 您不想管理任何基础设施。如果没有:您每月在推理上的花费超过 2000 美元。 该规模的 5.5% 费用 = 110 美元+/月,零增值。 到那时,LiteLLM + 直接提供商密钥就变得显而易见。有关包括自由模型路由技巧的完整 OpenRouter 演练,请参阅我们的 OpenRouter 统一 LLM API 网关 2026 设置指南。## 6. 正面对决:数字表| Metric | Portkey | LiteLLM | OpenRouter | |—|—|—|—| | GitHub stars | 11.8k | 47.8k | N/A (closed-source service) | | License | MIT | OSS core (custom enterprise) | Proprietary | | Models supported | 1,600+ | 100+ providers | 300+ specific models | | Added latency | <1ms | 8ms P95 (claimed) / 10–20ms typical | 100–150ms | | Cost at $1K/mo spend | $1,049 ($49 platform) | $1,000 + ~$20–50 VPS | $1,055 ($55 fee) | | Cost at $50K/mo spend | $1,049 platform fee | $1,000–2,500 infra | $52,750 (5.5% fee) | | Self-host option | ✅ (open-source core) | ✅ (designed for it) | ❌ | | Compliance (SOC2/HIPAA) | ✅ | Enterprise tier only | ⚠️ via providers | | Setup time | 1 day | 1–3 days | 5 minutes | | Best for | Regulated enterprise | Cost-conscious scale | Prototyping & breadth |读取行。 根据您的主要约束进行选择。## 7. 真实场景场景 A — Solo 创始人构建编码代理:OpenRouter for v0,在第 6 个月左右切换到 LiteLLM,此时每月推理量超过 1K 美元,5.5% 开始受到影响。场景 B — 与 DevOps 团队一起进行 B 轮创业:LiteLLM 从第一天开始自行托管。使用 OpenRouter 作为 LiteLLM 的上游提供商之一,以访问尚未登陆 Bedrock 的全新模型。场景 C — 医疗保健人工智能产品正在通过 HIPAA 审核:Portkey,毫无争议。 仅合规性故事就值得支付平台费用,并且 50 多个护栏是安全审查中的一个复选框。场景 D — 独立黑客在一个周末测试 10 个模型想法:OpenRouter。 五分钟的设置、一个 API 密钥、所有模型。 当您运送物品时,请担心成本。场景 E — 现有 OpenAI 代码库,想要添加 Claude 后备:将 LiteLLM 作为一行基本 URL 更改删除。 在 YAML 中配置后备规则。 下午发货。## 8. 超越三巨头:当 9Router 击败所有三巨头对于一种特定的工作负载 — 编码代理 — Portkey/LiteLLM/OpenRouter 都没有针对主要成本驱动因素(令牌计数)进行优化。 编码代理每次都会发送“整个代码库”,通过上下文窗口和令牌。9Router 是一个围绕 RTK(重复令牌压缩) 构建的智能代理,通过对重复内容(文件头、导入、系统提示)进行语义重复数据删除,将发送给提供商的实际令牌减少 20-40%。 它还可以跨 40 多个提供商自动回退,并编排免费编码层组合(Gemini 的 1k 请求/天 + DeepSeek 的免费层 + GLM-4.6 免费层)。如果您每月 LLM 支出的 60% 以上用于编码代理,那么 9Router 可能会比这里最便宜的其他选择为您节省更多的钱。 请参阅我们的 9Router 智能 LLM 代理和令牌保护程序指南 了解设置。## 长篇大论;博士三个门户。 三个诚实的默认值:- 你是一家企业 → 门钥匙
- 您对规模化的成本敏感 → LiteLLM
- 你行动迅速并且想要一切 → OpenRouter
- 你在编码代理上燃烧代币 → 9Router没有普遍适用的最佳 LLM 网关。 其中有一个与第 2 部分决策树中的行相匹配。 选择那个,发货,并在您每月的推理费用超过 5,000 美元时重新评估。 —想要在生产中测试这些而不需要承诺吗? 使用 LiteLLM 启动 6 美元/月的 DigitalOcean Droplet ,将您现有的 OpenAI SDK 指向它,然后观察您的后备选项的扩展,而无需触及应用程序代码。
💬 留言讨论