模型提供商 • 5 分钟阅读
OpenRouter
在 OpenClaw 中使用 OpenRouter:一个 API Key 访问多种模型
OpenRouter 提供一个 <strong>统一的 API</strong>:用同一个 endpoint 和 API Key,把请求路由到多种模型。它兼容 OpenAI API,因此多数 OpenAI SDK 只需切换 base URL 就能工作。
Tutorial.step
CLI 设置
Bash
openclaw onboard --auth-choice apiKey --token-provider openrouter --token "$OPENROUTER_API_KEY"
Tutorial.step
配置片段
Json5
{
env: { OPENROUTER_API_KEY: "sk-or-..." },
agents: {
defaults: {
model: { primary: "openrouter/anthropic/claude-sonnet-4-5" },
},
},
}Tutorial.step
备注
- Model ref format is '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'openrouter/<provider>/<model>'</code>'.
- 更多可选模型/提供商,见 '<a href="/concepts/model-providers" className="text-emerald-400 hover:text-emerald-300 transition-colors">'/concepts/model-providers'</a>'。
- OpenRouter 底层会用你的 API Key 作为 Bearer token 发送请求。