Skip to content

feat(providers): add Kimi / Moonshot China to Providers#7637

Closed
hcshen0111 wants to merge 2 commits into
NousResearch:mainfrom
hcshen0111:feat/kimi-coding-cn-provider
Closed

feat(providers): add Kimi / Moonshot China to Providers#7637
hcshen0111 wants to merge 2 commits into
NousResearch:mainfrom
hcshen0111:feat/kimi-coding-cn-provider

Conversation

@hcshen0111

@hcshen0111 hcshen0111 commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR adds first-class support for Moonshot China as a built-in provider by introducing kimi-coding-cn with a dedicated API key (KIMI_CN_API_KEY) and default China endpoint (https://api.moonshot.cn/v1).

It solves the current gap where China-region Moonshot usage required manual endpoint workarounds or conflicted with kimi-coding default routing.
This approach is low-risk and consistent with existing provider architecture: it reuses the existing OpenAI-compatible API-key provider path (no new adapter / api_mode), and wires the provider through auth, runtime resolution, CLI selection, model catalog, auxiliary routing, metadata inference, and docs.

Related Issue

Resolves #8825

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added new provider kimi-coding-cn in hermes_cli/auth.py
    • api_key_env_vars=("KIMI_CN_API_KEY",)
    • default inference_base_url="https://api.moonshot.cn/v1"
    • alias support: kimi-cn, moonshot-cn
  • Updated provider model metadata in hermes_cli/models.py
    • Added _PROVIDER_MODELS["kimi-coding-cn"]
    • Added _PROVIDER_LABELS["kimi-coding-cn"]
    • Added aliases and provider listing order
  • Wired provider into CLI flow in hermes_cli/main.py
    • Provider label/menu entry added
    • Included in API-key-provider flow dispatch
    • Added to chat --provider choices
  • Added env/config support in hermes_cli/config.py
    • Added KIMI_CN_API_KEY to OPTIONAL_ENV_VARS
    • Updated fallback/smart-routing provider comments
  • Updated auxiliary + metadata paths
    • agent/auxiliary_client.py: alias mapping + aux default model for kimi-coding-cn
    • agent/model_metadata.py: provider prefixes and URL-to-provider mapping for api.moonshot.cn
  • Updated docs/examples
    • .env.example
    • website/docs/reference/environment-variables.md
    • website/docs/user-guide/configuration.md
    • website/docs/getting-started/quickstart.md
  • Resolved merge-conflict markers in hermes_cli/auth.py during integration.

How to Test

  1. Configure env:
    • Set KIMI_CN_API_KEY in ~/.hermes/.env
    • (Optional) ensure KIMI_API_KEY is unset to avoid ambiguity during manual checks
  2. Verify provider wiring:
    • source venv/bin/activate
    • python -m hermes_cli.main chat -q "Say hello" --provider kimi-coding-cn --model kimi-k2.5
    • Confirm requests target https://api.moonshot.cn/v1
  3. Run provider regression tests:
    • source venv/bin/activate
    • python -m pytest tests/hermes_cli/test_api_key_providers.py tests/hermes_cli/test_runtime_provider_resolution.py -n0 -q

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I 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 run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Linux (RHEL-compatible kernel 4.19)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A (N/A: only .env provider key added)
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A (N/A)
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A (N/A)

For New Skills

N/A

Screenshots / Logs

Targeted test run:

python -m pytest tests/hermes_cli/test_api_key_providers.py tests/hermes_cli/test_runtime_provider_resolution.py -n0 -q
185 passed

@hcshen0111 hcshen0111 force-pushed the feat/kimi-coding-cn-provider branch from 3e9186d to 0702f28 Compare April 12, 2026 01:41
teknium1 pushed a commit that referenced this pull request Apr 13, 2026
Cherry-picked from PR #7637 by hcshen0111.
Adds kimi-coding-cn provider with dedicated KIMI_CN_API_KEY env var
and api.moonshot.cn/v1 endpoint for China-region Moonshot users.
teknium1 added a commit that referenced this pull request Apr 13, 2026
Follow-up for salvaged PR #7637. Adds kimi-coding-cn to:
- model_normalize.py (prefix strip)
- providers.py (models.dev mapping)
- runtime_provider.py (credential resolution)
- setup.py (model list + setup label)
- doctor.py (health check)
- trajectory_compressor.py (URL detection)
- models_dev.py (registry mapping)
- integrations/providers.md (docs)
teknium1 pushed a commit that referenced this pull request Apr 13, 2026
Cherry-picked from PR #7637 by hcshen0111.
Adds kimi-coding-cn provider with dedicated KIMI_CN_API_KEY env var
and api.moonshot.cn/v1 endpoint for China-region Moonshot users.
teknium1 added a commit that referenced this pull request Apr 13, 2026
Follow-up for salvaged PR #7637. Adds kimi-coding-cn to:
- model_normalize.py (prefix strip)
- providers.py (models.dev mapping)
- runtime_provider.py (credential resolution)
- setup.py (model list + setup label)
- doctor.py (health check)
- trajectory_compressor.py (URL detection)
- models_dev.py (registry mapping)
- integrations/providers.md (docs)
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #9172. Your commit was cherry-picked onto current main with your authorship preserved in git log. The salvage PR also incorporated supplementary coverage from PRs #8900, #8856, and #8166 (additional touchpoints like doctor.py, setup.py, model_normalize, runtime_provider, trajectory_compressor, and full docs). Thank you for the thorough implementation @hcshen0111!

@teknium1 teknium1 closed this Apr 13, 2026
@hcshen0111 hcshen0111 deleted the feat/kimi-coding-cn-provider branch April 16, 2026 08:57
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
Cherry-picked from PR NousResearch#7637 by hcshen0111.
Adds kimi-coding-cn provider with dedicated KIMI_CN_API_KEY env var
and api.moonshot.cn/v1 endpoint for China-region Moonshot users.
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
Follow-up for salvaged PR NousResearch#7637. Adds kimi-coding-cn to:
- model_normalize.py (prefix strip)
- providers.py (models.dev mapping)
- runtime_provider.py (credential resolution)
- setup.py (model list + setup label)
- doctor.py (health check)
- trajectory_compressor.py (URL detection)
- models_dev.py (registry mapping)
- integrations/providers.md (docs)
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
Cherry-picked from PR NousResearch#7637 by hcshen0111.
Adds kimi-coding-cn provider with dedicated KIMI_CN_API_KEY env var
and api.moonshot.cn/v1 endpoint for China-region Moonshot users.
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
Follow-up for salvaged PR NousResearch#7637. Adds kimi-coding-cn to:
- model_normalize.py (prefix strip)
- providers.py (models.dev mapping)
- runtime_provider.py (credential resolution)
- setup.py (model list + setup label)
- doctor.py (health check)
- trajectory_compressor.py (URL detection)
- models_dev.py (registry mapping)
- integrations/providers.md (docs)
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
Cherry-picked from PR NousResearch#7637 by hcshen0111.
Adds kimi-coding-cn provider with dedicated KIMI_CN_API_KEY env var
and api.moonshot.cn/v1 endpoint for China-region Moonshot users.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
Follow-up for salvaged PR NousResearch#7637. Adds kimi-coding-cn to:
- model_normalize.py (prefix strip)
- providers.py (models.dev mapping)
- runtime_provider.py (credential resolution)
- setup.py (model list + setup label)
- doctor.py (health check)
- trajectory_compressor.py (URL detection)
- models_dev.py (registry mapping)
- integrations/providers.md (docs)
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Cherry-picked from PR NousResearch#7637 by hcshen0111.
Adds kimi-coding-cn provider with dedicated KIMI_CN_API_KEY env var
and api.moonshot.cn/v1 endpoint for China-region Moonshot users.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Follow-up for salvaged PR NousResearch#7637. Adds kimi-coding-cn to:
- model_normalize.py (prefix strip)
- providers.py (models.dev mapping)
- runtime_provider.py (credential resolution)
- setup.py (model list + setup label)
- doctor.py (health check)
- trajectory_compressor.py (URL detection)
- models_dev.py (registry mapping)
- integrations/providers.md (docs)
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
Cherry-picked from PR NousResearch#7637 by hcshen0111.
Adds kimi-coding-cn provider with dedicated KIMI_CN_API_KEY env var
and api.moonshot.cn/v1 endpoint for China-region Moonshot users.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
Follow-up for salvaged PR NousResearch#7637. Adds kimi-coding-cn to:
- model_normalize.py (prefix strip)
- providers.py (models.dev mapping)
- runtime_provider.py (credential resolution)
- setup.py (model list + setup label)
- doctor.py (health check)
- trajectory_compressor.py (URL detection)
- models_dev.py (registry mapping)
- integrations/providers.md (docs)
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.

[Feature]: Add Kimi / Moonshot China to Providers (kimi-coding-cn)

2 participants