Skip to content

feat: add Kimi/Moonshot and Opencode provider support#933

Open
putueddy wants to merge 2 commits intosipeed:mainfrom
putueddy:feat/kimi-opencode-providers
Open

feat: add Kimi/Moonshot and Opencode provider support#933
putueddy wants to merge 2 commits intosipeed:mainfrom
putueddy:feat/kimi-opencode-providers

Conversation

@putueddy
Copy link

@putueddy putueddy commented Mar 1, 2026

Summary

  • Add Kimi/Moonshot provider support: "kimi", "kimi-code", "moonshot" as recognized provider names in resolveProviderSelection(), with default API base https://api.kimi.com/coding/v1 (Kimi Code API)
  • Add Kimi Code User-Agent header (KimiCLI/0.77) for api.kimi.com endpoints, required by the Kimi Code API
  • Add Opencode provider support: recognized protocol in CreateProviderFromConfig, default API base https://opencode.ai/zen/v1, migration entry for ConvertProvidersToModelList
  • Add Opencode field to ProvidersConfig struct with proper IsEmpty() and HasProvidersConfig() support

Test plan

  • Verified Kimi K2 P5 model works via Telegram bot with provider: "moonshot" config
  • go build ./pkg/... passes
  • Test Opencode provider with API key
  • Verify moonshot fallback URL change doesn't break existing moonshot/kimi users
- Add "kimi", "kimi-code", "moonshot" provider cases in factory.go
  with default API base https://api.kimi.com/coding/v1
- Add Kimi Code API User-Agent header (KimiCLI/0.77) for api.kimi.com
- Add "opencode" provider with default API base https://opencode.ai/zen/v1
- Add "opencode" to recognized HTTP-compatible protocols in factory_provider
- Add Opencode field to ProvidersConfig, IsEmpty, HasProvidersConfig
- Add opencode migration entry in ConvertProvidersToModelList
- Update moonshot fallback API base from api.moonshot.cn to api.kimi.com
Copilot AI review requested due to automatic review settings March 1, 2026 01:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for additional OpenAI-compatible providers (Kimi/Moonshot and Opencode) across provider selection, defaults, and legacy-config migration so users can configure these backends similarly to existing HTTP-compat providers.

Changes:

  • Add Kimi/Moonshot aliases in provider selection and set a Kimi Code-specific User-Agent for api.kimi.com requests.
  • Add opencode as a supported protocol/provider with a default API base (https://opencode.ai/zen/v1).
  • Extend legacy providers config + migration (ConvertProvidersToModelList) to include providers.opencode.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/providers/openai_compat/provider.go Adds Kimi Code User-Agent header behavior for Kimi endpoints.
pkg/providers/factory_provider.go Registers opencode as an OpenAI-compatible protocol and adds its default API base.
pkg/providers/factory.go Extends legacy provider selection to recognize opencode and Kimi/Moonshot aliases; adjusts moonshot default base behavior.
pkg/config/migration.go Migrates legacy providers.opencode into model_list.
pkg/config/config.go Adds Opencode to ProvidersConfig and includes it in IsEmpty() / HasProvidersConfig().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Allow APIBase-only config for opencode provider selection (like VLLM)
- Keep moonshot provider on moonshot.cn/v1 default, only use kimi.com/coding/v1 for kimi/kimi-code
- Use url.Parse hostname match for Kimi User-Agent check instead of strings.Contains
- Add opencode to DefaultAPIBase test cases in factory_provider_test.go
- Add opencode migration tests (full config + APIBase-only) in migration_test.go
- Update AllProviders test count to include opencode (18 -> 19)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants