feat(provider): add kimi-for-coding provider#393
Conversation
Add support for Kimi for Coding (Moonshot AI Coding Plan) via their Anthropic-compatible endpoint at https://api.kimi.com/coding. Key points: - Requires whitelisted User-Agent (KimiCLI/1.5) to avoid HTTP 429 "engine overloaded" errors. - Extracts shared AnthropicCompatibleProvider base class to eliminate ~60 lines of duplication with MinimaxProvider. - Adds describeImage support that MinimaxProvider was missing. Env vars: KIMI_API_KEY (required) KIMI_BASE_URL (optional, default: https://api.kimi.com/coding) KIMI_MODEL (optional, default: kimi-k2) Tests: - test/kimi-for-coding-provider.test.ts — base URL resolution - test/kimi-for-coding-e2e.test.ts — request shape + error handling Signed-off-by: yangyunchao <yangyunchao@tal.com>
|
@yangyunchao-tal is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughIntroduces ChangesAnthropic-Compatible Provider Abstraction and Kimi Integration
Sequence DiagramsequenceDiagram
participant Client
participant KimiProvider as KimiForCodingProvider
participant BaseProvider as AnthropicCompatibleProvider
participant KimiAPI as Kimi /v1/messages
Client->>KimiProvider: summarize(systemPrompt, userPrompt)
KimiProvider->>BaseProvider: super.summarize(...)
BaseProvider->>BaseProvider: Build headers + body
BaseProvider->>KimiAPI: POST (auth, model, messages)
KimiAPI-->>BaseProvider: JSON with content blocks
BaseProvider->>BaseProvider: Extract first text block
BaseProvider-->>KimiProvider: text result
KimiProvider-->>Client: text result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Add support for Kimi for Coding (Moonshot AI Coding Plan) via their Anthropic-compatible endpoint at
https://api.kimi.com/coding.Key Changes
kimi-for-codingwithKIMI_API_KEYenv varAnthropicCompatibleProviderto eliminate ~60 lines of duplication withMinimaxProviderKimiCLI/1.5describeImagesupport: Added to bothKimiForCodingProviderandMinimaxProvider(was missing)Env Vars
KIMI_API_KEYKIMI_BASE_URLhttps://api.kimi.com/codingKIMI_MODELkimi-k2Tests
test/kimi-for-coding-provider.test.ts— base URL resolution (default + env override)test/kimi-for-coding-e2e.test.ts— mock fetch verifies headers, body shape, and error handlingCompatibility Notes
This PR touches
src/types.ts(ProviderType) andsrc/providers/index.ts(createBaseProvider), which may conflict with other open provider PRs:If any of these merge first, this PR will need a rebase.
Additionally, #379 (AbortController timeout) adds
fetchWithTimeouttominimax.ts. Since this PR extracts a sharedAnthropicCompatibleProviderbase class, the timeout logic from #379 should ideally be merged into the base class rather than per-provider. Happy to coordinate with #379's author if both PRs are accepted.Verification
npm run buildpasses