> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipellm.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenClaw

> 通过 custom provider 将 OpenClaw 接到 PipeLLM

路由规则请参考 [路由与协议](/guides/routing-protocols.zh)。模型 ID 请参考
[列出模型](/api-reference/list-models.zh)。

OpenClaw 支持在 `~/.openclaw/openclaw.json` 里配置 custom provider。接 PipeLLM
时，覆盖面最广、也最简单的方案，是使用 OpenAI 兼容 custom provider 指向
PipeLLM 的 OpenAI converter 路由。

## 推荐路由

```text theme={null}
https://api.pipellm.ai/openai/v1
```

如果你明确希望使用 Anthropic Messages 语义，OpenClaw 也可以改成
`https://api.pipellm.ai/anthropic`，并把 `api` 设置为
`"anthropic-messages"`。

## 最快接法

直接用 onboarding 向导：

1. 运行 `openclaw onboard`
2. 选择 `Custom Provider`
3. 选择 `OpenAI-compatible`
4. Base URL 填 `https://api.pipellm.ai/openai/v1`
5. 粘贴你的 PipeLLM API Key
6. 输入模型 ID，例如 `claude-sonnet-4-6`、`gpt-4o` 或 `gemini-2.5-pro`

## 手动配置

OpenClaw 使用 JSON5，所以允许注释和尾随逗号。

```json5 theme={null}
{
  env: {
    PIPELLM_API_KEY: "your-pipellm-api-key",
  },
  agents: {
    defaults: {
      model: {
        primary: "pipellm/claude-sonnet-4-6",
      },
      models: {
        "pipellm/claude-sonnet-4-6": {
          alias: "Claude Sonnet 4.6",
        },
        "pipellm/gpt-4o": {
          alias: "GPT-4o",
        },
        "pipellm/gemini-2.5-pro": {
          alias: "Gemini 2.5 Pro",
        },
      },
    },
  },
  models: {
    mode: "merge",
    providers: {
      pipellm: {
        api: "openai-completions",
        baseUrl: "https://api.pipellm.ai/openai/v1",
        apiKey: "${PIPELLM_API_KEY}",
        models: [
          { id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
          { id: "gpt-4o", name: "GPT-4o" },
          { id: "gemini-2.5-pro", name: "Gemini 2.5 Pro" },
        ],
      },
    },
  },
}
```

## 说明

* `model.primary` 在 OpenClaw 里使用 `provider/model` 这种格式。
* `models.providers.<id>.api` 决定协议适配器。对于 PipeLLM 的推荐接法，使用
  `openai-completions`。
* 如果你后面要切到 Anthropic 兼容路由，把 provider 改成
  `api: "anthropic-messages"`，并把 `baseUrl` 改成
  `https://api.pipellm.ai/anthropic` 即可。

## 相关文档

<Columns cols={4}>
  <Card title="开发工具" icon="terminal" href="/integrations/overview.zh">
    查看当前支持的编码助手
  </Card>

  <Card title="OpenAI 转换器" icon="shuffle" href="/converter/openai-format.zh">
    保留 OpenAI 兼容格式，跨 provider 调用模型
  </Card>

  <Card title="WebSearch npm 包" icon="box" href="/websearch/npm-package.zh">
    给 OpenClaw 增加 PipeLLM WebSearch 工具
  </Card>

  <Card title="OpenClaw 配置文档" icon="book" href="https://docs.openclaw.ai/gateway/configuration-reference">
    官方 OpenClaw 配置参考
  </Card>
</Columns>
