三家定位差异
| 维度 | LiteLLM | OpenRouter | Portkey |
|---|---|---|---|
| 形式 | 开源库 + 自托管 | SaaS 平台 | SaaS / 自托管 |
| 手续费 | 0%(仅 VPS) | +5-10% | $99+/月 |
| 模型数 | 100+(手动接) | 300+ 自动 | 100+ 自动 |
| DX | 中(需配 yaml) | 极简(OpenAI 兼容) | 中(需 SDK) |
| Observability | 基础日志 | 基础 dashboard | ★★★★★ |
| 数据隔离 | ★★★★★ | ★★★ | ★★★★ |
| 运维 | 自己 | 不需要 | 不需要 |
| 目标客户 | 重度 / 自托管派 | Indie / SaaS | 企业团队 |
价格对比
| 方式 | input $/M | output $/M | 备注 |
|---|---|---|---|
| Anthropic 直连 | $15 | $75 | 需外卡 + 美国实体 |
| OpenRouter | $15.75 | $78.75 | +5%,免外卡 |
| Portkey | $15 | $75 + 月费 | $99/月起 |
| LiteLLM(自托管) | $15 | $75 + VPS | 自己接 |
| 商业中转站 | $5-10 | $25-40 | -30 至 -50% |
商业中转站价格最低(独立开发者用得起的 Claude 4.7 / GPT-5.5 中转)。
LiteLLM 实战
# 安装
pip install litellm
# 调用(OpenAI 兼容接口)
from litellm import completion
response = completion(
model="anthropic/claude-opus-4-7",
messages=[{"role": "user", "content": "Hello"}],
api_key=ANTHROPIC_API_KEY
)
print(response.choices[0].message.content)
自托管 proxy
# litellm_config.yaml
model_list:
- model_name: claude-opus
litellm_params:
model: anthropic/claude-opus-4-7
api_key: ${ANTHROPIC_API_KEY}
- model_name: gpt-5-5
litellm_params:
model: openai/gpt-5.5
api_key: ${OPENAI_API_KEY}
general_settings:
master_key: sk-1234
# 启动 proxy
litellm --config litellm_config.yaml --port 4000
# 客户端用
curl http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer sk-1234" \
-d '{"model": "claude-opus", "messages": [...]}'
OpenRouter 实战
// 完全 OpenAI 兼容
import OpenAI from 'openai'
const openai = new OpenAI({
baseURL: 'https://openrouter.ai/api/v1',
apiKey: process.env.OPENROUTER_KEY
})
const response = await openai.chat.completions.create({
model: 'anthropic/claude-opus-4-7',
messages: [{ role: 'user', content: 'Hello' }]
})
OpenRouter 优势
- 300+ 模型一站接(Claude / GPT / Gemini / Llama / Mistral / DeepSeek / Qwen)
- 自动 routing:选最便宜可用版本
- 模型 fallback:A 失败自动切 B
- 单一计费 + USD 充值
- 30 秒接入
Portkey 实战
import { Portkey } from 'portkey-ai'
const portkey = new Portkey({
apiKey: process.env.PORTKEY_KEY,
virtualKey: 'vk_anthropic_xxx' // 在 Portkey Dashboard 配
})
const response = await portkey.chat.completions.create({
model: 'claude-opus-4-7',
messages: [{ role: 'user', content: 'Hello' }],
config: {
cache: { mode: 'semantic' },
fallback: ['claude-sonnet-4-6'],
retry: { count: 3 }
}
})
Portkey 独家能力
- Semantic Caching(语义缓存,命中率 30-50%)
- PII 自动 detect + redact
- Prompt template 版本管理(A/B test)
- 按团队成员审计
- SOC2 + HIPAA 合规
indie 实战推荐
场景 A:MVP 阶段(0-100 用户)
推荐:OpenRouter
- 30 分钟接入
- 模型自由切换
- 单一账单
- $20-50 月预算够用
场景 B:增长阶段(100-1000 用户)
推荐:LiteLLM 自托管 + 商业中转站
- 降本 30-50%
- 数据完全隔离
- 自由路由策略
场景 C:团队 SaaS(1000+ 用户、多人协作)
推荐:Portkey 或自托管 LiteLLM + Sentry
- Observability 完整
- 团队协作
- 合规审计
场景 D:极致省钱 + 国内访问
推荐:商业中转站直接调用
- 价格降 30-50%
- 国内可访问
- 免外卡
如果你需要绕开外卡 + 模型选择灵活,最实操的做法是配独立开发者可用的 Claude / OpenAI API 中转作为应用的统一端点。配好后所有模型用同一个 API key、月预算可控。
性能实测
模拟 100 次 Claude Opus 4.7 调用:
| 网关 | 平均延迟 | P95 | 失败率 |
|---|---|---|---|
| Anthropic 直连(美国) | 1.5s | 3.2s | 0.2% |
| OpenRouter | 1.7s | 3.8s | 0.4% |
| Portkey | 1.6s | 3.5s | 0.3% |
| LiteLLM(self-host) | 1.6s | 3.5s | 0.5% |
| 商业中转(国内 IP) | 0.8s | 1.8s | 0.5% |
中转站在国内 IP 下延迟最低(因为节点在亚洲)。
迁移成本
| 从 → 到 | 难度 | 注意 |
|---|---|---|
| 直连 Anthropic → OpenRouter | 极低 | 仅改 baseURL |
| OpenRouter → Portkey | 低 | 加 virtualKey |
| 直连 → LiteLLM 自托管 | 中 | 部署 + 配 yaml |
| OpenRouter → 中转站 | 极低 | 仅改 baseURL |
OpenRouter / Portkey / 中转站都是 OpenAI 兼容协议,互相迁移 5 分钟。
跨境访问
LiteLLM / OpenRouter / Portkey Dashboard 在国内访问普遍稳定,但调用源 IP(如 Cloudflare Workers / Railway)对各家 LLM 后端的稳定性不同。
如果你需要稳定调用 Claude / GPT / Gemini 跨家 + 同时管 Stripe / Mercury / Wise,配一条主推 GPT-5.5 / Claude 4.7 的低价 API 中转能保证多模型调用 + 海外账户操作不中断,月预算降低 30-50%。