Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
change base url, search url, etc
Signed-off-by: Richard Chien <[email protected]>
  • Loading branch information
stdrc committed Oct 21, 2025
commit 7f714d620ee282d3f50f1013503c344b45c7d888
56 changes: 22 additions & 34 deletions src/kimi_cli/ui/shell/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
from enum import Enum
from typing import TYPE_CHECKING, NamedTuple

import aiohttp
Expand All @@ -16,34 +15,34 @@
from kimi_cli.ui.shell import ShellApp


class _PlatformKind(Enum):
KIMI_CODING = "kimi-coding"
MOONSHOT_CN = "moonshot-cn"
MOONSHOT_AI = "moonshot-ai"


class _Platform(NamedTuple):
id: str
name: str
base_url: str
search_url: str | None = None
allowed_models: list[str] | None = None


_PLATFORMS = {
_PlatformKind.KIMI_CODING: _Platform(
_PLATFORMS = [
_Platform(
id="kimi-coding",
name="Kimi Coding Plan",
base_url="https://kimi.com/coding/v1",
base_url="https://api.kimi.com/coding/v1",
search_url="https://api.kimi.com/coding/v1/search",
),
_PlatformKind.MOONSHOT_CN: _Platform(
_Platform(
id="moonshot-cn",
name="Moonshot AI 开放平台",
base_url="https://api.moonshot.cn/v1",
allowed_models=["kimi-k2-turbo-preview", "kimi-k2-0905-preview", "kimi-k2-0711-preview"],
),
_PlatformKind.MOONSHOT_AI: _Platform(
_Platform(
id="moonshot-ai",
name="Moonshot AI Open Platform",
base_url="https://api.moonshot.ai/v1",
allowed_models=["kimi-k2-turbo-preview", "kimi-k2-0905-preview", "kimi-k2-0711-preview"],
),
}
]


@meta_command(kimi_soul_only=True)
Expand All @@ -57,24 +56,21 @@ async def setup(app: "ShellApp", args: list[str]):
return

config = load_config()
config.providers[result.platform_kind.value] = LLMProvider(
config.providers[result.platform.id] = LLMProvider(
type="kimi",
base_url=result.base_url,
base_url=result.platform.base_url,
api_key=result.api_key,
)
config.models[result.model_id] = LLMModel(
provider=result.platform_kind.value,
provider=result.platform.id,
model=result.model_id,
max_context_size=result.max_context_size,
)
config.default_model = result.model_id

if result.platform_kind in [
_PlatformKind.KIMI_CODING,
_PlatformKind.MOONSHOT_CN,
]:
if result.platform.search_url:
config.services.moonshot_search = MoonshotSearchConfig(
base_url="https://search.saas.moonshot.cn/v1/search",
base_url=result.platform.search_url,
api_key=result.api_key,
)

Expand All @@ -89,8 +85,7 @@ async def setup(app: "ShellApp", args: list[str]):


class _SetupResult(NamedTuple):
platform_kind: _PlatformKind
base_url: str
platform: _Platform
api_key: SecretStr
model_id: str
max_context_size: int
Expand All @@ -100,19 +95,13 @@ async def _setup() -> _SetupResult | None:
# select the API platform
platform_name = await _prompt_choice(
header="Select the API platform",
choices=[platform.name for platform in _PLATFORMS.values()],
choices=[platform.name for platform in _PLATFORMS],
)
if not platform_name:
console.print("[bold red]No platform selected[/bold red]")
return None

platform_kind = next(
platform_key
for platform_key, platform in _PLATFORMS.items()
if platform.name == platform_name
)
assert platform_kind is not None
platform = _PLATFORMS[platform_kind]
platform = next(platform for platform in _PLATFORMS if platform.name == platform_name)

# enter the API key
api_key = await _prompt_text("Enter your API key", is_password=True)
Expand Down Expand Up @@ -157,11 +146,10 @@ async def _setup() -> _SetupResult | None:
return None

return _SetupResult(
platform_kind=platform_kind,
base_url=platform.base_url,
platform=platform,
api_key=SecretStr(api_key),
model_id=model_id,
max_context_size=200_000, # TODO: get from model
max_context_size=200_000, # TODO: get from model data
)


Expand Down