Fix OpenClaw Config Errors
Invalid JSON, unknown fields, wrong model IDs — how to diagnose and repair your OpenClaw configuration.
⚡ Quick Fix — Let AI Handle It
ClawAid reads your config, finds the exact error, and fixes it automatically:
npx clawaid
Auto-detects invalid fields, typos, wrong model IDs, and more. Free.
Symptoms
Symptom:
openclaw doctor reports config validation errors
Symptom: Gateway starts but every AI request returns HTTP 400 or 401
Symptom: Error: "Unexpected token in JSON" or "Cannot read config"
Symptom: OpenClaw worked before, you changed a setting, now nothing works
Common Config Problems
1. Invalid JSON Syntax
Cause: Missing comma, extra comma, unclosed bracket in
openclaw.json
Validate the JSON:
# Quick syntax check
python3 -c "import json; json.load(open('$HOME/.openclaw/openclaw.json'))"
# Or use jq
jq . ~/.openclaw/openclaw.json
Common mistakes:
- Trailing comma after the last item in an object:
{"key": "value",} - Missing quotes around keys or values
- Comments in JSON (JSON doesn't support
//or/* */)
2. Wrong Model ID → HTTP 400
Cause: The model string doesn't match what your provider expects
Every provider has its own model naming scheme:
# OpenAI
"openai/gpt-4o"
# Anthropic
"anthropic/claude-sonnet-4-6"
# OpenRouter (prefix with openrouter/)
"openrouter/anthropic/claude-sonnet-4-6"
# Google
"google/gemini-2.5-pro"
Fix it:
openclaw config set models.primary "openai/gpt-4o"
openclaw gateway restart
3. Invalid or Expired API Key
Cause: API key was rotated, expired, or copy-pasted with extra whitespace
# Test your key directly
curl -s https://api.openai.com/v1/models \
-H "Authorization: Bearer YOUR_KEY" | head -5
# Re-set the key (no extra spaces!)
openclaw config set providers.openai.apiKey "sk-..."
openclaw gateway restart
4. Unknown or Deprecated Fields
Cause: Old config fields from a previous OpenClaw version, or typos in field names
# Check what's valid
openclaw doctor
# The error message usually tells you which field is unrecognized
# Remove it manually or re-run setup
openclaw setup
5. Editing openclaw.json Directly (Risky)
Cause: Direct file edits bypass validation — easy to introduce errors
Always prefer the CLI:
# Instead of editing the file:
openclaw config set models.primary "openai/gpt-4o"
# Instead of guessing field names:
openclaw config get models
Nuclear Option: Reset Config
If nothing works, back up and start fresh:
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak
openclaw setup
Still Stuck?
🤖 ClawAid Handles Edge Cases Too
ClawAid reads your actual config file, cross-references it with your provider and model setup, and fixes the exact issue — even if it's a combination of problems.
npx clawaid
94% fix rate · Free · Open source