inferrs 是一个本地模型服务器,通过 OpenAI 兼容 /v1 API 提供服务。OpenClaw 通过自定义 provider 配置接入,不是内置 provider 插件。

属性值
Provider IDinferrs(自定义,配置在 models.providers.inferrs)
插件无内置插件
APIOpenAI 兼容(openai-completions)
建议 Base URLhttp://127.0.0.1:8080/v1

如需内置插件和自动发现,请参考 provider-sglang 或 provider-vllm。

快速开始

# 启动 inferrs 服务器
inferrs serve google/gemma-4-E2B-it \
  --host 127.0.0.1 \
  --port 8080 \
  --device metal
 
# 验证服务器
curl http://127.0.0.1:8080/health
curl http://127.0.0.1:8080/v1/models

完整配置示例

{
  agents: {
    defaults: {
      model: { primary: "inferrs/google/gemma-4-E2B-it" },
      models: {
        "inferrs/google/gemma-4-E2B-it": { alias: "Gemma 4 (inferrs)" },
      },
    },
  },
  models: {
    mode: "merge",
    providers: {
      inferrs: {
        baseUrl: "http://127.0.0.1:8080/v1",
        apiKey: "inferrs-local",
        api: "openai-completions",
        models: [
          {
            id: "google/gemma-4-E2B-it",
            name: "Gemma 4 E2B (inferrs)",
            reasoning: false,
            input: ["text"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 131072,
            maxTokens: 4096,
            compat: { requiresStringContent: true },
          },
        ],
      },
    },
  },
}

按需启动

通过 localService 配置让 OpenClaw 在需要时自动启动 inferrs:

{
  models: {
    providers: {
      inferrs: {
        baseUrl: "http://127.0.0.1:8080/v1",
        apiKey: "inferrs-local",
        api: "openai-completions",
        timeoutSeconds: 300,
        localService: {
          command: "/opt/homebrew/bin/inferrs",
          args: ["serve", "google/gemma-4-E2B-it", "--host", "127.0.0.1", "--port", "8080", "--device", "metal"],
          healthUrl: "http://127.0.0.1:8080/v1/models",
          readyTimeoutMs: 180000,
          idleStopMs: 0,
        },
      },
    },
  },
}

command 必须为绝对路径,使用 which inferrs 获取。

兼容性注意

  • 若报错 messages[].content: invalid type: sequence, expected a string,设置 compat.requiresStringContent: true
  • 若工具调用失败,尝试 compat.supportsTools: false 禁用工具 schema

相关链接