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

# OpenClaw

> Connect the OpenClaw personal AI assistant to FortAPI

[OpenClaw](https://github.com/openclaw/openclaw) is a personal AI assistant you run on your own devices, accessible via Telegram, WhatsApp, Discord, Signal, iMessage, and more. It supports many model providers — FortAPI plugs in via either the **Anthropic-compatible** or **OpenAI-compatible** protocol.

## Prerequisites

<Steps>
  <Step title="FortAPI account + API key">
    Console → **Tokens** → **Create token**. See [API keys & security](/en/authentication).
  </Step>

  <Step title="Node.js ≥ 18">
    ```bash theme={null}
    node --version
    ```

    Install from [nodejs.org](https://nodejs.org) if missing.
  </Step>

  <Step title="OS">
    Native macOS and Linux. On Windows, use **WSL2**.
  </Step>
</Steps>

## Install OpenClaw

```bash theme={null}
npm install -g openclaw@latest
```

Confirm:

```bash theme={null}
openclaw --version
```

## Configure FortAPI

OpenClaw uses the Anthropic SDK under the hood, so the simplest setup is **`ANTHROPIC_BASE_URL`** + **`ANTHROPIC_API_KEY`** env vars plus a model selection in `~/.openclaw/openclaw.json`.

### Method 1: env + config file (recommended)

<Steps>
  <Step title="Run onboarding to create the config directory">
    ```bash theme={null}
    openclaw onboard
    ```

    Walk through the wizard. When it asks for a model provider, pick anything (e.g. Anthropic API key) with a placeholder key — you'll overwrite it next. This step exists to create `~/.openclaw/` and the initial config.
  </Step>

  <Step title="Edit openclaw.json">
    Open `~/.openclaw/openclaw.json` (create if missing) and set:

    ```json5 theme={null}
    {
      env: {
        ANTHROPIC_BASE_URL: "https://www.fortapi.com",
        ANTHROPIC_API_KEY: "sk-your-FortAPI-token",
      },
      agents: {
        defaults: {
          model: { primary: "anthropic/your-model-name" }, // see the pricing page on the main site for available model names
        },
      },
    }
    ```

    <Warning>
      Don't append `/v1` to `ANTHROPIC_BASE_URL`.
    </Warning>
  </Step>

  <Step title="Restart the gateway">
    If you installed it as a daemon:

    ```bash theme={null}
    openclaw onboard --install-daemon
    ```

    Or start it manually:

    ```bash theme={null}
    openclaw gateway:start
    ```
  </Step>
</Steps>

### Method 2: shell env vars

If you'd rather not edit the config file, set the vars in your shell:

<Tabs>
  <Tab title="macOS / Linux">
    Add these to `~/.zshrc` or `~/.bashrc`:

    ```bash theme={null}
    export ANTHROPIC_BASE_URL="https://www.fortapi.com"
    export ANTHROPIC_API_KEY="sk-your-key"
    ```

    Then `source` the file or open a new terminal.
  </Tab>

  <Tab title="WSL2">
    Same as above — edit `~/.bashrc` inside your WSL distro.
  </Tab>
</Tabs>

You still need `agents.defaults.model` in `openclaw.json`, otherwise OpenClaw will prompt you to pick a model on every run.

## First call

Send one message:

```bash theme={null}
openclaw agent --message "Say hi in one English sentence" --local
```

You should get a reply, and the FortAPI Console → **Logs** should show a `claude-sonnet` (or whatever you set) call.

Once you've wired up Telegram / Discord / etc., messages on those channels will route through FortAPI too.

## Choosing a different model

Edit `~/.openclaw/openclaw.json`:

```json5 theme={null}
{
  agents: {
    defaults: {
      model: { primary: "anthropic/your-model-name" }, // see the pricing page on the main site for available model names
    },
  },
}
```

OpenClaw uses `<provider>/<model-id>` naming, e.g. `anthropic/your-model-name`. Replace `your-model-name` with any model name from the pricing page on the main site.

Full list on the [Pricing page](https://www.fortapi.com).

## Troubleshooting

<AccordionGroup>
  <Accordion title="401 Unauthorized">
    * `ANTHROPIC_API_KEY` must be your **FortAPI** token (`sk-...`), not Anthropic's official key.
    * Confirm the key is enabled and the model is in any allowlist via FortAPI Console → **Tokens**.
  </Accordion>

  <Accordion title="404 / model not found">
    * The model ID must include the `anthropic/` prefix, e.g. `anthropic/your-model-name`.
    * Don't add `/v1` to `ANTHROPIC_BASE_URL`.
  </Accordion>

  <Accordion title="`openclaw onboard` hangs or spins">
    * Check connectivity: `curl -I https://www.fortapi.com`.
    * Cancel onboarding (Ctrl+C) and hand-edit `~/.openclaw/openclaw.json` — the next start will use that file.
  </Accordion>

  <Accordion title="Configure multiple providers for failover">
    OpenClaw's `models.providers` config supports fallback chains. Get FortAPI working first, then layer fallbacks per the [OpenClaw configuration docs](https://docs.openclaw.ai/gateway/configuration).
  </Accordion>

  <Accordion title="Use the OpenAI-compatible protocol instead">
    Define a custom provider in `openclaw.json`:

    ```json5 theme={null}
    {
      models: {
        providers: {
          fortapi: {
            api: "openai",
            baseUrl: "https://www.fortapi.com/v1",
            apiKey: "sk-your-key",
            models: ["your-model-name"], // see the pricing page on the main site for available model names
          },
        },
      },
      agents: {
        defaults: { model: { primary: "fortapi/your-model-name" } }, // see the pricing page on the main site for available model names
      },
    }
    ```
  </Accordion>
</AccordionGroup>

## Advanced: channels

OpenClaw's main value is "use Claude via your messaging app." With FortAPI configured, wire up Telegram / Discord / Signal per the [OpenClaw channels docs](https://docs.openclaw.ai/channels) — model calls route through FortAPI automatically.
