> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.openmodels.market/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.openmodels.market/_mcp/server.

# OpenClaw

![OpenClaw logo](/_fern-files/_img/3d4021262adf0fafd8ac958df269577b97a641a42a7a18f2b51bc21e3d6fcfc1.webp)

Use OpenModels as the upstream model provider for OpenClaw. OpenClaw keeps control of the local Gateway, sessions, channels, tools, and dashboard, while model requests are sent through the OpenModels OpenAI-compatible API.

This guide focuses on OpenClaw calling OpenModels. If you want another app to call OpenClaw's own `/v1` endpoint, see "Use OpenClaw as an OpenAI-compatible endpoint" below.

## When to use this

Use this setup when you want:

* OpenClaw as a self-hosted assistant gateway for chat apps, agents, and local tools.
* OpenModels as the upstream model marketplace.
* One OpenModels API key with credit-based billing and model IDs from the Models page.
* OpenAI-compatible chat completions without changing OpenClaw source code.

## Prerequisites

* OpenClaw installed on the host that runs the Gateway.
* Node.js 24, or Node.js 22.19 or later.
* An OpenModels API key in the `ale-...` format.
* Available credits in your OpenModels account.
* A supported OpenModels chat model ID, such as `qwen3.5-flash` or `kimi-k2.7-code`.

## 1. Install and start OpenClaw

On macOS or Linux:

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
openclaw onboard --install-daemon
openclaw gateway status
openclaw dashboard
```

The local OpenClaw dashboard usually runs at:

```text
http://127.0.0.1:18789/
```

## 2. Prepare your OpenModels key

Create an API key in the OpenModels dashboard and keep it outside source control:

```bash
export OM_API_KEY="ale-your-api-key"
```

For a long-running OpenClaw daemon, put the key somewhere the daemon can read. OpenClaw supports daemon env files, so a simple local setup can use:

```bash
mkdir -p ~/.openclaw
printf 'OM_API_KEY=ale-your-api-key\n' >> ~/.openclaw/.env
```

Do not commit real `ale-...` keys to an application repository.

## 3. Add OpenModels as a provider

OpenClaw model references use this shape:

```text
provider/model
```

Use `openmodels` as the provider ID and put the OpenModels model ID after the slash.

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

```json5
{
  models: {
    mode: "merge",
    providers: {
      openmodels: {
        baseUrl: "https://api.getopenmodels.com/v1",
        api: "openai-completions",
        apiKey: "ale-your-api-key",
        models: [
          {
            id: "qwen3.5-flash",
            name: "qwen3.5-flash",
            input: ["text"],
            contextWindow: 1000000,
            maxTokens: 8192
          },
          {
            id: "kimi-k2.7-code",
            name: "kimi-k2.7-code",
            input: ["text"],
            contextWindow: 256000,
            maxTokens: 8192
          }
        ]
      }
    }
  },
  agents: {
    defaults: {
      model: {
        primary: "openmodels/qwen3.5-flash",
        fallbacks: ["openmodels/kimi-k2.7-code"]
      },
      models: {
        "openmodels/qwen3.5-flash": { alias: "Qwen Flash" },
        "openmodels/kimi-k2.7-code": { alias: "Kimi Code" }
      }
    }
  }
}
```

If you already have `models` or `agents` config, merge the keys above instead of replacing the whole file. The `apiKey` value in the example is a placeholder. For production, prefer OpenClaw's secrets or env mechanism. If you write a key directly into `openclaw.json`, make sure the file is readable only by the local user.

OpenClaw validates config strictly. If the Gateway does not start after the edit, run:

```bash
openclaw doctor
openclaw doctor --fix
```

## 4. Restart and verify

Restart the Gateway:

```bash
openclaw gateway restart
```

Check that the provider and model are visible:

```bash
openclaw models list --provider openmodels
openclaw models set openmodels/qwen3.5-flash
openclaw models status
```

Then send a message in the dashboard or a connected chat channel. OpenClaw should use the selected OpenModels-backed model.

## 5. Switch models in a session

Switch to another OpenModels model:

```text
/model openmodels/kimi-k2.7-code
```

Return to the configured default:

```text
/model default
```

If OpenClaw reports that the model is not allowed, add the matching `openmodels/<model-id>` entry to `agents.defaults.models` or remove the allowlist.

## Use OpenClaw as an OpenAI-compatible endpoint

This is the reverse direction: another app calls OpenClaw, then OpenClaw runs its configured agent.

When enabled, the OpenClaw Gateway can expose an OpenAI-compatible endpoint:

```text
http://127.0.0.1:18789/v1
```

For Open WebUI or another trusted local app:

| Field    | Value                         |
| -------- | ----------------------------- |
| Base URL | `http://127.0.0.1:18789/v1`   |
| API key  | OpenClaw Gateway bearer token |
| Model    | `openclaw/default`            |

Keep these URLs separate:

* Use `https://api.getopenmodels.com/v1` when an app calls OpenModels directly.
* Use `http://127.0.0.1:18789/v1` when an app calls your local OpenClaw Gateway.
* In OpenClaw's `/v1` endpoint, the OpenAI `model` field selects an OpenClaw agent target such as `openclaw/default`. Backend provider or model overrides belong in OpenClaw config or the `x-openclaw-model` header.

Do not expose OpenClaw's `/v1` endpoint directly to the public internet. A valid Gateway token is an operator-level credential for that Gateway.

## Troubleshooting

| Symptom                                             | Check                                                                           |
| --------------------------------------------------- | ------------------------------------------------------------------------------- |
| OpenModels returns `401` or invalid key             | Confirm `apiKey` is a valid `ale-...` key and the key still exists              |
| Balance or billing failure                          | Add credits to the OpenModels account before sending requests                   |
| `Model is not allowed`                              | Add `openmodels/<model-id>` to `agents.defaults.models`, or clear the allowlist |
| Gateway does not start                              | Run `openclaw doctor` and inspect the strict config validation error            |
| The session keeps using the old model               | Run `/model default`, or start a new session without a pinned model             |
| OpenClaw `/v1/models` only shows `openclaw/default` | That endpoint returns OpenClaw agent targets, not raw OpenModels model IDs      |

## References

* [OpenClaw Getting started](https://docs.openclaw.ai/start/getting-started)
* [OpenClaw Configuration](https://docs.openclaw.ai/gateway/configuration)
* [OpenClaw custom providers and base URLs](https://docs.openclaw.ai/gateway/config-tools#custom-providers-and-base-urls)
* [OpenClaw OpenAI chat completions](https://docs.openclaw.ai/gateway/openai-http-api)
* [OpenModels Quickstart](/docs/get-started/quickstart)
* [OpenModels Models](/docs/models-pricing/models)