Skip to content

feat(providers): add Kimi (Moonshot AI) provider#5716

Merged
waleedlatif1 merged 2 commits into
stagingfrom
worktree-kimi-provider
Jul 16, 2026
Merged

feat(providers): add Kimi (Moonshot AI) provider#5716
waleedlatif1 merged 2 commits into
stagingfrom
worktree-kimi-provider

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Add Kimi (Moonshot AI) as a hosted + BYOK LLM provider (api.moonshot.ai/v1, OpenAI-compatible)
  • Models: kimi-k3 (1M context, recommended), kimi-k2.7-code, kimi-k2.7-code-highspeed, kimi-k2.6 (default) — exactly the set the API serves, pricing from official docs
  • All current Kimi models pin temperature server-side, so no model declares the temperature capability and the adapter never sends it (verified live: non-default values are rejected)
  • Thinking toggle on kimi-k2.6 via thinking: {type}; forced tool_choice disables thinking on toggle models and downgrades to auto on always-thinking models (Kimi rejects forced tool_choice with thinking enabled — verified live)
  • Native json_schema structured output with the shared enforceStrictSchema() helper; max_completion_tokens output cap; image attachments via image_url data URIs
  • Hosted key rotation via KIMI_API_KEY_1..3 + BYOK support incl. settings UI row; wired through registry, types, attachments, tokenization, billing (getHostedModels), and tests

Type of Change

  • New feature

Testing

Live-tested every wire shape against the real Moonshot API with production keys: chat on all four models, streaming with usage, multi-turn tool loop, forced tool calls, strict json_schema output, thinking toggle, vision parts, and the max_completion_tokens cap. 888 provider/tokenization/byok tests pass; tsc, biome, and check:api-validation clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 16, 2026 8:54pm

Request Review

@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New LLM execution and billing path with non-trivial tool/thinking API constraints, but it follows established hosted-provider patterns and is covered by tests.

Overview
Adds Kimi (Moonshot AI) as a first-class LLM provider with hosted key rotation (KIMI_API_KEY_1..3) and workspace BYOK, including a new row in workspace BYOK settings and kimi in the BYOK API schema.

Registers four models (kimi-k3, kimi-k2.7-code, kimi-k2.7-code-highspeed, kimi-k2.6 with default kimi-k2.6), pricing, and inclusion in getHostedModels. Ships a new OpenAI-compatible adapter at api.moonshot.ai with streaming, tools, json_schema output, max_completion_tokens, image attachments, and Kimi-specific handling: no temperature, optional thinking toggle on kimi-k2.6, and forced tool_choice coordinated with thinking (disable thinking or fall back to auto).

Wires kimi through provider registry/types, attachments, tokenization, and key resolution paths alongside existing hosted providers; adds KimiIcon and provider definition tests.

Reviewed by Cursor Bugbot for commit 79ed9b8. Configure here.

Comment thread apps/sim/providers/kimi/index.ts
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Kimi as a hosted and BYOK language-model provider. The main changes are:

  • Kimi model metadata, capabilities, pricing, and billing registration.
  • Hosted key rotation and user-provided API key support.
  • Chat, streaming, tool calls, structured output, thinking controls, and image attachments.
  • Provider settings, icon, tokenization, registry, and model tests.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the updated code.
  • The forced-tool and tool-result paths do not expose a separate remaining production bug within this follow-up.

Important Files Changed

Filename Overview
apps/sim/providers/kimi/index.ts Adds Kimi request handling for streaming, tools, structured output, thinking controls, usage, cost, and timing.
apps/sim/providers/kimi/utils.ts Connects Kimi streams to the shared OpenAI-compatible stream processor.
apps/sim/providers/models.ts Defines Kimi models, capabilities, pricing, defaults, and hosted availability.
apps/sim/providers/registry.ts Registers the Kimi provider in the provider registry.
apps/sim/lib/api-key/byok.ts Adds Kimi to hosted and user-provided API key selection.

Reviews (2): Last reviewed commit: "fix(providers): preserve reasoning_conte..." | Re-trigger Greptile

Comment thread apps/sim/providers/kimi/index.ts
Comment thread apps/sim/providers/kimi/index.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 79ed9b8. Configure here.

@waleedlatif1
waleedlatif1 merged commit cea1c89 into staging Jul 16, 2026
20 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-kimi-provider branch July 16, 2026 20:59
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.

1 participant