快速开始
推断
inferrs 在兼容 OpenAI 的 /v1 API 后面提供本地模型。OpenClaw 通过通用的 openai-completions 适配器与它通信。
| 属性 | 值 |
|---|---|
| 提供商 ID | inferrs(自定义;在 models.providers.inferrs 下配置) |
| 插件 | 无 — 不是内置的 OpenClaw 提供商插件 |
| 认证环境变量 | 不需要;如果你的 inferrs 服务器没有认证,任何值都可以 |
| API | 兼容 OpenAI(openai-completions) |
| 建议基础 URL | http://127.0.0.1:8080/v1(或你的 inferrs 服务器监听的任何位置) |
入门指南
使用模型启动 inferrs
inferrs serve google/gemma-4-E2B-it \ --host 127.0.0.1 \ --port 8080 \ --device metal验证服务器可访问
curl http://127.0.0.1:8080/healthcurl http://127.0.0.1:8080/v1/models添加 OpenClaw 提供商条目
添加一个显式提供商条目,并将你的默认模型指向它。请参阅下面的配置示例。
完整配置示例
本地 inferrs 服务器上的 Gemma 4:
{ 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, }, }, ], }, }, },}按需启动
只有在选择 inferrs/... 模型时,OpenClaw 才能自行启动 inferrs。将 localService 添加到同一个提供商条目中:
{ 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, }, 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, }, }, ], }, }, },}command 必须是绝对路径。在 Gateway 网关主机上运行 which inferrs 并使用该路径。完整字段参考:本地模型服务。
高级配置
为什么 requiresStringContent 很重要
某些 inferrs Chat Completions 路由只接受字符串形式的 messages[].content,不接受结构化内容片段数组。
Gemma 和工具 schema 注意事项
某些 inferrs + Gemma 组合可以接受小型直接 /v1/chat/completions 请求,但会在完整的 OpenClaw agent-runtime 轮次中失败。请先尝试禁用工具 schema 表面:
compat: { requiresStringContent: true, supportsTools: false}这会降低对更严格本地后端的提示词压力。如果很小的直接请求仍然可用,但普通 OpenClaw agent 轮次持续在 inferrs 内部崩溃,请将其视为上游模型/服务器限制,而不是 OpenClaw 传输问题。
手动冒烟测试
配置完成后测试两层:
curl http://127.0.0.1:8080/v1/chat/completions \ -H 'content-type: application/json' \ -d '{"model":"google/gemma-4-E2B-it","messages":[{"role":"user","content":"What is 2 + 2?"}],"stream":false}'openclaw infer model run \ --model inferrs/google/gemma-4-E2B-it \ --prompt "What is 2 + 2? Reply with one short sentence." \ --json如果第一个命令可用但第二个失败,请参阅下面的故障排查。
代理式行为
因为 inferrs 使用通用 openai-completions 适配器(而不是 openai-responses),所以仅原生 OpenAI 可用的请求整形永远不会应用:不会发送 service_tier、Responses store、提示词缓存提示,也不会发送 OpenAI reasoning-compat 载荷整形。
故障排查
curl /v1/models 失败
inferrs 未运行、不可访问,或没有绑定到你配置的主机/端口。确认服务器已启动并在该地址上监听。
messages[].content 预期为字符串
在模型条目中设置 compat.requiresStringContent: true(见上文)。
直接 /v1/chat/completions 调用通过,但 openclaw infer model run 失败
设置 compat.supportsTools: false 以禁用工具 schema 表面(参见上面的 Gemma 注意事项)。
inferrs 在较大的 agent 轮次中仍然崩溃
如果 schema 错误已经消失,但 inferrs 仍然在较大的 agent 轮次中崩溃,请将其视为上游 inferrs 或模型限制。降低提示词压力,或切换后端/模型。