BerriAI/litellm · error · ValueError
Azure OpenAI client is not initialized. Make sure api_key…
Error message
Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY is set in the environment.
What it means
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.
Solutions
- Set AZURE_API_KEY or pass api_key so the Azure OpenAI client initializes.
When it happens
Trigger: Thrown at litellm/llms/azure/fine_tuning/handler.py:83 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/2c0400d3215dccd8.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/azure/fine_tuning/handler.py:83
timeout: float | httpx.Timeout,
max_retries: int | None,
organization: str | None,
client: OpenAI | AsyncOpenAI | AzureOpenAI | AsyncAzureOpenAI | None = None,
) -> LiteLLMFineTuningJob | Coroutine[Any, Any, LiteLLMFineTuningJob]:
self._ensure_training_type(create_fine_tuning_job_data)
openai_client: Final[OpenAI | AsyncOpenAI | AzureOpenAI | AsyncAzureOpenAI | None] = self.get_openai_client(
api_key=api_key,
api_base=api_base,
timeout=timeout,
max_retries=max_retries,
organization=organization,
client=client,
_is_async=_is_async,
api_version=api_version,
)
if openai_client is None:
raise ValueError(
"Azure OpenAI client is not initialized. Make sure api_key is passed or AZURE_API_KEY is set in the environment."
)
if _is_async is True:
if not isinstance(openai_client, (AsyncOpenAI, AsyncAzureOpenAI)):
raise ValueError(
"OpenAI client is not an instance of AsyncOpenAI. Make sure you passed an AsyncOpenAI client."
)
return self.acreate_fine_tuning_job(
create_fine_tuning_job_data=create_fine_tuning_job_data,
openai_client=openai_client,
)
verbose_logger.debug("creating fine tuning job, args= %s", create_fine_tuning_job_data)
response: Final = cast(OpenAI, openai_client).fine_tuning.jobs.create(**create_fine_tuning_job_data)
return _litellm_fine_tuning_job_from_response(response, is_azure=True)
def cancel_fine_tuning_job(View on GitHub (pinned to 77b7c6c40c)