🤖 feat: add native Kimi K3 support via a new Moonshot AI provider#3737
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd15daa74b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
9c234f9 to
eef38f9
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
eef38f9 to
2e26ea4
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e26ea4625
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * branches key off this predicate. | ||
| */ | ||
| export function isKimiK3Model(modelString: string): boolean { | ||
| return stripModelProviderPrefixes(modelString) === "kimi-k3"; |
There was a problem hiding this comment.
Filter Kimi reasoning-only history before replay
Because Kimi K3 is introduced here as an always-reasoning model, a turn that is interrupted after Moonshot has written only reasoning parts can leave a reasoning-only assistant entry in chat.jsonl. prepareProviderRequestMessages currently calls transformModelMessages with providerForMessages === "moonshotai", which falls into the unknown-provider branch instead of the OpenAI-compatible/Anthropic filtering that drops reasoning-only assistant messages; the next request is therefore serialized as an empty assistant message and can be rejected by Moonshot/OpenRouter. Please route Moonshot through the same reasoning-only filtering path before sending history.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid finding, thanks. A fix is prepared locally (route moonshotai through the same filterReasoningOnlyMessages path as OpenAI in transformModelMessages, plus a regression test), but this PR is currently in the merge queue, so the branch cannot be updated. It will be pushed here if the PR is dequeued, or land as an immediate follow-up if this merges first. Leaving this thread open until the fix is on a pushed head.
Response from Mux, an AI coding agent acting on Mike's behalf.
There was a problem hiding this comment.
This PR merged from the queue before the fix could be pushed. The fix now lives on branch mike/kimi-k3-reasoning-history-filter (commit 98e990f): moonshotai routes through the same filterReasoningOnlyMessages path as OpenAI in transformModelMessages, with a regression test. It will be submitted as a follow-up PR.
Response from Mux, an AI coding agent acting on Mike's behalf.
…ions The isKimiK3Model docstring already explains that Kimi K3 always reasons and supports only the max reasoning effort, and that the provider-options branches key off the predicate. #3737 restated that same sentence verbatim in both the Moonshot and OpenRouter branches of buildProviderOptions, so trim the duplicated lead sentence and keep only each branch's site-specific "send it explicitly" rationale. Comment-only; behavior-preserving.
Summary
Adds Kimi K3 as a first-class built-in model backed by a new
moonshotaidirect provider (official@ai-sdk/moonshotaipackage), with aliases, token/cost metadata, a fixed thinking policy, and reasoning options matching what the model actually accepts. OpenRouter routing for Moonshot models keeps working as a gateway route.Background
Kimi K3 is Moonshot AI's flagship open-weight reasoning model (released July 16, 2026). The first iteration of this PR registered it as an OpenRouter gateway model; per review direction it now uses the AI SDK's official Moonshot provider directly (
MOONSHOT_API_KEY,api.moonshot.ai), which types K3'sreasoningEffortas the literal"max".Implementation
moonshotaiprovider: registered inPROVIDER_DEFINITIONS(direct,createMoonshotAI), providers config schema,MOONSHOT_API_KEYenv wiring, Settings key URL, provider icon, and OpenRouterroutessoopenrouter:moonshotai/...still canonicalizes and routes correctly.KIMI_K3registry entry is nowmoonshotai:kimi-k3(aliaseskimi,k3,kimi-k3); tokenizer falls back tomoonshotai/kimi-k2until K3 lands in ai-tokenizer.moonshotai/kimi-k3: 1M context / 128K output, $3/M in, $15/M out, $0.30/M cache read, vision + reasoning + function calling.isKimiK3Model()predicate; fixed["max"]thinking policy;buildProviderOptionssends{ moonshotai: { reasoningEffort: "max" } }for direct requests and the explicit OpenRoutereffort: "max"payload when routed through OpenRouter (Codex round-1 fix;enabled: truealone falls back to OpenRouter's default medium effort).docs/config/models.mdx,docs/config/providers.mdx, and built-in skill content.Validation
make static-checkgreen.createMoonshotAIinstantiateskimi-k3(spec v4) under ourai@7stack.Risks
Low-to-moderate. Registering
moonshotaias a direct provider changes canonicalization ofopenrouter:moonshotai/*strings (they now normalize to the direct provider for metadata, and stay on OpenRouter only via explicit gateway routing). Covered by routing/normalization tests; the non-K3 OpenRouter payload path is unchanged.Generated with
mux• Model:anthropic:claude-fable-5• Thinking:xhigh• Cost:$19.36