⚠️ 待更新·2026-08-29核验 · 更新时间待核验 · 本文信息可能已过期,请以官方文档为准
更新时间:2026-08-29 · 核验状态:待更新 · 官方溯源待补
简介
OpenRouter 是一个模型聚合网关,一个 Key 即可调用 300+ 模型,其中包括大量带 :free 后缀的免费模型。它统一了请求协议、计费与监控,适合做模型选型、多 provider 容灾或快速原型。本文演示完整申请流程并解读费率规则,把免费层与付费层的边界讲清楚。
flowchart TD
A["Sign Up at openrouter.ai"] --> B["Verify Account"]
B --> C["Add Payment Method"]
C --> D["Create API Key"]
D --> E["Test Key with curl"]
E --> F["Watch Credits / Quota"]
F --> G["Use in Production"]
注册账号
- 打开 https://openrouter.ai/,点击右上角 Sign In,使用 Google 或 GitHub 登录。
- 登录后访问 https://openrouter.ai/settings/keys,点击 Create Key。
- 给 Key 起名(如
dev-local),复制生成的 sk-or-v1-...,妥善保存——关闭弹窗后无法再次查看。
建议按用途建多把 Key(如 dev、ci、prod),出问题精准吊销,避免一把 Key 全家共用。OpenRouter 的 Key 不区分权限,但能按 Key 看 usage,分开建 Key 能让你看到哪条线被刷爆。
绑定支付方式
OpenRouter 的免费模型仍要求账户验证(防滥用):
- 进入 https://openrouter.ai/settings/credits,点击 Add Credits。
- 选信用卡或加密货币充值最低 $5(这 $5 是真金白银,可以用来跑付费模型)。
- 充值后账户升级为"已验证",
:free 模型不再触发 429。
注意:即使你只用 :free 模型,账户也必须验证一次。这是 OpenRouter 防机器人刷量的硬规则,无法绕过。
费率规则速读
OpenRouter 的计费分三层:
:free 模型:零成本,但受日请求数限制(每模型 50–200 req/day 不等,超限触发 429)。
- 付费按量模型:按 token 计费,价格从 $0.1/M 到 $5/M token 不等。Llama 3.3 70B 大约 $0.6/M,GPT-4o 类大约 $5/M。
- 按次模型(少数):按请求次数计费,不看 token 数。文档会显式标注。
:free 与付费版的区别不仅在钱,还在排队优先级——:free 在高峰期可能慢或返回 503,付费版基本稳定。所以做生产时,建议把免费模型设为主路由、付费模型设为 fallback。
测试 Key
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-chat:free",
"messages":[{"role":"user","content":"ping"}]
}'
返回 200 与一段 JSON 即说明 Key 可用。返回 401 检查 Key 拼写,402 说明账户未充值验证。
配额监控
OpenRouter 在 Dashboard 给出当日请求数与 token 消耗。要监控告警,调用:
curl https://openrouter.ai/api/v1/key \
-H "Authorization: Bearer $OPENROUTER_API_KEY"
返回 JSON 含 usage、limit、limit_remaining 三个字段,把它们抓到 Prometheus 或日志系统,配额到 70% 时告警。
生产建议
- 多 Key 隔离:每个客户端或环境一把 Key,吊销某条不影响其他。
- 免费 + 付费分层:把
:free 模型设为主路由,付费 key 设为 fallback;任何免费层突然收紧,路由自动降级。
- watchdog 兜底:每 5 分钟跑一次
/api/v1/key 看 limit_remaining,掉到阈值就切到备用 key。
- 日志全留:把每次调用的 model、prompt token 数、completion token 数落日志,事后对账容易。
走完这套流程,你就有了一个能从免费层一路滑到生产的多 provider 入口——账单从 0 开始,但随时能升级。
⚠️ Pending Update · 2026-08-29 Verification · Content may be outdated, please refer to official docs
Updated: 2026-08-29 · Status: Pending Verification
Introduction
OpenRouter is a model-aggregation gateway — a single key unlocks 300+ models, including many free ones marked with the :free suffix. It unifies the request protocol, billing, and monitoring across providers, making it ideal for model selection, multi-provider failover, or rapid prototyping. This article walks through the full application flow and decodes the pricing rules, with a clear boundary between free-tier and paid-tier behavior.
flowchart TD
A["Sign Up at openrouter.ai"] --> B["Verify Account"]
B --> C["Add Payment Method"]
C --> D["Create API Key"]
D --> E["Test Key with curl"]
E --> F["Watch Credits / Quota"]
F --> G["Use in Production"]
Account Registration
- Open https://openrouter.ai/, click Sign In in the top-right, and log in with Google or GitHub.
- After login, visit https://openrouter.ai/settings/keys and click Create Key.
- Name the key (e.g.
dev-local), copy the generated sk-or-v1-..., and store it securely — once the dialog closes you cannot view it again.
Best practice: create separate keys per use case (dev, ci, prod). OpenRouter keys do not have scoped permissions, but per-key usage is visible, so splitting keys tells you exactly which pipeline is burning quota.
Payment Method
Free models still require one-time account verification (anti-abuse):
- Visit https://openrouter.ai/settings/credits and click Add Credits.
- Top up at least $5 via card or crypto. The $5 is real money, usable on paid models.
- After top-up the account becomes "verified" —
:free models no longer return 429.
Note: even if you only intend to use :free models, the account must be verified once. This is OpenRouter's hard rule against bot abuse — there is no bypass.
Pricing Cheat Sheet
OpenRouter billing has three layers:
:free models: zero cost, but rate-limited to 50–200 requests per day per model (returning 429 when exceeded).
- Paid usage-based models: billed per token, from $0.1/M to $5/M. Llama 3.3 70B is about $0.6/M; GPT-4o-class runs around $5/M.
- Per-call models (a minority): billed per request, not per token. The docs mark these explicitly.
The gap between :free and paid is not just price — it is also queueing priority. :free may slow down or return 503 at peak; paid is stable. For production, treat free models as the primary route and paid as fallback.
Test the Key
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-chat:free",
"messages":[{"role":"user","content":"ping"}]
}'
A 200 with a JSON body means the key is good. 401 = key typo. 402 = account not verified (top up).
Quota Monitoring
OpenRouter's dashboard shows daily request count and token spend. To monitor programmatically:
curl https://openrouter.ai/api/v1/key \
-H "Authorization: Bearer $OPENROUTER_API_KEY"
The JSON contains usage, limit, and limit_remaining. Pipe these into Prometheus or your log stack, alert when remaining drops below 70%.
Production Tips
- Per-client key isolation: one key per client or environment; revoking one does not break the others.
- Free-first with paid fallback: set
:free as the primary route and a paid key as fallback. If a free tier tightens, routing degrades gracefully.
- Watchdog: poll
/api/v1/key every 5 min for limit_remaining; switch to the backup key when it crosses the threshold.
- Audit-grade logs: record model, prompt tokens, completion tokens for every call — makes reconciliation painless.
With this flow you have a multi-provider entry that scales from free tier to production — the bill starts at zero and can upgrade on demand.