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

# OpenClaw

> Add RunInfra to OpenClaw while keeping existing providers available.

Add RunInfra to OpenClaw while keeping existing providers available.

Support level: `ready`. Connect supports automatic setup.

<Note>
  Check the active configuration path before connecting. If you use an OpenClaw profile, pass its directory to Connect through `OPENCLAW_STATE_DIR`. Keep the same path environment for `on` and `off`.
</Note>

## Connect OpenClaw

Have OpenClaw installed, a workspace API key, and available RunInfra credits.

```bash theme={"dark"}
npx @runinfra/connect openclaw
```

The bare agent command is an alias for `on`. In an interactive terminal, Connect starts login if needed. Review and approve the proposed changes. Connect saves a snapshot, writes the model settings, and makes a real Chat Completions request that uses credits.

To choose a model during setup:

```bash theme={"dark"}
npx @runinfra/connect openclaw on --model deepseek-v4-flash
```

See [Connect](/docs/tools-sdks/connect) for status, diagnostics, and key replacement.

## What Connect writes

Connect uses the first nonempty path setting in this order:

| Priority | Connect's configuration target             |
| -------- | ------------------------------------------ |
| 1        | `OPENCLAW_CONFIG_PATH`, the full file path |
| 2        | `OPENCLAW_STATE_DIR/openclaw.json`         |
| 3        | `OPENCLAW_HOME/.openclaw/openclaw.json`    |
| 4        | `~/.openclaw/openclaw.json`                |

Empty overrides are ignored. A leading `~` expands to your home directory. Connect refuses relative paths. Use an absolute path or a home-relative path beginning with `~`.

Check the file OpenClaw actually uses:

```bash theme={"dark"}
openclaw config file
```

For `--profile p1`, run Connect with `OPENCLAW_STATE_DIR` set to `~/.openclaw-p1`. More generally, `--profile <name>` uses `~/.openclaw-<name>`. Connect cannot see OpenClaw's profile flag. Use the same path environment for setup and disconnect.

Connect sets `models.mode` to `merge`. It adds `models.providers.runinfra` with `baseUrl: https://api.runinfra.ai/v1`, `apiKey`, `api: openai-completions`, and the catalog model list. Each model uses its exact `id`, `name`, reasoning support, `contextWindow`, and `maxTokens`, with `input: ["text"]`.

Connect selects `runinfra/<model-id>` through `agents.defaults.model.primary`. Existing providers remain available. Other settings, including `modelPolicy.allow`, stay unchanged.

### Key placement

Literal mode writes the key to `models.providers.runinfra.apiKey`. For an environment reference:

```bash theme={"dark"}
npx @runinfra/connect openclaw on --key-source helper
```

Helper mode writes `${RUNINFRA_API_KEY}`. Start OpenClaw with `RUNINFRA_API_KEY` in its actual process environment. A value exported in another terminal does not reach an already running process.

<Accordion title="Pass the helper key to the app">
  Export `RUNINFRA_API_KEY` with your RunInfra API key in the environment that launches the app. Restart GUI apps and background services with that environment.

  On Windows, set `RUNINFRA_API_KEY` in your user environment, then fully restart the app. GUI and Start menu launches do not receive a terminal-only `$env:RUNINFRA_API_KEY` value. Connect does not change your external environment.
</Accordion>

## Verify

OpenClaw 2026.9.2 on WSL completed a verified round trip on September 8, 2026, after Connect's config-path correction. With `OPENCLAW_STATE_DIR` set, Connect wrote the file reported by `openclaw config file`. Configuration validation passed. The local agent request succeeded with `stopReason: stop` and was confirmed in RunInfra usage.

Validate the active configuration:

```bash theme={"dark"}
openclaw config validate
```

If validation rejects pre-existing legacy keys such as `meta.lastTouchedAt` or `commands.ownerDisplay`, review the changes before letting OpenClaw migrate its own configuration:

```bash theme={"dark"}
openclaw doctor --fix
```

In an authorized isolated environment, run the follow-up command for `deepseek-v4-flash`. Connect prints it but does not execute it:

