{"record":{"id":"2c0400d3215dccd8","repo":"BerriAI/litellm","slug":"azure-openai-client-is-not-initialized-make-sure","errorCode":null,"errorMessage":"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY is set in the environment.","messagePattern":"Azure OpenAI client is not initialized\\. Make sure api_key is passed or AZURE_API_KEY is set in the environment\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure/fine_tuning/handler.py","lineNumber":83,"sourceCode":"        timeout: float | httpx.Timeout,\n        max_retries: int | None,\n        organization: str | None,\n        client: OpenAI | AsyncOpenAI | AzureOpenAI | AsyncAzureOpenAI | None = None,\n    ) -> LiteLLMFineTuningJob | Coroutine[Any, Any, LiteLLMFineTuningJob]:\n        self._ensure_training_type(create_fine_tuning_job_data)\n\n        openai_client: Final[OpenAI | AsyncOpenAI | AzureOpenAI | AsyncAzureOpenAI | None] = self.get_openai_client(\n            api_key=api_key,\n            api_base=api_base,\n            timeout=timeout,\n            max_retries=max_retries,\n            organization=organization,\n            client=client,\n            _is_async=_is_async,\n            api_version=api_version,\n        )\n        if openai_client is None:\n            raise ValueError(\n                \"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY is set in the environment.\"\n            )\n\n        if _is_async is True:\n            if not isinstance(openai_client, (AsyncOpenAI, AsyncAzureOpenAI)):\n                raise ValueError(\n                    \"OpenAI client is not an instance of AsyncOpenAI. Make sure you passed an AsyncOpenAI client.\"\n                )\n            return self.acreate_fine_tuning_job(\n                create_fine_tuning_job_data=create_fine_tuning_job_data,\n                openai_client=openai_client,\n            )\n\n        verbose_logger.debug(\"creating fine tuning job, args= %s\", create_fine_tuning_job_data)\n        response: Final = cast(OpenAI, openai_client).fine_tuning.jobs.create(**create_fine_tuning_job_data)\n        return _litellm_fine_tuning_job_from_response(response, is_azure=True)\n\n    def cancel_fine_tuning_job(","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/azure/fine_tuning/handler.py#L65-L101","documentation":"Error \"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY is set in the environment.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/azure/fine_tuning/handler.py:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set AZURE_API_KEY or pass api_key so the Azure OpenAI client initializes."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}