# OpenClaw

[OpenClaw](https://docs.openclaw.ai) is an open-source personal AI assistant that can be deployed locally or remotely. It connects to chat apps such as Telegram, Discord, Feishu (Lark), DingTalk, and QQ, so you can call the agent directly from the chat apps you use every day. OpenClaw supports custom OpenAI-compatible, OpenAI Responses-compatible, and Anthropic-compatible APIs.

## 1. Get an API Key

Open the [API Keys](https://beeroute.ai/keys) page, click **Create API Key**, set **Group** to `default`, and copy the key (it starts with `sk-`).

!> Do not use a key from the `ClaudeCode` group: that group can only be used in the Claude Code client, and requests from OpenClaw will be rejected.

## 2. Install OpenClaw

**macOS / Linux / WSL2:**

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```

**Windows PowerShell:**

```powershell
iwr -useb https://openclaw.ai/install.ps1 | iex
```

The install script automatically installs the required Node.js and starts the setup wizard. You can also install it with npm (requires Node.js 24.16 or later): `npm install -g openclaw@latest`.

Verify the installation:

```bash
openclaw --version
```

## 3. Option 1: Add BeeRoute in the Setup Wizard

Run the setup wizard (it opens automatically at the end of the install script):

```bash
openclaw onboard
```

1. At the step where you choose a model provider, select **More…**, then select **Custom Provider**.
2. Fill in the fields as prompted:

| Wizard field | Value |
| :--- | :--- |
| Base URL | `https://beeroute.ai/v1` |
| API key | Your BeeRoute key `sk-xxx` |
| Compatibility | OpenAI-compatible |
| Model ID | For example, `claude-sonnet-5-5`. See the [Pricing](https://beeroute.ai/modellist/) page for all model IDs |

3. The wizard sends a real request to verify the settings. Once verification passes, it saves the configuration. Follow the prompts to complete the remaining steps.

You can also do this with a single command (useful on servers):

```bash
openclaw onboard --non-interactive --accept-risk \
  --auth-choice custom-api-key \
  --custom-provider-id beeroute \
  --custom-base-url "https://beeroute.ai/v1" \
  --custom-model-id "claude-sonnet-5-5" \
  --custom-api-key "sk-xxx" \
  --custom-compatibility openai
```

## 4. Option 2: Edit the Configuration File Directly

The configuration file is `~/.openclaw/openclaw.json` (on Windows, `%USERPROFILE%\.openclaw\openclaw.json`; when running inside WSL, `~/.openclaw/openclaw.json` within WSL). Change the `models` and `agents` sections to the following (leave the rest of the file unchanged), and replace `sk-xxx` with your key:

```json
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "beeroute/claude-sonnet-5-5"
      }
    }
  },
  "models": {
    "mode": "merge",
    "providers": {
      "beeroute": {
        "baseUrl": "https://beeroute.ai/v1",
        "apiKey": "sk-xxx",
        "api": "openai-completions",
        "models": [
          {
            "id": "claude-sonnet-5-5",
            "name": "Claude Sonnet 5.5",
            "input": ["text", "image"],
            "contextWindow": 200000,
            "maxTokens": 32000,
            "compat": { "supportsUsageInStreaming": true }
          },
          {
            "id": "gpt-6.2-sol",
            "name": "GPT-6.2 Sol",
            "input": ["text", "image"],
            "compat": { "supportsUsageInStreaming": true }
          },
          {
            "id": "deepseek-flash",
            "name": "DeepSeek Flash",
            "compat": { "supportsUsageInStreaming": true }
          }
        ]
      }
    }
  }
}
```

| Field | Description |
| :--- | :--- |
| `agents.defaults.model.primary` | Default model, in the format `provider-id/model-id` |
| `models.mode` | `merge` adds your providers alongside the built-in ones without overwriting the built-in configuration |
| `baseUrl` | Must include `/v1` |
| `apiKey` | The key. You can also write `"${BEEROUTE_API_KEY}"` to read it from an environment variable |
| `api` | `openai-completions` means the OpenAI Chat Completions format |
| `models[].id` | The model ID on BeeRoute (case-sensitive) |
| `compat.supportsUsageInStreaming` | Lets OpenClaw get usage statistics in streaming requests. Recommended |

`contextWindow` and `maxTokens` are parameters OpenClaw uses to control context length. Adjust them to match each model's actual capabilities.

?> The gateway watches the configuration file and reloads changes automatically. If a change does not take effect, run `openclaw gateway restart` to restart the background gateway service.

## 5. Verify

Open the OpenClaw gateway UI (it opens in your browser automatically when the wizard finishes), or send a message in a connected chat app. If you get a normal reply, the connection works.

## 6. Advanced: Use the Native Anthropic Format (Optional)

If you want Claude models to use the native Anthropic Messages format, set **Compatibility** to **Anthropic-compatible** in the wizard, set Base URL to `https://beeroute.ai`, and enter the Model ID manually (Anthropic-compatible mode does not fetch the model list automatically).

## 7. FAQ

**Wizard verification fails with 401 or 403?**

Check that the key was copied completely and that you are using a `default` group key.

**Logs show `returned no token usage`?**

Add `"compat": { "supportsUsageInStreaming": true }` to the model configuration.

**Model not found?**

`models[].id` must match the BeeRoute model ID exactly.

For more settings, see the official OpenClaw documentation: [Custom providers](https://docs.openclaw.ai/gateway/config-tools/custom-providers).
