diff --git a/packages/core/src/core/contentGenerator.test.ts b/packages/core/src/core/contentGenerator.test.ts index 57ce1fed23..4bacd1b488 100644 --- a/packages/core/src/core/contentGenerator.test.ts +++ b/packages/core/src/core/contentGenerator.test.ts @@ -725,6 +725,26 @@ describe('createContentGeneratorConfig', () => { expect(config.apiKey).toBeUndefined(); expect(config.vertexai).toBeUndefined(); }); + it('should configure for GATEWAY using dummy placeholder if GEMINI_API_KEY is set', async () => { + vi.stubEnv('GEMINI_API_KEY', 'env-gemini-key'); + const config = await createContentGeneratorConfig( + mockConfig, + AuthType.GATEWAY, + ); + expect(config.apiKey).toBe('gateway-placeholder-key'); + expect(config.vertexai).toBe(false); + }); + + it('should configure for GATEWAY using dummy placeholder if GEMINI_API_KEY is not set', async () => { + vi.stubEnv('GEMINI_API_KEY', ''); + vi.mocked(loadApiKey).mockResolvedValue(null); + const config = await createContentGeneratorConfig( + mockConfig, + AuthType.GATEWAY, + ); + expect(config.apiKey).toBe('gateway-placeholder-key'); + expect(config.vertexai).toBe(false); + }); }); describe('validateBaseUrl', () => { diff --git a/packages/core/src/core/contentGenerator.ts b/packages/core/src/core/contentGenerator.ts index 60641abdeb..ff1739c04b 100644 --- a/packages/core/src/core/contentGenerator.ts +++ b/packages/core/src/core/contentGenerator.ts @@ -150,6 +150,13 @@ export async function createContentGeneratorConfig( return contentGeneratorConfig; } + if (authType === AuthType.GATEWAY) { + contentGeneratorConfig.apiKey = apiKey || 'gateway-placeholder-key'; + contentGeneratorConfig.vertexai = false; + + return contentGeneratorConfig; + } + return contentGeneratorConfig; }