diff --git a/backend/agent/run.py b/backend/agent/run.py index 2d3ba16e..d6967a7e 100644 --- a/backend/agent/run.py +++ b/backend/agent/run.py @@ -492,6 +492,9 @@ async def run_agent( elif "gemini-2.5-pro" in model_name.lower(): # Gemini 2.5 Pro has 64k max output tokens max_tokens = 64000 + elif "kimi-k2" in model_name.lower(): + # Kimi-K2 has 120K context, set reasonable max output tokens + max_tokens = 8192 generation = trace.generation(name="thread_manager.run_thread") if trace else None try: diff --git a/backend/services/llm.py b/backend/services/llm.py index 6187e247..7045294c 100644 --- a/backend/services/llm.py +++ b/backend/services/llm.py @@ -232,6 +232,12 @@ def prepare_params( use_thinking = enable_thinking if enable_thinking is not None else False is_anthropic = "anthropic" in effective_model_name.lower() or "claude" in effective_model_name.lower() is_xai = "xai" in effective_model_name.lower() or model_name.startswith("xai/") + is_kimi_k2 = "kimi-k2" in effective_model_name.lower() or model_name.startswith("moonshotai/kimi-k2") + + if is_kimi_k2: + params["provider"] = { + "order": ["groq", "together/fp8"] + } if is_anthropic and use_thinking: effort_level = reasoning_effort if reasoning_effort else 'low' diff --git a/backend/utils/constants.py b/backend/utils/constants.py index 9d85684f..4a0ac589 100644 --- a/backend/utils/constants.py +++ b/backend/utils/constants.py @@ -53,6 +53,14 @@ MODELS = { }, "tier_availability": ["paid"] }, + "openrouter/moonshotai/kimi-k2": { + "aliases": ["moonshotai/kimi-k2", "kimi-k2"], + "pricing": { + "input_cost_per_million_tokens": 1.00, + "output_cost_per_million_tokens": 3.00 + }, + "tier_availability": ["paid"] + }, "openai/gpt-4o": { "aliases": ["gpt-4o"], "pricing": { diff --git a/frontend/src/components/thread/chat-input/_use-model-selection.ts b/frontend/src/components/thread/chat-input/_use-model-selection.ts index 7687e1ed..d1ac4643 100644 --- a/frontend/src/components/thread/chat-input/_use-model-selection.ts +++ b/frontend/src/components/thread/chat-input/_use-model-selection.ts @@ -70,6 +70,12 @@ export const MODELS = { recommended: false, lowQuality: false }, + 'moonshotai/kimi-k2': { + tier: 'premium', + priority: 96, + recommended: false, + lowQuality: false + }, 'gpt-4.1': { tier: 'premium', priority: 96,