Skip to content

feat: add Moonshot AI (Kimi) as native provider#25

Merged
jamiepine merged 3 commits intospacedriveapp:mainfrom
ricorna:feat/moonshot-provider-clean
Feb 20, 2026
Merged

feat: add Moonshot AI (Kimi) as native provider#25
jamiepine merged 3 commits intospacedriveapp:mainfrom
ricorna:feat/moonshot-provider-clean

Conversation

@ricorna
Copy link
Contributor

@ricorna ricorna commented Feb 18, 2026

Depends on #24 — this PR includes those commits and adds the Moonshot provider on top.

Motivation

Moonshot AI builds Kimi, one of the most widely used AI assistants internationally. Their models (Kimi K2, Kimi K2.5) compete with frontier models at lower cost. Adding native support eliminates routing through OpenRouter (~15-20% markup).

Moonshot offers two API surfaces:

  • Standard API (api.moonshot.ai/v1) — pay-per-token with a standard API key
  • Kimi Coding Plan (api.kimi.com/coding/v1) — subscription-based, same key, dedicated endpoint for coding workloads

Both are supported via the base_url infrastructure from #24. The web UI offers a preset selector so users can switch between Standard and Coding Plan without knowing the URLs.

Changes

  • Added moonshot_key / MOONSHOT_API_KEY config and env var
  • Moonshot dispatch via call_openai_compatible (OpenAI-compatible format)
  • Default endpoint: api.moonshot.ai/v1/chat/completions
  • Endpoint presets: "Moonshot API (General)" / "Kimi Coding Plan (subscription)"
  • Default routing: Kimi K2.5 for channel/branch, moonshot-v1-8k for workers
  • Provider card, status endpoint, moonshot/ model prefix

Breaking Changes

None. New provider — no existing behavior affected.

How to Test

# Standard Moonshot API
MOONSHOT_API_KEY=\"sk-...\" cargo run

# Kimi Coding Plan
MOONSHOT_API_KEY=\"sk-kimi-...\" \
MOONSHOT_BASE_URL=\"https://api.kimi.com/coding/v1/chat/completions\" \
cargo run

# Or via web UI → Settings → Providers → Moonshot AI → Endpoint dropdown

Verified

Tested with a Kimi Coding Plan subscription (sk-kimi- key). With MOONSHOT_BASE_URL pointed at the Kimi Coding endpoint (api.kimi.com/coding/v1/chat/completions), chat completions return successfully. Using the same key against the standard Moonshot endpoint (api.moonshot.ai/v1) returns the expected authentication error — confirming the Coding Plan key is scoped to its dedicated endpoint. Endpoint preset selector in the web UI correctly switches between Standard and Coding Plan URLs.

Diff stats

8 files changed, 87 insertions(+), 4 deletions(-)

ricorna and others added 3 commits February 19, 2026 16:40
Add Moonshot AI as a new LLM provider with full ProviderConfig
integration: legacy key auto-mapping, API routing (OpenAI-compatible),
routing defaults (kimi-k2.5), and onboarding flow.

The Kimi Coding API (api.kimi.com) requires a User-Agent: KimiCLI/1.3
header, added conditionally in call_openai when the endpoint URL
contains "kimi.com".

Frontend gains a Moonshot entry in the provider list with Kimi brand
icon from lobehub.
… handling for moonshot.ai

- Added moonshot_key to the TomlLlmConfig struct for enhanced configuration options.
- Updated the user-agent header condition to include moonshot.ai endpoints alongside kimi.com for proper API requests.
@jamiepine jamiepine force-pushed the feat/moonshot-provider-clean branch from 9cc66f0 to 1302f6b Compare February 20, 2026 00:52
@jamiepine
Copy link
Member

I accidentally merged #26 before this PR, so I had to rebase and fix, all good. merging this too now.

@jamiepine jamiepine merged commit d7ab386 into spacedriveapp:main Feb 20, 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.

2 participants

Comments