fix: set codex oauth model default

This commit is contained in:
Peter Steinberger
2026-01-06 02:48:53 +01:00
parent 17db03ad55
commit 20705d1b37
6 changed files with 179 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import { getShellEnvAppliedKeys } from "../infra/shell-env.js";
import {
type AuthProfileStore,
ensureAuthProfileStore,
listProfilesForProvider,
resolveApiKeyForProfile,
resolveAuthProfileOrder,
} from "./auth-profiles.js";
@@ -83,6 +84,15 @@ export async function resolveApiKeyForProvider(params: {
return { apiKey: customKey, source: "models.json" };
}
if (provider === "openai") {
const hasCodex = listProfilesForProvider(store, "openai-codex").length > 0;
if (hasCodex) {
throw new Error(
'No API key found for provider "openai". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.2 (ChatGPT OAuth) or set OPENAI_API_KEY for openai/gpt-5.2.',
);
}
}
throw new Error(`No API key found for provider "${provider}".`);
}