feat: add kimi code provider onboarding
This commit is contained in:
@@ -157,6 +157,7 @@ export function resolveEnvApiKey(provider: string): EnvApiKeyResult | null {
|
||||
openrouter: "OPENROUTER_API_KEY",
|
||||
"vercel-ai-gateway": "AI_GATEWAY_API_KEY",
|
||||
moonshot: "MOONSHOT_API_KEY",
|
||||
"kimi-code": "KIMICODE_API_KEY",
|
||||
minimax: "MINIMAX_API_KEY",
|
||||
synthetic: "SYNTHETIC_API_KEY",
|
||||
mistral: "MISTRAL_API_KEY",
|
||||
|
||||
@@ -37,6 +37,12 @@ const MOONSHOT_DEFAULT_COST = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
};
|
||||
const KIMI_CODE_BASE_URL = "https://api.kimi.com/coding/v1";
|
||||
const KIMI_CODE_MODEL_ID = "kimi-for-coding";
|
||||
const KIMI_CODE_CONTEXT_WINDOW = 262144;
|
||||
const KIMI_CODE_MAX_TOKENS = 32768;
|
||||
const KIMI_CODE_HEADERS = { "User-Agent": "KimiCLI/0.77" } as const;
|
||||
const KIMI_CODE_COMPAT = { supportsDeveloperRole: false } as const;
|
||||
|
||||
function normalizeApiKeyConfig(value: string): string {
|
||||
const trimmed = value.trim();
|
||||
@@ -184,6 +190,26 @@ function buildMoonshotProvider(): ProviderConfig {
|
||||
};
|
||||
}
|
||||
|
||||
function buildKimiCodeProvider(): ProviderConfig {
|
||||
return {
|
||||
baseUrl: KIMI_CODE_BASE_URL,
|
||||
api: "openai-completions",
|
||||
models: [
|
||||
{
|
||||
id: KIMI_CODE_MODEL_ID,
|
||||
name: "Kimi For Coding",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
cost: MOONSHOT_DEFAULT_COST,
|
||||
contextWindow: KIMI_CODE_CONTEXT_WINDOW,
|
||||
maxTokens: KIMI_CODE_MAX_TOKENS,
|
||||
headers: KIMI_CODE_HEADERS,
|
||||
compat: KIMI_CODE_COMPAT
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function buildSyntheticProvider(): ProviderConfig {
|
||||
return {
|
||||
baseUrl: SYNTHETIC_BASE_URL,
|
||||
@@ -192,7 +218,9 @@ function buildSyntheticProvider(): ProviderConfig {
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveImplicitProviders(params: { agentDir: string }): ModelsConfig["providers"] {
|
||||
export function resolveImplicitProviders(params: {
|
||||
agentDir: string;
|
||||
}): ModelsConfig["providers"] {
|
||||
const providers: Record<string, ProviderConfig> = {};
|
||||
const authStore = ensureAuthProfileStore(params.agentDir, {
|
||||
allowKeychainPrompt: false,
|
||||
@@ -212,6 +240,13 @@ export function resolveImplicitProviders(params: { agentDir: string }): ModelsCo
|
||||
providers.moonshot = { ...buildMoonshotProvider(), apiKey: moonshotKey };
|
||||
}
|
||||
|
||||
const kimiCodeKey =
|
||||
resolveEnvApiKeyVarName("kimi-code") ??
|
||||
resolveApiKeyFromProfiles({ provider: "kimi-code", store: authStore });
|
||||
if (kimiCodeKey) {
|
||||
providers["kimi-code"] = { ...buildKimiCodeProvider(), apiKey: kimiCodeKey };
|
||||
}
|
||||
|
||||
const syntheticKey =
|
||||
resolveEnvApiKeyVarName("synthetic") ??
|
||||
resolveApiKeyFromProfiles({ provider: "synthetic", store: authStore });
|
||||
|
||||
Reference in New Issue
Block a user