For Moonshot/Kimi, HTTP 401: Invalid Authentication is almost always one of these:
- Using the wrong provider/key combo
- Moonshot K2 models are
moonshot/...and expectMOONSHOT_API_KEY - Kimi Coding models are
kimi-coding/...and expectKIMI_API_KEY
Keys are not interchangeable. Docs: https://docs.openclaw.ai/providers/moonshot
- Wrong endpoint
- International:
https://api.moonshot.ai/v1 - China:
https://api.moonshot.cn/v1
If your key was created for the CN endpoint but you’re hitting.ai(or vice versa), you’ll get 401.
- Gateway service not actually loading the new key
If you updated an env var in your shell but the gateway runs as a service, it likely won’t inherit it. Put the key in~/.openclaw/.env(on the gateway host) or in the configenv: { ... }, thenopenclaw gateway restart.
To pinpoint which one it is, can you paste (no secrets) the output of: