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

# How to set up OpenClaw with Grok API key

> Use Agent 37 to connect OpenClaw to xAI and configure a Grok model for your hosted instance.

If you want to run OpenClaw with Grok, this guide walks you through the full setup inside Agent 37. You will create an xAI API key, open your hosted OpenClaw terminal, and configure Grok as the active model provider for your instance.

This page is based on the video walkthrough below and turns it into a written blog-style guide you can follow step by step.

## Video walkthrough

<iframe src="https://www.youtube.com/embed/-1aPtYoc55c" title="How to Setup OpenClaw with Grok API Key" frameborder="0" className="w-full aspect-video rounded-xl" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

<Info>
  **Before you begin**:

  * An active [Agent 37 account](https://www.agent37.com/dashboard)
  * A running OpenClaw instance in Agent 37
  * An [xAI account](https://docs.x.ai/developers/quickstart)
  * A valid xAI API key
</Info>

## Why use Grok with OpenClaw

Grok is a good option when you want to run OpenClaw on xAI models while keeping the same hosted Agent 37 workflow. Once your API key is ready, the setup is mostly a configuration change in the OpenClaw terminal.

## Step 1: Create your xAI API key

1. Open the [xAI getting started guide](https://docs.x.ai/developers/quickstart).
2. Sign in to your xAI account and open the API key section in the xAI Console.
3. Create a new API key for the account you want to use with OpenClaw.
4. Copy the key and store it somewhere safe.

<Warning>
  Keep this key private. Anyone with the key can consume usage on your xAI account.
</Warning>

## Step 2: Open your Agent 37 instance

1. Go to the [Agent 37 dashboard](https://www.agent37.com/dashboard).
2. Open the OpenClaw instance you want to configure.
3. Click **Terminal**.

You will complete the full Grok setup from the hosted Agent 37 terminal. You do not need to configure this on your local machine.

## Step 3: Start the OpenClaw configuration flow

In Terminal, run:

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

When prompted, choose:

1. **Where will the gateway run?** → `Local`
2. **Select Section to Configure?** → `Model`
3. **Model / Auth Provider** → `XAI`

## Step 4: Add your xAI API key

After selecting the provider:

1. Choose the xAI API key authentication option
2. Paste the API key you created in Step 1
3. Continue to the model picker

OpenClaw will save the credential to your instance configuration.

## Step 5: Select a Grok model

Choose the Grok model you want OpenClaw to use as the active model for this instance.

A common default choice is:

```text theme={null}
grok-4
```

xAI’s current docs describe `grok-4` as the stable alias for its flagship Grok model, so it is a sensible starting point if you want a general setup.

## Step 6: Verify the model is active

Run:

```bash theme={null}
openclaw models list
```

You should see the selected Grok model in the output.

If you want to switch models later, rerun `openclaw configure` or use the exact model identifier shown by OpenClaw in the model management commands.

## What this changes in Agent 37

Once setup is complete:

* your OpenClaw instance uses xAI as the configured provider
* your agent can use the selected Grok model for prompts and workflows
* you can keep using the same Agent 37 channels, tools, and hosted environment

## Common issues

If the setup does not work on the first try, check these first:

* the API key was copied correctly from xAI
* you selected `XAI` in `openclaw configure`
* the model name you picked is available on your xAI account
* the configuration flow finished without interruption
* your xAI account has available billing or credits if requests are rejected

If needed, rerun:

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

## Which Grok model should you choose

Start with `grok-4` if you want a stable default and you are not optimizing for a special edge case yet.

If your xAI account exposes newer aliases or dated variants, you can pick those later after you confirm the base setup works.

## What to do next

<CardGroup cols={2}>
  <Card title="Change default model" icon="refresh-cw" href="/docs/models/how-to-change-default-model-openclaw">
    Switch between configured model providers as your workflow changes.
  </Card>

  <Card title="OpenAI API" icon="sparkles" href="/docs/models/how-to-setup-openclaw-openai-api">
    Compare the Grok setup flow with the OpenAI provider flow.
  </Card>
</CardGroup>
