Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: list Kimi K3 for Kimi API keys (#13300)

Daniel Han58b24b01b703
diff --git a/studio/backend/core/inference/external_provider.py b/studio/backend/core/inference/external_provider.py
index 2769d6f6509..b65ca5c4ce1 100644
--- a/studio/backend/core/inference/external_provider.py
+++ b/studio/backend/core/inference/external_provider.py
@@ -863,6 +863,27 @@ def _apply_deepseek_reasoning_controls(
body["thinking"] = {"type": "enabled"}
+_KIMI_K3_EFFORT_ALIASES = {"minimal": "low", "medium": "high", "xhigh": "max"}
+
+
+def _is_kimi_k3(provider_type: Optional[str], model: Optional[str]) -> bool:
+ return provider_type == "kimi" and (model or "").strip().lower() == "kimi-k3"
+
+
+def _apply_kimi_k3_controls(body: dict[str, Any], reasoning_effort: Optional[str]) -> None:
+ """kimi-k3 always reasons and has no `thinking` field; effort is low | high | max (server default max), output
+ is capped by `max_completion_tokens`, and its fixed sampling (presence_penalty incl.) is to be omitted.
+ https://platform.kimi.ai/docs/guide/kimi-k3-quickstart"""
+ body.pop("thinking", None)
+ body.pop("presence_penalty", None)
+ if "max_tokens" in body:
+ body["max_completion_tokens"] = body.pop("max_tokens")
+ effort = (reasoning_effort or "").strip().lower()
+ effort = _KIMI_K3_EFFORT_ALIASES.get(effort, effort)
+ if effort in ("low", "high", "max"):
+ body["reasoning_effort"] = effort
+
+
def _apply_qwen_reasoning_controls(body: dict[str, Any], enable_thinking: Optional[bool]) -> None:
if enable_thinking is not None:
body["enable_thinking"] = bool(enable_thinking)
@@ -1721,6 +1742,7 @@ class ExternalProviderClient:
messages,
model,
max_tokens,
+ reasoning_effort,
):
yield line
return
@@ -1775,7 +1797,9 @@ class ExternalProviderClient:
# Kimi thinking is a top-level body field. kimi-k2-thinking is always on (ignore the toggle); kimi-k2.6
# defaults on, can be disabled. `keep: all` preserves every chunk for the UI panel.
- if self.provider_type == "kimi" and enable_thinking is not None:
+ if _is_kimi_k3(self.provider_type, model):
+ _apply_kimi_k3_controls(body, reasoning_effort)
+ elif self.provider_type == "kimi" and enable_thinking is not None:
if model == "kimi-k2-thinking":
# Always on; ignore client toggle to avoid an API-level reject.
pass
@@ -2124,7 +2148,11 @@ class ExternalProviderClient:
)
async def _stream_kimi_web_search(
- self, messages: list[dict[str, Any]], model: str, max_tokens: Optional[int]
+ self,
+ messages: list[dict[str, Any]],
+ model: str,
+ max_tokens: Optional[int],
+ reasoning_effort: Optional[str] = None,
) -> AsyncGenerator[str, None]:
"""Kimi $web_search round-trip, per https://platform.kimi.ai/docs/guide/use-web-search: POST
messages with tools=[{type: "builtin_function", function: {name: "$web_search"}}] and
@@ -2157,6 +2185,8 @@ class ExternalProviderClient:
provider_info = get_provider_info(self.provider_type) or {}
for field in provider_info.get("body_omit", ()):
body.pop(field, None)
+ if _is_kimi_k3(self.provider_type, model):
+ _apply_kimi_k3_controls(body, reasoning_effort)
tool_call_id = "kimi_web_search"
synthetic_id = f"chatcmpl-{self.provider_type}-synthetic"
@@ -2178,6 +2208,8 @@ class ExternalProviderClient:
)
tool_calls_acc: dict[int, dict[str, Any]] = {}
+ # A reasoning model's tool-call turn is replayed whole, reasoning included, or the follow-up is rejected.
+ reasoning_parts: list[str] = []
try:
async with _client().stream(
"POST",
@@ -2222,6 +2254,8 @@ class ExternalProviderClient:
if not isinstance(choice, dict):
continue
delta = choice.get("delta") or {}
+ if isinstance(delta.get("reasoning_content"), str):
+ reasoning_parts.append(delta["reasoning_content"])
for tc in delta.get("tool_calls") or []:
if not isinstance(tc, dict):
continue
@@ -2365,6 +2399,8 @@ class ExternalProviderClient:
"content": "",
"tool_calls": list(tool_calls_acc.values()),
}
+ if reasoning_parts:
+ assistant_msg["reasoning_content"] = "".join(reasoning_parts)
tool_msgs = [
{
"role": "tool",
diff --git a/studio/backend/core/inference/external_tool_transport.py b/studio/backend/core/inference/external_tool_transport.py
index f1c08d33701..6dac4fdca85 100644
--- a/studio/backend/core/inference/external_tool_transport.py
+++ b/studio/backend/core/inference/external_tool_transport.py
@@ -20,7 +20,7 @@ import threading
from collections.abc import AsyncIterator, Awaitable, Callable
from typing import Any
-from core.inference.external_provider import ExternalProviderClient
+from core.inference.external_provider import ExternalProviderClient, _is_kimi_k3
# /inference/cancel and the model-load path only set a threading.Event, so an asyncio consumer has to poll it. Same
@@ -74,7 +74,7 @@ class OAICompatTransport:
self._last_tools: list[dict[str, Any]] | None = None
self.preserves_reasoning = (
client.provider_type == "llama_cpp" and request_kwargs.get("preserve_thinking") is True
- )
+ ) or _is_kimi_k3(client.provider_type, model)
def stream(
self,
diff --git a/studio/backend/core/inference/providers.py b/studio/backend/core/inference/providers.py
index dee0d561ae5..752cc108f2e 100644
--- a/studio/backend/core/inference/providers.py
+++ b/studio/backend/core/inference/providers.py
@@ -256,12 +256,13 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
"kimi": {
"display_name": "Kimi",
"base_url": "https://api.moonshot.ai/v1",
- # Surface only the two SoTA multimodal models (kimi-k2.6/k2.5);
+ # Surface only the SoTA multimodal models (kimi-k3, kimi-k2.6/k2.5);
# moonshot-v1-* and dated k2 previews are filtered by the allowlist.
# Docs: https://platform.kimi.ai/docs/models
# Listing/overview: https://platform.kimi.ai/docs/api/list-models
# https://platform.kimi.ai/docs/api/overview
"default_models": [
+ "kimi-k3",
"kimi-k2.6",
"kimi-k2.5",
],
@@ -274,7 +275,7 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
"auth_header": "Authorization",
"auth_prefix": "Bearer ",
"notes": "Moonshot API key. China: use base URL https://api.moonshot.cn/v1",
- "model_id_allowlist": re.compile(r"^kimi-k2\.[56]$"),
+ "model_id_allowlist": re.compile(r"^kimi-(?:k3|k2\.[56])$"),
# Reasoning-class: the API rejects custom temperature/top_p ("only 1
# is allowed"). Strip both so the server uses its required defaults.
"body_omit": ("temperature", "top_p"),
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index 7df356c3adb..e8a696b703b 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -3969,6 +3969,7 @@ from core.inference.providers import (
)
from core.inference.external_provider import (
ExternalProviderClient,
+ _is_kimi_k3,
_is_openai_family_cloud,
compacts_server_side,
)
@@ -9834,7 +9835,7 @@ _TEXT_ONLY_PROVIDER_TYPES = frozenset({"cohere", "deepseek", "mistral"})
# Mixed catalogs require model-level vision capability; family flags do not
# identify which models accept images. Qwen has unrestricted text defaults;
# its vision models use separate qwen-vl-* or Qwen2.5-VL IDs. Kimi is excluded
-# because its allowlist permits only multimodal kimi-k2.5/k2.6.
+# because its allowlist permits only multimodal kimi-k3/k2.5/k2.6.
# Single-endpoint types (custom, vllm, ollama, llamacpp, lmstudio) retain the
# registry default: no model catalog exists to check the configured endpoint.
_MIXED_CATALOG_PROVIDER_TYPES = frozenset({"huggingface", "openrouter", "qwen"})
@@ -27615,6 +27616,7 @@ def _build_external_messages(
api_type: Optional[str] = None,
promoted_out: "Optional[list]" = None,
promote_mcp_images: "Optional[bool]" = None,
+ model: Optional[str] = None,
) -> list[dict]:
"""
Convert ChatMessage list to OpenAI-compatible dicts for external providers.
@@ -27759,11 +27761,12 @@ def _build_external_messages(
return {"type": "compaction", "encrypted_content": item.encrypted_content}
return None
+ replays_reasoning = provider_type == "llama_cpp" or _is_kimi_k3(provider_type, model)
result = []
for msg in messages:
replay = (
{"reasoning_content": msg.reasoning_content}
- if provider_type == "llama_cpp" and msg.role == "assistant" and msg.reasoning_content
+ if replays_reasoning and msg.role == "assistant" and msg.reasoning_content
else {}
)
has_message_extra_content = bool(
@@ -28952,6 +28955,7 @@ async def _proxy_to_external_provider(
promote_mcp_images = _external_takes_mcp_images(
provider_type, _supports_vision, model, _pinfo
),
+ model = model,
)
monitor_id = None
if not getattr(request.state, "skip_api_monitor", False):
diff --git a/studio/backend/tests/test_kimi_k3_provider.py b/studio/backend/tests/test_kimi_k3_provider.py
new file mode 100644
index 00000000000..ffd48ce2e95
--- /dev/null
+++ b/studio/backend/tests/test_kimi_k3_provider.py
@@ -0,0 +1,170 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Kimi K3 over the direct Moonshot API (#8735): it reaches the picker, and requests
+follow https://platform.kimi.ai/docs/guide/kimi-k3-quickstart while k2.x keep their shape."""
+
+import asyncio
+import json
+
+import httpx
+import pytest
+
+from core.inference import external_provider as ep_mod
+from core.inference.external_provider import ExternalProviderClient
+from core.inference.providers import PROVIDER_REGISTRY
+
+
+def _drive(coro):
+ return asyncio.new_event_loop().run_until_complete(coro)
+
+
+async def _collect(agen):
+ return [line async for line in agen]
+
+
+def _capture(monkeypatch, responses):
+ bodies: list = []
+ replies = iter(responses)
+
+ def handler(request: httpx.Request) -> httpx.Response:
+ bodies.append(json.loads(request.content.decode("utf-8")))
+ return httpx.Response(
+ 200, content = next(replies), headers = {"content-type": "text/event-stream"}
+ )
+
+ monkeypatch.setattr(
+ ep_mod, "_http_client", httpx.AsyncClient(transport = httpx.MockTransport(handler))
+ )
+ return bodies
+
+
+_PLAIN = b'data: {"choices":[{"delta":{"content":"ok"}}]}\n\ndata: [DONE]\n\n'
+
+
+def _stream(model, **kwargs):
+ async def run():
+ client = ExternalProviderClient(
+ provider_type = "kimi", base_url = "http://kimi.example/v1", api_key = "sk-test"
+ )
+ await _collect(
+ client.stream_chat_completion(
+ messages = [{"role": "user", "content": "ping"}], model = model, **kwargs
+ )
+ )
+ await client.close()
+
+ _drive(run())
+
+
+def test_kimi_k3_reaches_the_picker():
+ kimi = PROVIDER_REGISTRY["kimi"]
+ for model_id in ("kimi-k3", "kimi-k2.6", "kimi-k2.5"):
+ assert kimi["model_id_allowlist"].match(model_id), model_id
+ assert model_id in kimi["default_models"], model_id
+ for model_id in ("kimi-k3-preview", "kimi-k2-0905-preview", "moonshot-v1-8k"):
+ assert not kimi["model_id_allowlist"].match(model_id), model_id
+
+
+ ("effort", "sent"),
+ [("low", "low"), ("high", "high"), ("max", "max"), ("medium", "high"), ("xhigh", "max")],
+)
+def test_kimi_k3_sends_its_documented_controls(monkeypatch, effort, sent):
+ bodies = _capture(monkeypatch, [_PLAIN])
+ _stream(
+ "kimi-k3",
+ temperature = 0.7,
+ top_p = 0.9,
+ presence_penalty = 0.0,
+ max_tokens = 64,
+ enable_thinking = False,
+ reasoning_effort = effort,
+ )
+ body = bodies[0]
+ assert body["reasoning_effort"] == sent
+ assert body["max_completion_tokens"] == 64
+ for field in ("thinking", "max_tokens", "presence_penalty", "temperature", "top_p"):
+ assert field not in body, field
+
+
+def test_kimi_k3_without_an_effort_leaves_the_server_default(monkeypatch):
+ bodies = _capture(monkeypatch, [_PLAIN])
+ _stream("kimi-k3", max_tokens = 64, reasoning_effort = "none")
+ assert "reasoning_effort" not in bodies[0]
+ assert "thinking" not in bodies[0]
+
+
+def test_kimi_k2_6_request_is_unchanged(monkeypatch):
+ bodies = _capture(monkeypatch, [_PLAIN])
+ _stream(
+ "kimi-k2.6",
+ presence_penalty = 0.5,
+ max_tokens = 64,
+ enable_thinking = False,
+ reasoning_effort = "high",
+ )
+ body = bodies[0]
+ assert body["thinking"] == {"type": "disabled"}
+ assert body["max_tokens"] == 64
+ assert body["presence_penalty"] == 0.5
+ assert "reasoning_effort" not in body
+ assert "max_completion_tokens" not in body
+
+
+_SEARCH_CALL = (
+ b'data: {"choices":[{"delta":{"reasoning_content":"look it up"}}]}\n\n'
+ b'data: {"choices":[{"delta":{"tool_calls":[{"index":0,"id":"c1","type":"builtin_function",'
+ b'"function":{"name":"$web_search","arguments":"{\\"q\\":1}"}}]},"finish_reason":"tool_calls"}]}\n\n'
+ b"data: [DONE]\n\n"
+)
+
+
+def test_kimi_k3_web_search_keeps_reasoning_and_drops_thinking(monkeypatch):
+ bodies = _capture(monkeypatch, [_SEARCH_CALL, _PLAIN])
+ _stream("kimi-k3", max_tokens = 64, reasoning_effort = "low", enabled_tools = ["web_search"])
+ first, followup = bodies
+ for body in (first, followup):
+ assert "thinking" not in body
+ assert body["reasoning_effort"] == "low"
+ assert body["max_completion_tokens"] == 64
+ replayed = followup["messages"][1]
+ assert replayed["role"] == "assistant"
+ assert replayed["reasoning_content"] == "look it up"
+
+
+def test_kimi_k2_6_web_search_still_turns_thinking_off(monkeypatch):
+ bodies = _capture(monkeypatch, [_SEARCH_CALL, _PLAIN])
+ _stream("kimi-k2.6", max_tokens = 64, enabled_tools = ["web_search"])
+ first = bodies[0]
+ assert first["thinking"] == {"type": "disabled"}
+ assert first["max_tokens"] == 64
+ assert "reasoning_effort" not in first
+
+
+def test_kimi_k3_history_keeps_prior_reasoning():
+ from models.inference import ChatMessage
+ from routes.inference import _build_external_messages
+
+ calls = [
+ {"id": "call_1", "type": "function", "function": {"name": "lookup", "arguments": "{}"}}
+ ]
+ history = [
+ ChatMessage(role = "user", content = "hi"),
+ ChatMessage(role = "assistant", content = "", reasoning_content = "plan", tool_calls = calls),
+ ChatMessage(role = "tool", content = "42", tool_call_id = "call_1"),
+ ChatMessage(role = "assistant", content = "answer", reasoning_content = "done"),
+ ]
+ k3 = _build_external_messages(history, True, provider_type = "kimi", model = "kimi-k3")
+ assert [m.get("reasoning_content") for m in k3 if m["role"] == "assistant"] == ["plan", "done"]
+ k26 = _build_external_messages(history, True, provider_type = "kimi", model = "kimi-k2.6")
+ assert all("reasoning_content" not in m for m in k26)
+
+
[email protected](("model", "keeps"), [("kimi-k3", True), ("kimi-k2.6", False)])
+def test_studio_tool_loop_replays_kimi_k3_reasoning(model, keeps):
+ from core.inference.external_tool_transport import OAICompatTransport
+ client = ExternalProviderClient(
+ provider_type = "kimi", base_url = "http://kimi.example/v1", api_key = "sk-test"
+ )
+ assert OAICompatTransport(client, model = model).preserves_reasoning is keeps
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 32fd5c5239b..8c7921316e4 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -222,6 +222,7 @@ import { translate, useT } from "@/i18n";
import {
clampReasoningEffortToLevels,
getExternalReasoningCapabilities,
+ kimiSearchExcludesThinking,
modelCatalogVersion,
subscribeModelCatalog,
} from "@/features/chat/provider-capabilities";
@@ -6019,7 +6020,10 @@ const ReasoningToggle: FC<{ side?: "top" | "bottom" }> = ({
externalSelection != null
? externalProviders.find((p) => p.id === externalSelection.providerId)
: undefined;
- const isKimiExternal = selectedExternalProvider?.providerType === "kimi";
+ const isKimiExternal = kimiSearchExcludesThinking(
+ selectedExternalProvider?.providerType,
+ externalSelection?.modelId,
+ );
const toolsEnabled = useChatRuntimeStore((s) => s.toolsEnabled);
const setToolsEnabled = useChatRuntimeStore((s) => s.setToolsEnabled);
const supportsPreserveThinking = useChatRuntimeStore(
@@ -6320,7 +6324,10 @@ const WebSearchToggle: FC = () => {
externalSelection != null
? externalProviders.find((p) => p.id === externalSelection.providerId)
: undefined;
- const isKimiExternal = selectedExternalProvider?.providerType === "kimi";
+ const isKimiExternal = kimiSearchExcludesThinking(
+ selectedExternalProvider?.providerType,
+ externalSelection?.modelId,
+ );
// Disable only when a loaded model lacks the capability; with no model the
// tool can still be pre-selected, matching the + menu.
const disabled = modelLoaded && !(supportsTools || supportsBuiltinWebSearch);
@@ -6621,7 +6628,10 @@ const ComposerToolsMenu: FC<{
externalSelection != null
? externalProviders.find((p) => p.id === externalSelection.providerId)
: undefined;
- const isKimiExternal = selectedExternalProvider?.providerType === "kimi";
+ const isKimiExternal = kimiSearchExcludesThinking(
+ selectedExternalProvider?.providerType,
+ externalSelection?.modelId,
+ );
// Disable only when a loaded model lacks the capability; with no model the
// tool can still be pre-selected, matching the pill logic above.
const searchDisabled =
diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.ts
index 6b2f10fe901..d661ad42fb7 100644
--- a/studio/frontend/src/features/chat/api/chat-adapter.ts
+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts
@@ -241,6 +241,7 @@ import {
getGroundedExternalMaxOutputTokens,
getExternalMinOutputTokens,
getExternalReasoningCapabilities,
+ providerModelReplaysReasoning,
providerSupportsPreserveThinking,
getProviderCapabilities,
providerHostsCodeExecution,
@@ -5280,6 +5281,9 @@ export function createOpenAIStreamAdapter(
const replayReasoning = !isExternalRequest || (
providerSupportsPreserveThinking(externalProvider?.providerType) &&
runtime.preserveThinking
+ ) || providerModelReplaysReasoning(
+ externalProvider?.providerType,
+ externalSelection?.modelId,
);
const survivingMessages = pruneOutboundHistory(messages, replayReasoning);
const { messages: renderedMessages, sandboxAttachments } =
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx
index fcaa36bc58e..aeabf9d8b96 100644
--- a/studio/frontend/src/features/chat/chat-page.tsx
+++ b/studio/frontend/src/features/chat/chat-page.tsx
@@ -211,6 +211,7 @@ import {
getExternalReasoningCapabilities,
providerSupportsPreserveThinking,
getProviderCapabilities,
+ kimiSearchExcludesThinking,
modelCatalogVersion,
providerHostsCodeExecution,
providerSupportsBuiltinCodeExecution,
@@ -3087,7 +3088,10 @@ export function ChatPage({
);
// Kimi's k2.6/k2.5 default to thinking enabled server-side, so the Think pill comes up clicked. Search stays
// off; the composer's mutual-exclusion handlers flip the two. Per https://platform.kimi.ai/docs/models.
- const isKimi = provider?.providerType === "kimi";
+ const isKimi = kimiSearchExcludesThinking(
+ provider?.providerType,
+ selection.modelId,
+ );
// Web search on by default only for Anthropic and OpenAI, both with structured citations.
// OpenRouter and Kimi work on opt-in but are less reliable.
const searchOnByDefault =
@@ -3873,7 +3877,10 @@ export function ChatPage({
);
// See sibling useEffect: Kimi's k2.x default to thinking enabled. Search stays off; the
// composer's mutual exclusion flips them.
- const isKimi = selectedProvider?.providerType === "kimi";
+ const isKimi = kimiSearchExcludesThinking(
+ selectedProvider?.providerType,
+ selectedExternal?.modelId,
+ );
// Mirror of sibling useEffect: Anthropic/OpenAI get Search on by default; others stay off.
const searchOnByDefault =
supportsBuiltinWebSearch &&
diff --git a/studio/frontend/src/features/chat/provider-capabilities.ts b/studio/frontend/src/features/chat/provider-capabilities.ts
index 087c9ce741f..53cd7fd4258 100644
--- a/studio/frontend/src/features/chat/provider-capabilities.ts
+++ b/studio/frontend/src/features/chat/provider-capabilities.ts
@@ -242,6 +242,8 @@ const EXTERNAL_MAX_OUTPUT_TOKENS_BY_MODEL: Array<{
},
// DeepSeek (deepseek-flash / deepseek-v4-pro).
{ providerType: "deepseek", prefixes: ["deepseek"], cap: 384000 },
+ // max_completion_tokens up to 1M (https://platform.kimi.ai/docs/guide/kimi-k3-quickstart).
+ { providerType: "kimi", prefixes: ["kimi-k3"], cap: 1048576 },
];
/** The connection's effective Max Tokens ceiling for one model. A documented per-model cap
@@ -411,6 +413,16 @@ export function providerSupportsBuiltinWebSearch(
);
}
+/** Search and Think stay exclusive on Kimi, except kimi-k3, which has no thinking off switch. */
+export function kimiSearchExcludesThinking(
+ providerType: string | null | undefined,
+ modelId: string | null | undefined,
+): boolean {
+ return (
+ providerType === "kimi" && modelId?.trim().toLowerCase() !== "kimi-k3"
+ );
+}
+
/** Whether the provider exposes a server-side web_fetch tool emitting a document block.
* Anthropic-only today; gates the Fetch pill independently of Search. */
export function providerSupportsBuiltinWebFetch(
@@ -798,6 +810,10 @@ export function getProviderCapabilities(
topK: false,
};
}
+ // kimi-k3 fixes presence_penalty too and the docs ask for it to be omitted.
+ if (providerType === "kimi" && modelId?.trim().toLowerCase() === "kimi-k3") {
+ return { ...PROVIDER_CAPABILITIES.kimi, presencePenalty: false };
+ }
return PROVIDER_CAPABILITIES[providerType] ?? DEFAULT_EXTERNAL_CAPABILITIES;
}
@@ -1020,7 +1036,19 @@ function withReasoningEffortStyle(caps: ReasoningCaps): ExternalReasoningCapabil
function resolveKimiReasoningCapabilities(modelId: string): ExternalReasoningCapabilities {
// Kimi has a boolean thinking toggle, not an effort scale: k2.6 on by default and
// toggleable, k2-thinking always on, k2.5 and others none.
- // k2.6 is toggled via extra_body: {thinking: {type: enabled|disabled}}.
+ // k2.6 is toggled via extra_body: {thinking: {type: enabled|disabled}}. k3 always reasons
+ // and takes reasoning_effort low|high|max instead.
+ if (modelId === "kimi-k3") {
+ return {
+ ...withReasoningEffortStyle({
+ supportsReasoning: true,
+ supportsReasoningOff: false,
+ reasoningEffortLevels: ["low", "high", "max"],
+ }),
+ // The API's own default; the chat's medium would otherwise clamp down to low.
+ defaultEffort: "max",
+ };
+ }
if (modelId === "kimi-k2-thinking") {
return withEnableThinkingStyle({
supportsReasoning: true,
@@ -1455,6 +1483,14 @@ export function reasoningFieldsAfterCatalogRefresh(
};
}
+/** kimi-k3 wants every assistant message back whole (https://platform.kimi.ai/docs/guide/use-kimi-k2-thinking-model). */
+export function providerModelReplaysReasoning(
+ providerType: string | null | undefined,
+ modelId: string | null | undefined,
+): boolean {
+ return providerType === "kimi" && modelId?.trim().toLowerCase() === "kimi-k3";
+}
+
/** Sent as a llama-server template kwarg, so the model's template must still read it. */
export function providerSupportsPreserveThinking(
providerType: string | null | undefined,
diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx
index c68dd1eb15c..4dd124a349b 100644
--- a/studio/frontend/src/features/chat/shared-composer.tsx
+++ b/studio/frontend/src/features/chat/shared-composer.tsx
@@ -222,6 +222,7 @@ import {
import {
clampReasoningEffortToLevels,
getExternalReasoningCapabilities,
+ kimiSearchExcludesThinking,
providerHostsCodeExecution,
providerSupportsBuiltinCodeExecution,
providerSupportsBuiltinImageGeneration,
@@ -891,7 +892,10 @@ export function SharedComposer({
// Kimi's $web_search builtin mandates thinking=disabled
// (https://platform.kimi.ai/docs/guide/use-web-search). Both pills stay clickable, but turning
// one on flips the other off, so the visible state matches what the backend sends.
- const isKimiExternal = selectedExternalProvider?.providerType === "kimi";
+ const isKimiExternal = kimiSearchExcludesThinking(
+ selectedExternalProvider?.providerType,
+ externalSelection?.modelId,
+ );
const effectiveReasoningEnabled = reasoningLockedOn ? true : reasoningEnabled;
// What the adapter sends: the stored effort clamped to the current ladder, so a catalog refresh that
// drops the stored level is shown truthfully without overwriting the choice.
diff --git a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
index 10c567d1ee3..adbdbf05c05 100644
--- a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
+++ b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
@@ -54,6 +54,7 @@ import {
type ExternalReasoningCapabilities,
externalReasoningTakesEffort,
getExternalMaxOutputTokens,
+ kimiSearchExcludesThinking,
resolveExternalReasoningEffort,
} from "../provider-capabilities";
import {
@@ -3330,11 +3331,12 @@ function externalCheckpointRefusesDeepResearch(
function isKimiCheckpoint(checkpoint: string | null | undefined): boolean {
const parsed = parseExternalModelId(checkpoint);
if (!parsed) return false;
- return (
+ return kimiSearchExcludesThinking(
useExternalProvidersStore
.getState()
.providers.find((candidate) => candidate.id === parsed.providerId)
- ?.providerType === "kimi"
+ ?.providerType,
+ parsed.modelId,
);
}
diff --git a/studio/frontend/tests/external-preserve-thinking.test.ts b/studio/frontend/tests/external-preserve-thinking.test.ts
index 24ca6c39ffc..5b2c82e174c 100644
--- a/studio/frontend/tests/external-preserve-thinking.test.ts
+++ b/studio/frontend/tests/external-preserve-thinking.test.ts
@@ -8,7 +8,7 @@ import ts from "typescript";
import { registerBundlerResolver } from "./helpers/kit.ts";
registerBundlerResolver();
-const { providerSupportsPreserveThinking } = await import("../src/features/chat/provider-capabilities.ts");
+const { providerModelReplaysReasoning, providerSupportsPreserveThinking } = await import("../src/features/chat/provider-capabilities.ts");
const source = readFileSync(new URL("../src/features/chat/api/chat-adapter.ts", import.meta.url), "utf8");
const tree = ts.createSourceFile("adapter.ts", source, ts.ScriptTarget.Latest, true);
let replayExpression = "";
@@ -25,10 +25,19 @@ function visit(node: ts.Node): void {
visit(tree);
assert.ok(replayExpression && payloadExpression);
// Evaluates the real send-path expressions rather than a copied policy.
-const evaluate = new Function("providerSupportsPreserveThinking", "externalProvider", "runtime", "isExternalRequest",
+const evaluateWithModel = new Function("providerSupportsPreserveThinking", "externalProvider", "runtime", "isExternalRequest",
+ "providerModelReplaysReasoning", "externalSelection",
`return { replay: ${replayExpression}, fields: ${payloadExpression} };`) as
- (supports: typeof providerSupportsPreserveThinking, provider: {providerType: string}, runtime: {preserveThinking: boolean}, external: boolean) =>
+ (supports: typeof providerSupportsPreserveThinking, provider: {providerType: string}, runtime: {preserveThinking: boolean}, external: boolean,
+ replays: typeof providerModelReplaysReasoning, selection: {modelId: string}) =>
{replay: boolean; fields: {preserve_thinking?: boolean}};
+const evaluate = (
+ supports: typeof providerSupportsPreserveThinking,
+ provider: {providerType: string},
+ runtime: {preserveThinking: boolean},
+ external: boolean,
+ modelId = "m",
+) => evaluateWithModel(supports, provider, runtime, external, providerModelReplaysReasoning, {modelId});
test("llama.cpp sends the selected value and replays reasoning only when enabled", () => {
for (const enabled of [true, false]) {
@@ -46,3 +55,16 @@ test("switching providers never leaks a retained enabled preference", () => {
}
assert.equal(evaluate(providerSupportsPreserveThinking, {providerType: ""}, {preserveThinking: false}, false).replay, true);
});
+
+test("kimi-k3 replays reasoning whatever the preserve toggle says; k2.6 does not", () => {
+ for (const enabled of [true, false]) {
+ assert.deepEqual(
+ evaluate(providerSupportsPreserveThinking, {providerType: "kimi"}, {preserveThinking: enabled}, true, "kimi-k3"),
+ {replay: true, fields: {}},
+ );
+ assert.equal(
+ evaluate(providerSupportsPreserveThinking, {providerType: "kimi"}, {preserveThinking: enabled}, true, "kimi-k2.6").replay,
+ false,
+ );
+ }
+});
diff --git a/studio/frontend/tests/model-catalog.test.ts b/studio/frontend/tests/model-catalog.test.ts
index 13148e6db0c..d8df88d872a 100644
--- a/studio/frontend/tests/model-catalog.test.ts
+++ b/studio/frontend/tests/model-catalog.test.ts
@@ -169,16 +169,22 @@ test("DeepSeek direct maps the snapshot ladder onto its low / high / max wire",
assert.equal(getExternalReasoningCapabilities("deepseek", "deepseek-unknown").supportsReasoning, false);
});
-test("Qwen and Kimi only have a wire toggle, so a ladder collapses to on/off", () => {
- for (const [provider, model] of [["qwen", "qwen3.5-plus"], ["kimi", "kimi-k3"]] as const) {
- const caps = getExternalReasoningCapabilities(provider, model);
- assert.equal(caps.reasoningStyle, "enable_thinking", model);
- assert.equal(caps.supportsReasoning, true, model);
- assert.equal(caps.supportsReasoningOff, true, model);
- }
+test("Qwen only has a wire toggle, so a ladder collapses to on/off", () => {
+ const caps = getExternalReasoningCapabilities("qwen", "qwen3.5-plus");
+ assert.equal(caps.reasoningStyle, "enable_thinking");
+ assert.equal(caps.supportsReasoning, true);
+ assert.equal(caps.supportsReasoningOff, true);
assert.equal(getExternalReasoningCapabilities("kimi", "kimi-k2.6").supportsReasoning, true);
});
+test("Kimi K3's documented always-on effort ladder outranks the catalog's toggle", () => {
+ // models.dev lists a toggle, but the Kimi API has no thinking switch for kimi-k3.
+ const caps = getExternalReasoningCapabilities("kimi", "kimi-k3");
+ assert.equal(caps.reasoningStyle, "reasoning_effort");
+ assert.equal(caps.supportsReasoningOff, false);
+ assert.deepEqual([...caps.reasoningEffortLevels], ["low", "high", "max"]);
+});
+
test("Mistral models outside the table get the documented none / high form", () => {
const caps = getExternalReasoningCapabilities("mistral", "mistral-medium-latest");
assert.equal(caps.reasoningStyle, "reasoning_effort");
diff --git a/studio/frontend/tests/provider-capabilities-current-models.test.ts b/studio/frontend/tests/provider-capabilities-current-models.test.ts
index ce3b2855fc5..9d644a3e7ba 100644
--- a/studio/frontend/tests/provider-capabilities-current-models.test.ts
+++ b/studio/frontend/tests/provider-capabilities-current-models.test.ts
@@ -16,13 +16,16 @@ const {
getExternalMaxOutputTokens,
getExternalReasoningCapabilities,
getProviderCapabilities,
+ kimiSearchExcludesThinking,
providerHostsCodeExecution,
+ providerModelReplaysReasoning,
providerSupportsBuiltinCodeExecution,
providerSupportsBuiltinImageGeneration,
providerSupportsBuiltinWebSearch,
providerSupportsFastMode,
providerSupportsPreserveThinking,
+ resolveExternalReasoningEffort,
} = await import("../src/features/chat/provider-capabilities.ts");
const {
@@ -558,3 +561,39 @@ test("preserve thinking is available only for explicit llama.cpp connections", (
assert.equal(providerSupportsPreserveThinking(provider), false);
}
});
+
+test("Kimi K3 always thinks at a low/high/max effort and leaves k2.x as they were (#8735)", () => {
+ const k3 = getExternalReasoningCapabilities("kimi", "kimi-k3");
+ assert.equal(k3.supportsReasoning, true);
+ assert.equal(k3.reasoningStyle, "reasoning_effort");
+ assert.equal(k3.supportsReasoningOff, false);
+ assert.deepEqual([...k3.reasoningEffortLevels], ["low", "high", "max"]);
+ assert.equal(clampReasoningEffortToLevels("xhigh", k3.reasoningEffortLevels), "max");
+ assert.equal(getExternalMaxOutputTokens("kimi", "kimi-k3"), 1048576);
+ assert.equal(getProviderCapabilities("kimi", undefined, "kimi-k3")?.presencePenalty, false);
+ assert.equal(kimiSearchExcludesThinking("kimi", "kimi-k3"), false);
+ // A fresh chat's medium would clamp down to low; K3's own default is max.
+ assert.equal(
+ resolveExternalReasoningEffort({ caps: k3, providerType: "kimi", current: "medium" }),
+ "max",
+ );
+ assert.equal(providerModelReplaysReasoning("kimi", "kimi-k3"), true);
+
+ const k26 = getExternalReasoningCapabilities("kimi", "kimi-k2.6");
+ assert.equal(k26.reasoningStyle, "enable_thinking");
+ assert.equal(k26.supportsReasoningOff, true);
+ assert.equal(getProviderCapabilities("kimi", undefined, "kimi-k2.6")?.presencePenalty, true);
+ assert.equal(getExternalMaxOutputTokens("kimi", "kimi-k2.6"), 32768);
+ assert.equal(kimiSearchExcludesThinking("kimi", "kimi-k2.6"), true);
+ assert.equal(kimiSearchExcludesThinking("openai", "kimi-k3"), false);
+ assert.equal(providerModelReplaysReasoning("kimi", "kimi-k2.6"), false);
+});
+
+test("a saved Search choice survives selecting or reloading Kimi K3", () => {
+ const page = readFileSync(
+ path.join(path.dirname(fileURLToPath(import.meta.url)), "../src/features/chat/chat-page.tsx"),
+ "utf8",
+ );
+ assert.doesNotMatch(page, /const isKimi = \w+\?\.providerType === "kimi"/);
+ assert.equal(page.match(/const isKimi = kimiSearchExcludesThinking\(/g)?.length, 2);
+});