OpenRouter 免费模型路由:一条 API Key 用 300+ 模型
> "OpenRouter is the Swiss Army knife of LLM APIs. One key, 300+ models, automatic fallback. And the free tier actually works — I've been running my side project on openrouter/free for 3 months without spending a dime." — u/api_explorer, Reddit r/ChatGPTCoding, 2026
引言
如果你只能选一个免费 API 方案,我推荐 OpenRouter。它不是模型提供商,而是一个模型路由层 — 用一条 API Key 访问 300+ 模型,包括免费模型和付费模型。它的 openrouter/free 端点聚合了多个来源的免费模型,遇到限流或错误会自动 fallback。
Reddit r/ChatGPTCoding 上大量开发者把 OpenRouter 作为首选 API 网关。YouTube 上也有多个教程(播放量超过 20 万)介绍如何使用 OpenRouter 的免费通道。
---
具体步骤:配置 OpenRouter 免费 API
第一步:注册 OpenRouter
访问 openrouter.ai,用 Google/GitHub 账号登录。2026 年支持 Passkey 无密码登录。
不需要信用卡。免费层完全不需要绑定支付方式。
第二步:生成 API Key
在 Keys 页面创建 Key。OpenRouter 支持多种 Key 类型:
- Standard Key:正常访问所有模型
- Free Key:只能访问免费模型
- Custom Key:限制特定模型和额度
建议先用 Standard Key,然后用 Free Key 控制预算。
第三步:了解免费模型
2026 年 openrouter/free 端点的可用免费模型:
| 模型 | 提供商 | 特点 |
|---|---|---|
| Llama 3.3 70B | Various | 高质量通用 |
| Mistral 7B | Mistral | 轻量快速 |
| Phi-3 Medium | Microsoft | 推理能力强 |
| Gemma 2 9B | 轻量高效 | |
| Qwen 2.5 7B | Alibaba | 中文优秀 |
| DeepSeek V2 Lite | DeepSeek | 极低成本 |
免费模型列表经常变动,建议定期查看 OpenRouter 的 Models 页面。
第四步:Python 调用
from openai import OpenAI
client = OpenAI(
api_key="sk-or-xxx", # OpenRouter API Key
base_url="https://openrouter.ai/api/v1"
)
response = client.chat.completions.create(
model="openrouter/free", # 自动路由到可用的免费模型
messages=[
{"role": "user", "content": "解释一下OpenRouter的免费路由机制"}
],
max_tokens=512,
# 可选:添加引用信息
extra_headers={
"HTTP-Referer": "https://myapp.com",
"X-Title": "MyApp"
}
)
print(response.choices[0].message.content)
# 查看实际用了哪个模型
print(f"使用的模型: {response.model}")
第五步:自动 Fallback 配置
OpenRouter 最强大的功能是自动 fallback。如果一个模型返回错误,会自动尝试下一个:
# 手动指定 fallback 列表
response = client.chat.completions.create(
model="openrouter/auto", # auto 模式
messages=[{"role": "user", "content": "Hello"}],
# 指定 fallback 顺序
models=[
"meta-llama/llama-3.3-70b-instruct:free",
"microsoft/phi-3-medium:free",
"google/gemma-2-9b-it:free"
]
)
第六步:监控用量
OpenRouter 提供详细的用量仪表盘,包括:
- 每个模型的请求次数
- 总消耗 token 数
- 延迟统计
- 错误率分析
---
curl 示例
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer sk-or-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "openrouter/free",
"messages": [
{"role": "user", "content": "Hello, who are you?"}
]
}'
---
够干什么?实际场景建议
| 场景 | 推荐配置 | 说明 |
|---|---|---|
| 学习测试 | openrouter/free | 零成本试各种模型 |
| Side Project MVP | openrouter/auto + fallback | 自动切换保证可用 |
| 多模型对比 | 手动指定 model 参数 | 同时测试不同模型 |
| 生产环境 | 付费模型 + 免费 fallback | 高可用低成本 |
| 代理/转发 | OpenRouter API 做统一网关 | 管理团队的 API 调用 |
OpenRouter 的最大价值是灵活性。你可以在一个接口下测试 300+ 模型,找到最适合你场景的模型后,再切换到直接使用该模型提供商的 API。
---
2026 年现状与变化
- 免费模型数量减少但质量提升:2026 年 OpenRouter 淘汰了一些低质量免费模型,但增加了 Llama 3.3 70B 和 Phi-3 Medium
- Rate Limit 收紧:免费层从 500 RPD 降到 200 RPD
- 新功能:模型评分:用户可以给模型打分,帮助其他人选择
- 创业计划:符合条件的初创公司可以申请 $1000 免费额度
- 隐私模式:2026 年新增,请求不会用于训练
---
交叉引用
- 用 OpenRouter 免费跑 Claude Code — 经典用法
- Groq 免费 API — 其中一些免费模型通过 Groq 提供
- 全部薅一遍:20 家免费 API 额度叠加 — OpenRouter 作为总网关
- 免费 API 的坑与避雷指南 — 注意数据隐私设置
---
数据来源
- OpenRouter 官网 (openrouter.ai)
- Reddit r/ChatGPTCoding, "OpenRouter free tier guide" 帖子
- YouTube, "How to Use OpenRouter Free Models" 教程
- OpenRouter 官方文档