Skip to content

[Bug]: Moonshot CN users get 401 after onboard — models.json uses api.moonshot.ai instead of api.moonshot.cn #32607

@xww0911

Description

@xww0911

Bug type

Behavior bug (incorrect output/state without crash)

Summary

Hi~
After running openclaw setup and choosing Moonshot CN as the provider, the agent immediately fails with HTTP 401: Invalid Authentication.

I Tried to find the reason, the root cause: openclaw.json correctly stores baseUrl: "https://api.moonshot.cn/v1", but ~/.openclaw/agents/main/agent/models.json gets baseUrl: "https://api.moonshot.ai/v1" (the international endpoint). Since CN API keys don't work on the international endpoint, all requests return 401.

The issue is in buildMoonshotProvider() in src/agents/models-config.providers.ts — it hardcodes MOONSHOT_BASE_URL (api.moonshot.ai) and resolveImplicitProviders() calls it without passing the user's configured baseUrl.

Workaround: Manually edit ~/.openclaw/agents/main/agent/models.json and change api.moonshot.ai to api.moonshot.cn.

Steps to reproduce

1.openclaw setup
2.Choose Moonshot → Moonshot CN endpoint
3.Enter a CN API key (from platform.moonshot.cn)
4.Try chatting with the agent
5.Actual: run error: HTTP 401: Invalid Authentication

Expected behavior

Agent responds normally

Actual behavior

Agent responds normally

OpenClaw version

Version: 2026.3.1

Operating system

Mac mini m4, macOS Sequoia 15.7.4 (24G517), Node 22.14.0

Install method

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions