mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-11 21:42:36 +00:00
`_normalize_gemini_fields` captures `GOOGLE_API_KEY` / `GEMINI_API_KEY` / `GOOGLE_CLOUD_PROJECT` at construction time, so an LLM constructed before deployment env vars are set would freeze `self.api_key = None` and the lazy `_get_sync_client` build would then always auth-fail. Re-read the env vars inside `_get_sync_client` when `self._client` is None and the corresponding field is still unset, matching the pattern used for the other native providers. Add a regression test that constructs `GeminiCompletion` with no env vars set, patches them in afterwards, and asserts the lazy build succeeds and writes the resolved key back onto the LLM.