Use GOOGLE_API_KEY as default if both GEMINI and GOOGLE set (#777)

This commit is contained in:
Seth Troisi
2025-06-09 13:54:11 -07:00
committed by GitHub
parent 6e5332f716
commit f11414a424
3 changed files with 54 additions and 4 deletions

View File

@@ -188,6 +188,11 @@ async function createContentGeneratorConfig(
const hasVertexProjectLocationConfig =
!!googleCloudProject && !!googleCloudLocation;
if (hasGeminiApiKey && hasGoogleApiKey) {
logger.warn(
'Both GEMINI_API_KEY and GOOGLE_API_KEY are set. Using GOOGLE_API_KEY.',
);
}
if (!hasGeminiApiKey && !hasGoogleApiKey && !hasVertexProjectLocationConfig) {
logger.error(
'No valid API authentication configuration found. Please set ONE of the following combinations in your environment variables or .env file:\n' +
@@ -203,7 +208,7 @@ async function createContentGeneratorConfig(
const config: ContentGeneratorConfig = {
model: argv.model || DEFAULT_GEMINI_MODEL,
apiKey: geminiApiKey || googleApiKey || '',
apiKey: googleApiKey || geminiApiKey || '',
vertexai: hasGeminiApiKey ? false : undefined,
};