Skip to content

在 OpenClaw 中使用 imrouter

准备信息

先在 imrouter 用户控制台准备:

  • 一把 API Key
  • 一个可用的模型 ID
  • 充足的余额(免费模型除外)

添加自定义模型供应商

在 OpenClaw 配置中添加一个 OpenAI-compatible provider。以下示例使用环境变量保存 API Key;把 your-model-id 替换为控制台中的模型 ID

json5
{
  agents: {
    defaults: {
      model: { primary: "imrouter/your-model-id" }
    }
  },
  models: {
    mode: "merge",
    providers: {
      imrouter: {
        baseUrl: "https://www.imrouter.com/api/v1",
        apiKey: "${IMROUTER_API_KEY}",
        api: "openai-completions",
        models: [
          { id: "your-model-id", name: "imrouter model" }
        ]
      }
    }
  }
}

在启动 OpenClaw 的环境中设置 Key:

bash
export IMROUTER_API_KEY="sk-your-key"

重启 OpenClaw 后选择或使用 imrouter/your-model-id。如果出现 401,检查 API Key;如果提示模型不可用,重新从 imrouter 模型目录复制模型 ID

OpenClaw 的配置格式可能随版本更新,其他配置项请以 OpenClaw 自定义供应商文档 为准

imrouter 文档