```bash theme={"dark"}
openclaw agent --local -m "Reply exactly RUNINFRA_OK. Do not use tools." --model runinfra/deepseek-v4-flash --json --timeout 120
```

The no-tools prompt is not a permission boundary. Confirm the selected model and request destination after choosing the active configuration file.

## Restart

Check the active OpenClaw provider and model. Restart OpenClaw if reload is disabled or fails. Start a new chat. A successful Connect API probe does not verify OpenClaw.

## Known behaviours

Connect edits JSON/JSONC only, not full JSON5. Still check reply routing after selecting the corrected file, reload behavior, helper credential resolution, and restoration after OpenClaw saves changes.

<Accordion title="Use OpenClaw's controls when Connect refuses JSON5">
  If Connect refuses JSON5 syntax or a structure it cannot rewrite safely, review the non-secret settings before applying them through this command:

  ```text theme={"dark"}
  openclaw config set
  ```

  Supply the reviewed setting and value yourself. Set `models.mode` to `merge`, `models.providers.runinfra.baseUrl` to `https://api.runinfra.ai/v1`, and `models.providers.runinfra.api` to `openai-completions`. Set `agents.defaults.model.primary` to `runinfra/<model-id>`.

  Use the catalog's exact model ids, names, reasoning support, context windows, and output limits for `models.providers.runinfra.models`. Connect uses `input: ["text"]`.

  Enter your API key through OpenClaw's **Control UI Settings > Models**. Keep a backup of manual changes. Do not put the key in command arguments.
</Accordion>

## Troubleshooting

| Symptom                                    | What to check                                                                                                               |
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
| OpenClaw reports an unknown RunInfra model | Compare `openclaw config file` with Connect's target. Check path precedence and the profile's `OPENCLAW_STATE_DIR`.         |
| Connect refuses a relative path            | Set the chosen override to an absolute path or use a leading `~`.                                                           |
| Validation rejects old configuration keys  | Review the legacy keys and use `openclaw doctor --fix` to let OpenClaw migrate them.                                        |
| Connect refuses JSON5                      | Use the reviewed non-secret settings with `openclaw config set` and enter the key through **Control UI Settings > Models**. |
| Helper authentication fails                | Check `RUNINFRA_API_KEY` in the actual OpenClaw process environment.                                                        |
| A chat retains its previous model          | Check the active provider and model. Restart if reload fails, then start a new chat.                                        |
| Normal `off` refuses changed bytes         | Review OpenClaw's saved changes before choosing `off --force`.                                                              |

## Revert

Keep the same path environment you used for `on`, including `OPENCLAW_STATE_DIR` for a profile:

```bash theme={"dark"}
npx @runinfra/connect openclaw off
```

In the recorded rerun, `off` restored the original absent-file state. With intact state and snapshots, `off` restores the original bytes from before the first `on` in the active connection. If the file did not exist then, Connect removes it. Later `on` calls and key rotations keep that restore point.

If OpenClaw or another editor changed the file, Connect refuses to overwrite it. Back up and review the edits before choosing to discard them:

```bash theme={"dark"}
npx @runinfra/connect openclaw off --force
```

Connect saves the current contents in a recovery snapshot and prints its id before restoring the origin. Keep the snapshots. Without the origin snapshot, credential cleanup does not remove the provider, model catalog, or primary selection. It does not guarantee original-byte restoration. See [Connect recovery](/docs/tools-sdks/connect#what-off-restores).

Restore manual environment changes yourself. Review changes made through OpenClaw's own controls separately.

## Related

<Columns cols={3}>
  <Card title="Connect" icon="plug" href="/docs/tools-sdks/connect">
    Set up, inspect, and restore your coding agent.
  </Card>

  <Card title="Chat completions" icon="braces" href="/docs/api-reference/chat-completions">
    Read the request contract.
  </Card>

  <Card title="Models" icon="list" href="/docs/api-reference/models">
    Find model ids and context windows.
  </Card>
</Columns>
