Skip to content

fix(provider): correct moonshot-cn domestic provider for China-based Kimi/Moonshot users#8856

Closed
bugmaker2 wants to merge 1 commit into
NousResearch:mainfrom
bugmaker2:fix/kimi-cn-endpoint-v2
Closed

fix(provider): correct moonshot-cn domestic provider for China-based Kimi/Moonshot users#8856
bugmaker2 wants to merge 1 commit into
NousResearch:mainfrom
bugmaker2:fix/kimi-cn-endpoint-v2

Conversation

@bugmaker2

@bugmaker2 bugmaker2 commented Apr 13, 2026

Copy link
Copy Markdown

What does this PR do?

Add a dedicated moonshot-cn domestic direct API provider for Kimi/Moonshot users in mainland China who register at platform.moonshot.cn. The existing kimi-coding provider continues to serve global users at api.moonshot.ai.

This resolves the issue where China-based users were getting 401 authentication errors out-of-the-box because the default endpoint (api.moonshot.ai) only accepts keys from platform.moonshot.ai.

Related Issue

Fixes #8096

Type of Change

  • ✨ New feature (non-breaking change that adds functionality)

Changes Made

  • hermes_cli/auth.py: Add moonshot-cn ProviderConfig with domestic endpoint https://api.moonshot.cn/v1 and MOONSHOT_CN_API_KEY environment variable; add moonshot-chinamoonshot-cn alias
  • hermes_cli/config.py: Add MOONSHOT_CN_API_KEY and MOONSHOT_CN_BASE_URL environment variable definitions; update fallback model docs
  • hermes_cli/models.py: Add moonshot-cn model list, display label, and alias; add to provider order list
  • hermes_cli/setup.py: Add moonshot-cn provider and model list to interactive setup
  • hermes_cli/providers.py: Add HermesOverlay for moonshot-cn with openai_chat transport
  • hermes_cli/doctor.py: Add moonshot-cn health check entry
  • hermes_cli/status.py: Add moonshot-cn to API key provider status display
  • hermes_cli/main.py: Add moonshot-cn to provider labels and --provider choices
  • agent/auxiliary_client.py: Add moonshot-cn auxiliary model mapping
  • agent/model_metadata.py: Add moonshot-cn to provider prefixes
  • agent/models_dev.py: Add moonshot-cn models.dev registry mapping
  • hermes_cli/model_normalize.py: Add moonshot-cn to prefix-strip providers
  • cli-config.yaml.example and .env.example: Document the new provider

How to Test

  1. Run hermes setup and select Kimi / Moonshot (China) as the provider
  2. Enter a API key from platform.moonshot.cn
  3. Select a model (e.g. kimi-k2.5) and verify the chat works — no 401 errors
  4. Run hermes doctor and confirm the Kimi / Moonshot (China) status shows as configured
  5. Verify hermes status shows the domestic endpoint (api.moonshot.cn/v1)

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I've searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've tested on my platform: macOS

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I've searched for existing PRs
  • My PR contains only changes related to this fix/feature

Documentation & Housekeeping

  • I've updated .env.example and cli-config.yaml.example with the new provider
  • I've considered cross-platform impact

Screenshots / Logs

Issue #8096 root cause: The Kimi/Moonshot setup defaults to api.moonshot.ai/v1, but keys from platform.moonshot.cn only authenticate against api.moonshot.cn/v1. The fix adds a dedicated domestic provider so users can select the correct platform during setup.


Contributor: @bugmaker2

… users

Add a dedicated domestic direct API provider (moonshot-cn) for Kimi/Moonshot
users in mainland China who register at platform.moonshot.cn. The existing
kimi-coding provider continues to serve global users at api.moonshot.ai.

This resolves issue NousResearch#8096 where China-based users were getting 401 errors
out-of-the-box because the default endpoint (api.moonshot.ai) only accepts
keys from platform.moonshot.ai.

Changes:
- Add moonshot-cn ProviderConfig (https://api.moonshot.cn/v1, MOONSHOT_CN_API_KEY)
- Add moonshot-cn to provider registry, models, aliases, and setup flows
- Add moonshot-cn to health checks (doctor), status, and config examples
- Add moonshot-cn to provider overlays and model metadata

Closes NousResearch#8096

Made-with: Cursor
@bugmaker2 bugmaker2 changed the title feat: add moonshot-cn domestic provider for China-based Kimi/Moonshot users fix: correct moonshot-cn domestic provider for China-based Kimi/Moonshot users Apr 13, 2026
@bugmaker2 bugmaker2 changed the title fix: correct moonshot-cn domestic provider for China-based Kimi/Moonshot users fix(provider): correct moonshot-cn domestic provider for China-based Kimi/Moonshot users Apr 13, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #9172 which adds kimi-coding-cn as the provider name (consistent with existing kimi-coding). Your PR's coverage of doctor.py was incorporated into the salvage. Thank you for the contribution @bugmaker2!

@teknium1 teknium1 closed this Apr 13, 2026
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.

[Config issue]: Kimi/Moonshot provider defaults to wrong endpoint for China users

2 participants