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

# OpenClaw

> Use the LeanMCP AI Gateway with OpenClaw

# OpenClaw Integration

[OpenClaw](https://github.com/openclaw/openclaw) is an open-source personal AI assistant that you run on your own devices and talk to through the messaging apps you already use. You can configure it to route its Claude API calls through the LeanMCP AI Gateway for monitoring, cost tracking, and content filtering.

## About OpenClaw

OpenClaw is an open-source personal AI assistant created by Austrian developer Peter Steinberger as a playground project in late 2025 , originally released under the name Clawdbot and briefly renamed Moltbot before settling on OpenClaw in late January 2026 after trademark concerns from Anthropic's legal team over the original "Clawd" pun on "Claude" . Rather than living in a browser tab, OpenClaw runs locally on your machine and answers you on channels you already use like WhatsApp, Telegram, Slack, Discord, Google Chat, Signal, iMessage, Microsoft Teams, Matrix, LINE, and many more , with persistent memory stored in local Markdown files, a skills system, scheduled wakeups, and integrations for browser control, voice, and canvas rendering. The project went viral almost immediately: it drew 2 million visitors in a single week  shortly after launch, reached around 247,000 stars and 47,700 forks on GitHub by early March 2026 , and surpassed 250,000 stars on March 3, 2026, overtaking React to become one of the fastest-growing projects in GitHub history . In February 2026, Steinberger announced he was joining OpenAI and that OpenClaw would move to a foundation to stay open and independent , and the project continues to ship weekly releases driven by its community.

## Monitoring OpenClaw with LeanMCP

Because OpenClaw makes its Claude calls through a standard Anthropic-compatible client, you can point it at the LeanMCP AI Gateway instead of the Anthropic API directly. Every request then flows through LeanMCP, where it gets logged, scanned for sensitive data, attributed to a user, and counted against your spending limits — without changing anything about how you talk to your assistant from Discord, Telegram, or WhatsApp.

## Prerequisites

<Steps>
  <Step title="Enable Billing">
    Before anything else, sign in at [app.leanmcp.com](https://app.leanmcp.com) and enable billing on your account. Until billing is enabled, gateway requests will be rejected even if you have an API key. Add a payment method and top up credits from the Billing section of the dashboard.
  </Step>

  <Step title="Create an API Key">
    Create an API key at [app.leanmcp.com/api-keys](https://app.leanmcp.com/api-keys) with **SDK** permissions. Your key will start with `leanmcp_`.
  </Step>

  <Step title="Install OpenClaw">
    If you don't already have OpenClaw running, install it and run the onboarding wizard:

    ```bash theme={null}
        npm install -g openclaw@latest
        openclaw onboard --install-daemon
    ```
  </Step>
</Steps>

## Configuration

### Environment Variables

Point OpenClaw at the LeanMCP AI Gateway by setting the Anthropic environment variables on the host running the OpenClaw gateway:

```bash theme={null}
# AI Gateway Configuration (instead of direct Anthropic)
ANTHROPIC_API_KEY=leanmcp_your_api_key_here
ANTHROPIC_BASE_URL=https://aigateway.leanmcp.com/v1/anthropic
```

Add these to `~/.openclaw/.env` (or your shell profile) and restart the gateway:

```bash theme={null}
openclaw gateway
```

### Configuration File

If you prefer to configure OpenClaw via its config file rather than environment variables:

```json theme={null}
{
  "anthropic": {
    "apiKey": "leanmcp_your_api_key_here",
    "baseUrl": "https://aigateway.leanmcp.com/v1/anthropic"
  }
}
```

## How It Works

```
Discord / Telegram / WhatsApp / iMessage user message
        |
        v
    OpenClaw (local gateway on your machine)
        |
        v
  LeanMCP AI Gateway  <-- Logs request, checks for sensitive data, enforces limits
        |
        v
   Anthropic API
        |
        v
  Claude Response
        |
        v
  Reply on the originating channel
```

## Benefits for OpenClaw Users

<CardGroup cols={2}>
  <Card title="User Monitoring" icon="users">
    Track which messaging users are talking to your assistant and how much
  </Card>

  <Card title="Cost Control" icon="dollar-sign">
    Set spending limits to prevent runaway costs from heavy usage or loops
  </Card>

  <Card title="Content Filtering" icon="filter">
    Block sensitive prompts before they reach Claude
  </Card>

  <Card title="Usage Analytics" icon="chart-bar">
    Understand how OpenClaw is being used across all your channels
  </Card>
</CardGroup>

## Adding Per-User Tracking

OpenClaw runs across many channels. To attribute usage to the right person and channel, attach identifying headers when OpenClaw calls the Anthropic SDK:

```javascript theme={null}
const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  messages: messages,
}, {
  headers: {
    'X-User-ID': message.author.id,
    'X-Channel': 'discord', // or telegram, whatsapp, imessage, ...
    'X-Server-ID': message.guild?.id,
  }
});
```

This enables per-user usage tracking, per-user limits, and the ability to block specific users from your dashboard.

## Verifying the Setup

1. Restart your OpenClaw gateway after changing environment variables.
2. Send a message to your assistant on any connected channel (Discord, Telegram, WhatsApp, etc.).
3. Open the [LeanMCP Dashboard](https://app.leanmcp.com) and confirm the request appears in the logs.

## Setting Up Rate Limits

Protect your assistant from runaway loops or abusive users:

```javascript theme={null}
await leanmcp.gateway.setRateLimit({
  scope: 'per_user',
  limits: {
    requestsPerMinute: 5,
    requestsPerHour: 50,
    tokensPerDay: 100000,
  }
});
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Assistant not responding">
    * Check that the OpenClaw gateway daemon is running (`openclaw status`)
    * Verify your LeanMCP API key is valid and billing is enabled
    * Tail the gateway logs for errors
  </Accordion>

  <Accordion title="API errors">
    * Ensure the base URL ends with `/v1/anthropic` (no trailing slash)
    * Verify your API key starts with `leanmcp_`
    * Confirm billing is enabled and you have remaining credits at [app.leanmcp.com](https://app.leanmcp.com)
  </Accordion>

  <Accordion title="Requests not showing in dashboard">
    * Confirm OpenClaw is actually using the custom base URL (check the env vars inside the running process)
    * Restart the gateway after configuration changes
    * Make sure you're looking at the same workspace in the dashboard that owns the API key
  </Accordion>
</AccordionGroup>

## Resources

* [OpenClaw GitHub Repository](https://github.com/openclaw/openclaw)
* [OpenClaw Website](https://openclaw.ai/)
* [OpenClaw Documentation](https://docs.openclaw.ai/)

## Next Steps

<CardGroup cols={2}>
  <Card title="Set Up Alerts" icon="bell" href="/ai-gateway/security">
    Get notified of unusual usage
  </Card>

  <Card title="Optimize Costs" icon="chart-pie" href="/ai-gateway/token-optimization">
    Reduce token usage
  </Card>
</CardGroup>
