# OpenClaw

OpenClaw, a multi-channel AI gateway. See the [OpenClaw documentation](https://docs.openclaw.ai) for its current Node and dependency requirements before installing, since those change independently of this page.

## Install OpenClaw

```
npm install -g openclaw
openclaw --version
```

## Register the provider

Add IFM under `models.providers`. Pass the block as strict JSON and merge it so the rest of the config is left alone:

```
export IFM_API_KEY="sk-ifm-..."

openclaw config set models.providers.ifm '{
  "baseUrl": "https://api.ifm.ai/v1",
  "apiKey": { "source": "env", "provider": "default", "id": "IFM_API_KEY" },
  "api": "openai-completions",
  "models": [{ "id": "IFM/K2-Horizon-375B-A23B", "name": "K2 Horizon 375B",
               "input": ["text"], "contextWindow": 512000, "maxTokens": 32000,
               "reasoning": true }]
}' --strict-json --merge
```

The command reports `Updated models.providers.ifm`. If it asks you to restart the gateway, do so.

| Field | Meaning |
| --- | --- |
| baseUrl | The OpenAI-compatible root — `https://api.ifm.ai/v1` for the hosted API, or your own server's address when self-hosting. |
| apiKey | A secret reference, not a literal key: `{"source":"env","provider":"default","id":"IFM_API_KEY"}` reads the value from the environment at request time. |
| api | Wire protocol. Use `openai-completions`. |
| models | One entry per model you intend to call — `id`, a display `name`, `input` modalities, `contextWindow`, and `maxTokens`. |
| reasoning | Set to `true`. Without it, OpenClaw discards the model's reasoning between turns and the next request is rejected. |
| compat | Keep `requiresStringContent: true` and `thinkingFormat: "openrouter"`. Together they make OpenClaw send message text in the format IFM expects and return the model's reasoning on later turns. |

The `apiKey.provider` field names a registered _secret_ provider — use `"default"`. It is a separate namespace from the model-provider id, so `"provider": "ifm"` fails with `Secret provider "ifm" is not configured`.

## Run a request

Call the model by its ID:

```
openclaw infer model run --local \
  --model "IFM/K2-Horizon-375B-A23B" \
  --prompt "Count the .txt files in the current directory."
```

For a conversation, use the agent command and reuse the same `--session-id` to continue it:

```
openclaw agent --local --session-id my-chat \
  --model "IFM/K2-Horizon-375B-A23B" -m "Your message"
```

## Gateway and TUI

The `--local` commands above run without a gateway. For the interactive terminal UI, start the gateway, set IFM as the default model, then open the TUI in a second terminal.

### 1. Start the gateway

Start it from the shell where `IFM_API_KEY` is exported, because the key is read from the gateway's environment.

```
export IFM_API_KEY="sk-ifm-..."
openclaw gateway

# in another terminal: confirm it is running
openclaw gateway status
```

### 2. Set the default model

```
openclaw models set "IFM/K2-Horizon-375B-A23B"
openclaw gateway restart
```

### 3. Open the TUI

```
openclaw tui
```

The TUI connects to the running gateway. Type `/model` to confirm or switch the active model.

If the TUI reports that it can't reach the gateway, check `openclaw gateway status`. If requests fail with a missing-secret error, restart the gateway from a shell where `IFM_API_KEY` is set. See [OpenClaw documentation](https://docs.openclaw.ai) for daemon install and remote gateways.

## Self-hosting

Serve the model with vLLM 0.30.0 or later. Take the GPU and parallelism flags for your hardware from the [vLLM recipe](https://recipes.vllm.ai/IFM/K2-Horizon-375B-A23B), and keep the flags below:

```
vllm serve IFM/K2-Horizon-MoVA-36B-A4B \
  --trust-remote-code \
  --reasoning-parser k2_horizon \
  --enable-auto-tool-choice --tool-call-parser k2_horizon \
  --chat-template-content-format string
```

Then register the provider as above with `baseUrl` set to your server, for example `http://<host>:8000/v1`. The model id stays `IFM/K2-Horizon-375B-A23B`, because vLLM serves the model under the name it was started with. If you start it from a local path, add `--served-model-name IFM/K2-Horizon-375B-A23B`.

## Notes

- Only `baseUrl` changes between the hosted API and a self-hosted server; a local server that needs no auth can drop `apiKey` entirely.
- `--chat-template-content-format string` is required.
- Models absent from the `models` array are rejected before a request is sent. Add an entry per model you plan to call.
- OpenClaw's built-in tools use the standard tool-calling schema; see [Custom function calling](https://docs.ifm.ai/docs/custom-function-calling.md).

_Last updated: October 15, 2026_
