Onboard: store OpenAI auth in profiles instead of .env

This commit is contained in:
joshavant
2026-02-21 14:55:56 -08:00
committed by Peter Steinberger
parent 09c7cb5d34
commit 68b9d89ee7
6 changed files with 131 additions and 26 deletions

View File

@@ -42,6 +42,7 @@ import {
setMistralApiKey,
setMinimaxApiKey,
setMoonshotApiKey,
setOpenaiApiKey,
setOpencodeZenApiKey,
setOpenrouterApiKey,
setSyntheticApiKey,
@@ -408,15 +409,16 @@ export async function applyNonInteractiveAuthChoice(params: {
flagName: "--openai-api-key",
envVar: "OPENAI_API_KEY",
runtime,
allowProfile: false,
});
if (!resolved) {
return null;
}
const key = resolved.key;
const result = upsertSharedEnvVar({ key: "OPENAI_API_KEY", value: key });
process.env.OPENAI_API_KEY = key;
runtime.log(`Saved OPENAI_API_KEY to ${shortenHomePath(result.path)}`);
await setOpenaiApiKey(resolved.key);
nextConfig = applyAuthProfileConfig(nextConfig, {
profileId: "openai:default",
provider: "openai",
mode: "api_key",
});
return applyOpenAIConfig(nextConfig);
}