diff --git a/CulinaryCommandApp/Program.cs b/CulinaryCommandApp/Program.cs index 5d69361..21a8960 100644 --- a/CulinaryCommandApp/Program.cs +++ b/CulinaryCommandApp/Program.cs @@ -124,12 +124,10 @@ // ===================== // AI Services // ===================== -builder.Services.AddSingleton(sp => -{ - var apiKey = builder.Configuration["Google:ApiKey"] - ?? throw new InvalidOperationException("Google:ApiKey is not configured."); - return new Client(apiKey: apiKey); -}); +var googleApiKey = builder.Configuration["Google:ApiKey"] + ?? Environment.GetEnvironmentVariable("GOOGLE_API_KEY") + ?? throw new InvalidOperationException("Missing config: Google:ApiKey (or GOOGLE_API_KEY env var)."); +builder.Services.AddSingleton(new Client(apiKey: googleApiKey)); builder.Services.AddScoped(); //