That OpenAI error (401 Incorrect API key provided) usually means either the key is genuinely invalid/revoked or OpenClaw is not using the key you think it is (old env var wins, remote gateway, etc.). A couple important gotchas:
1) Make sure the key is on the Gateway host
OpenClaw sends model requests from the machine running openclaw gateway (or the installed service).
So if you’re running the TUI on your laptop but the Gateway is on a VPS, the key must be set on the VPS, not just locally.
2) OpenClaw will NOT override an existing OPENAI_API_KEY
Env precedence is “never override existing values”. If you have an old/bad OPENAI_API_KEY in your shell/service environment, putting a new one in config won’t replace it. Docs: https://docs.openclaw.ai/help/environment
Quick fix checklist
On the machine running the Gateway:
- Don’t paste your key here, but run:
openclaw --version
openclaw models status