mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-12 22:12:37 +00:00
Azure's `_normalize_azure_fields` captures env vars at construction time. When `LLM(model="azure/...")` is instantiated before deployment env vars are set, `self.api_key` / `self.endpoint` freeze as `None` and the lazy client builder then always raises — defeating the point of deferred init for Azure. Re-read `AZURE_API_KEY` / `AZURE_ENDPOINT` (and friends) inside `_make_client_kwargs` when the fields are still unset, matching OpenAI's `_get_client_params` pattern. Runs the endpoint validator on any env-provided value so the same normalization applies. Add a regression test that constructs the LLM with no env vars set, then patches them in afterwards and asserts `_get_sync_client()` successfully builds a client and writes the resolved values back onto the LLM instance.