Portkey AI Gateway — Route to 250+ LLMs
Portkey AI Gateway routes to 250+ LLMs with sub-1ms latency, 40+ guardrails, retries, fallbacks, and caching. 11.1K+ stars. Apache 2.0.
Agent 可直接安装
这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。
npx -y tokrepo@latest install 585d3a26-0cca-47cb-ac88-2797a853367d --target codex先 dry-run 确认安装计划,再运行此命令。
What it is
Portkey AI Gateway is an open-source API gateway that sits between your application and LLM providers. It routes requests to over 250 LLMs with sub-1ms latency overhead. Built-in features include 40+ guardrails, automatic retries, provider fallbacks, semantic caching, and request logging. It has over 11.1K GitHub stars and is Apache 2.0 licensed.
Portkey targets teams running production LLM applications who need reliability, cost control, and provider flexibility without vendor lock-in.
How it saves time or tokens
Portkey's semantic caching returns cached responses for similar queries, saving both tokens and latency. Automatic fallbacks switch to backup providers when the primary is down, avoiding downtime. The unified API means you switch providers by changing a config, not your code.
How to use
- Run locally:
npx @portkey-ai/gateway
- Or use the Python SDK:
pip install portkey-ai
- Route requests through the gateway:
from portkey_ai import Portkey
client = Portkey(api_key='your-key')
response = client.chat.completions.create(
model='gpt-4o',
messages=[{'role': 'user', 'content': 'Hello'}]
)
Example
# Run the gateway locally
npx @portkey-ai/gateway
# API at http://localhost:8787/v1
# Use with curl
curl http://localhost:8787/v1/chat/completions \
-H 'Content-Type: application/json' \
-H 'x-portkey-provider: openai' \
-H 'Authorization: Bearer sk-...' \
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'
Related on TokRepo
- AI Gateway Providers — Portkey deep-dive and comparisons
- AI Tools for API — API management and LLM routing tools
Key considerations
When evaluating Portkey AI Gateway for your workflow, consider the following factors. First, assess whether your team has the technical prerequisites to adopt this tool effectively. Second, evaluate the maintenance burden against the productivity gains. Third, check community activity and documentation quality to ensure long-term viability. Integration with your existing toolchain matters more than feature count alone. Start with a small pilot project before rolling out across the organization. Monitor resource usage during the initial adoption phase to identify bottlenecks early. Document your configuration decisions so team members can onboard independently.
Common pitfalls
- Self-hosted gateway requires proper network configuration to reach all LLM provider endpoints.
- Caching aggressive prompts may return stale responses; configure cache TTL based on your use case.
- Guardrails add latency; profile your specific guardrail combination to ensure acceptable response times.
常见问题
Portkey routes to over 250 LLMs from providers including OpenAI, Anthropic, Google, Mistral, Cohere, and many more. The provider list is updated regularly.
Semantic caching returns cached responses for queries that are semantically similar (not just identical). This saves tokens and latency for repeated or similar requests without requiring exact prompt matching.
Configure a primary and backup provider. If the primary returns an error or times out, Portkey automatically retries with the backup provider. You define the fallback chain in your configuration.
The gateway is open-source under Apache 2.0 and free to self-host. Portkey also offers a managed cloud service with additional features like analytics dashboards and team management.
The gateway adds sub-1ms latency overhead for routing. Guardrails and caching may add additional time depending on configuration. For most applications, the overhead is negligible compared to LLM inference time.
引用来源 (3)
- Portkey Gateway GitHub— Routes to 250+ LLMs with sub-1ms latency
- Portkey Official Site— 40+ guardrails, retries, fallbacks, and caching
- Portkey GitHub— 11.1K+ stars, Apache 2.0 licensed
来源与感谢
Portkey-AI/gateway — 11,100+ GitHub stars
讨论
相关资产
Apache ShenYu — High-Performance Extensible API Gateway
Apache ShenYu is a Java-native API gateway with a plugin-based architecture supporting HTTP, gRPC, WebSocket, MQTT, and Dubbo protocols for microservice traffic management.
AxonHub — Open-Source AI Gateway Platform
AxonHub is an Apache-2.0 AI gateway with routing, failover, and trace viewing, letting you keep your SDK while centralizing keys, logs, and model config.
LLM Gateway Comparison — Proxy Your AI Requests
Compare top LLM gateway and proxy tools for routing AI requests. Covers LiteLLM, Bifrost, Portkey, and OpenRouter for cost optimization, failover, and multi-provider access.
Tyk — Open Source API Gateway with Developer Portal
Tyk is a Go-based API gateway with plugins, rate limiting, OAuth2/OIDC, GraphQL federation, and a built-in developer portal — packaged as a single binary or full Kubernetes operator.