Skip to content

fix(providers): add Moonshot (Global) provider for api.moonshot.ai endpoint#839

Merged
hazeone merged 1 commit intoValueCell-ai:mainfrom
octo-patch:fix/issue-822-moonshot-global-endpoint
Apr 13, 2026
Merged

fix(providers): add Moonshot (Global) provider for api.moonshot.ai endpoint#839
hazeone merged 1 commit intoValueCell-ai:mainfrom
octo-patch:fix/issue-822-moonshot-global-endpoint

Conversation

@octo-patch
Copy link
Copy Markdown
Contributor

Fixes #822

Problem

The Moonshot provider only supports the Chinese endpoint (api.moonshot.cn/v1). API keys issued for the international endpoint (api.moonshot.ai/v1) get rejected because requests are sent to the wrong host, resulting in auth errors for international users.

Solution

Added a separate moonshot-global provider entry pointing to https://api.moonshot.ai/v1, following the same CN/Global split pattern already used by MiniMax (minimax-portal / minimax-portal-cn).

Changes:

  • electron/shared/providers/registry.ts: New moonshot-global provider entry with api.moonshot.ai/v1 base URL and its own env var (MOONSHOT_GLOBAL_API_KEY)
  • electron/utils/provider-keys.ts: Added OPENCLAW_PROVIDER_KEY_MOONSHOT_GLOBAL constant
  • electron/utils/openclaw-auth.ts: Updated upsertMoonshotWebSearchConfig to accept a providerKey and baseUrl parameter; ensureMoonshotKimiWebSearchCnBaseUrl now handles both CN and Global providers with correct endpoints
  • src/lib/providers.ts: Added moonshot-global to PROVIDER_TYPES and BUILTIN_PROVIDER_TYPES, plus UI metadata entry
  • src/assets/providers/index.ts: Mapped moonshot-global to the existing moonshot SVG icon

Testing

  • TypeScript type check passes: pnpm exec tsc -p tsconfig.json --noEmit
  • Provider store validation tests pass: pnpm exec vitest run tests/unit/provider-store-validation.test.ts
  • International Moonshot API keys can now be configured using the new "Moonshot (Global)" provider entry

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67fd7d8532

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

},
},
{
id: 'moonshot-global',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add moonshot-global to shared provider type lists

This new provider ID is registered here, but electron/shared/providers/types.ts still omits 'moonshot-global' from PROVIDER_TYPES/BUILTIN_PROVIDER_TYPES (lines 1-28), which backend code treats as the source of truth. In ProviderService.buildAccountsFromOpenClawEntries (electron/services/providers/provider-service.ts:161-163), that causes models.providers['moonshot-global'] entries to be classified as custom, so later key derivation/sync uses a custom-... runtime key instead of moonshot-global; users with config-seeded accounts can end up with mis-typed accounts and writes going to the wrong provider key.

Useful? React with 👍 / 👎.

@hazeone
Copy link
Copy Markdown
Contributor

hazeone commented Apr 13, 2026

LGTM

@hazeone hazeone merged commit 5482acd into ValueCell-ai:main Apr 13, 2026
5 checks passed
DigitalNomad-Chat added a commit to DigitalNomad-Chat/ClawX that referenced this pull request Apr 26, 2026
…ueCell-ai#810 ValueCell-ai#839 ValueCell-ai#897 ValueCell-ai#907)

Add DeepSeek provider, Moonshot Global endpoint, update Kimi to k2.6,
fix API key validation trimming.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add international Moonshot endpoint (api.moonshot.ai) as provider option

2 participants