feat: add support for Moonshot API key for China endpoint

This commit is contained in:
Liu Weizhan
2026-02-02 20:25:14 +08:00
committed by Peter Steinberger
parent 9f16de2533
commit 1c6b25ddbb
13 changed files with 143 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ import {
applyMinimaxApiConfig,
applyMinimaxConfig,
applyMoonshotConfig,
applyMoonshotConfigCn,
applyOpencodeZenConfig,
applyOpenrouterConfig,
applySyntheticConfig,
@@ -303,6 +304,29 @@ export async function applyNonInteractiveAuthChoice(params: {
return applyMoonshotConfig(nextConfig);
}
if (authChoice === "moonshot-api-key-cn") {
const resolved = await resolveNonInteractiveApiKey({
provider: "moonshot",
cfg: baseConfig,
flagValue: opts.moonshotApiKey,
flagName: "--moonshot-api-key",
envVar: "MOONSHOT_API_KEY",
runtime,
});
if (!resolved) {
return null;
}
if (resolved.source !== "profile") {
await setMoonshotApiKey(resolved.key);
}
nextConfig = applyAuthProfileConfig(nextConfig, {
profileId: "moonshot:default",
provider: "moonshot",
mode: "api_key",
});
return applyMoonshotConfigCn(nextConfig);
}
if (authChoice === "kimi-code-api-key") {
const resolved = await resolveNonInteractiveApiKey({
provider: "kimi-coding",