#Need help with the Json config

1 messages · Page 1 of 1 (latest)

fervent furnace
#

I have been banging my head on this for hours, and I'm not sure what I'm doing wrong. I have a VPS running openclaw in a container (hostinger). I'm just trying to get it hooked up to grok. My config snippet is below:

"xai": {

"baseUrl": "https://api.grok.x.ai/v1",
      "apiKey": "redacted",
      "models": [
        {
          "id": "grok-4-1-fast-reasoning",
          "name": "Grok 4.1 Fast Reasoning",
          "alias": "Grok 4.1 Fast Reasoning",
          "reasoning": true,
          "input": ["text", "image"],
          "maxTokens": 8192,
          "contextWindow": 200000
        }
      ]
    }

weary viperBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

acoustic willowBOT
#

That snippet won’t work as-is because OpenClaw doesn’t read a top-level "xai": { ... } block. Provider config lives under models.providers, and xAI is also a built-in provider, so in most cases you don’t need any provider block at all.

Option A (recommended): use the built-in xai provider

  1. Make sure the key is available to the gateway process (container env var is easiest):
  • XAI_API_KEY=...
  1. Set your default model to an xAI model ref (provider/model), e.g.:
{
env: { XAI_API_KEY: "sk-..." }, // or set it in docker env instead
agents: {
defaults: { model: { primary: "xai/<model-id>" } }
}
}

To avoid guessing the model id, run on the VPS/container and paste output:

#
openclaw --version
openclaw models list | grep -i xai
openclaw models status --probe --probe-provider xai

Docs: https://docs.openclaw.ai/concepts/model-providers

Option B: if you must use https://api.grok.x.ai/v1 + a custom model id

Define a custom provider (note: provider goes under models.providers, and alias belongs under agents.defaults.models, not inside the provider’s models[] entry):

{
env: { XAI_API_KEY: "sk-..." },

models: {
#
mode: "merge",
providers: {
grok: {
baseUrl: "https://api.grok.x.ai/v1",
apiKey: "${XAI_API_KEY}",
api: "openai-completions",
models: [
{
id: "grok-4-1-fast-reasoning",
name: "Grok 4.1 Fast Reasoning",
reasoning: true,
input: ["text", "image"],
maxTokens: 8192,
contextWindow: 200000
}
#
]
}
}
},

agents: {
defaults: {
model: { primary: "grok/grok-4-1-fast-reasoning" },
models: {
"grok/grok-4-1-fast-reasoning": { alias: "Grok 4.1 Fast Reasoning" }
}
}
}
}
fervent furnace
#

How about this. What do I need to do assuming I start from scratch with a fresh container and the Xai environmental variable added? I'm happy to use the built in provider.

acoustic willowBOT
#

If you’re starting totally fresh and you already have XAI_API_KEY in the container env, the simplest path is: run the onboarding wizard, then pick an xai/... model. You don’t need any "xai": { ... } config block.

1) Start from the official Docker flow (recommended)

Docs: https://docs.openclaw.ai/install/docker

On the VPS:

git clone https://github.com/openclaw/openclaw.git
cd openclaw

# make sure the gateway containers will see this:
export XAI_API_KEY="sk-...your-key..."

./docker-setup.sh

That script will:

#
  • build the image
  • run openclaw onboard
  • write config/workspace on the host under ~/.openclaw/
  • start the gateway with docker compose

2) Pick an xAI model (built-in provider)

Inside the docker setup, run (from the repo root):

docker compose run --rm openclaw-cli openclaw models list | grep -i xai

Then set your default model to one of the xai/<model-id> entries you see:

docker compose run --rm openclaw-cli openclaw models set xai/<model-id>

Verify the key + provider works with a live probe:

#
docker compose run --rm openclaw-cli openclaw models status --probe --probe-provider xai

3) Bring up the gateway + open dashboard

docker compose up -d openclaw-gateway
docker compose logs -f openclaw-gateway

If you need the dashboard URL/token again:

docker compose run --rm openclaw-cli openclaw dashboard --no-open

#

If you paste:

  • openclaw --version
  • the output of openclaw models status --probe --probe-provider xai (or the error)

…I can tell you exactly what step is failing.

fervent furnace
#

Sorry, this is a one click deploy container through Hostinger

acoustic willowBOT
#

All good — in a one‑click Hostinger container you usually can’t rely on docker-setup.sh / compose, so treat it like: “set env vars + drop an openclaw.json into the container (ideally on persistent storage) + restart”.

What you need for built-in xAI (Grok)

1) Set env var(s) in Hostinger

In the Hostinger one‑click deploy UI, add an environment variable:

  • XAI_API_KEY = <your key>

(Optional but useful if you want a non-default config location)

  • OPENCLAW_CONFIG_PATH = /data/openclaw.json (or whatever path is persisted in your container)

2) Create the config file (JSON5)

OpenClaw config is JSON5 and defaults to ~/.openclaw/openclaw.json unless you set OPENCLAW_CONFIG_PATH.

Minimal config to force Grok as the default model:

#
{
agents: {
defaults: {
model: {
primary: "xai/<pick-from-openclaw-models-list>"
}
}
}
}

Important: with the built-in xai provider, you do not add any models.providers.xai block.

3) Pick the correct xai/... model id

Because model ids change over time, don’t guess. In the container, run:

#
openclaw models list | grep -i xai

Then put one of those exact ids into agents.defaults.model.primary.

4) Restart the container / gateway

After the env var + config are in place, restart the container so the gateway reloads cleanly.

5) Verify it’s actually seeing the key

Run (redact anything sensitive when pasting output):

openclaw models status --probe --probe-provider xai

Two quick questions (so I can tailor to Hostinger’s UI)

#
  1. Do you have a way to exec into the container / open a terminal? If yes, we’ll use the openclaw models list / status --probe commands above.
  2. Does Hostinger give you a persistent volume/path (like /data)? If not, any config you edit inside the container may disappear on redeploy, so we should point OPENCLAW_CONFIG_PATH at the persisted path.

If you tell me what paths Hostinger persists (or screenshot the storage/env-var section), I’ll tell you exactly where to put openclaw.json.

fervent furnace
#

Thanks!