BerriAI/litellm · error · ValueError
Azure client is not an instance of AzureOpenAI or OpenAI. Ma
Error message
Azure client is not an instance of AzureOpenAI or OpenAI. Make sure you passed a sync client.
What it means
Error "Azure client is not an instance of AzureOpenAI or OpenAI. Make sure you passed a sync client." thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/azure/batches/handler.py:160
client=client,
_is_async=_is_async,
litellm_params=litellm_params or {},
)
if azure_client is None:
raise ValueError(
"OpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
)
if _is_async is True:
if not isinstance(azure_client, (AsyncAzureOpenAI, AsyncOpenAI)):
raise ValueError(
"Azure client is not an instance of AsyncAzureOpenAI or AsyncOpenAI. Make sure you passed an async client."
)
return self.acancel_batch(cancel_batch_data=cancel_batch_data, client=azure_client)
# At this point, azure_client is guaranteed to be a sync client
if not isinstance(azure_client, (AzureOpenAI, OpenAI)):
raise ValueError(
"Azure client is not an instance of AzureOpenAI or OpenAI. Make sure you passed a sync client."
)
response: Final = azure_client.batches.cancel(**cancel_batch_data)
return LiteLLMBatch.model_validate(response.model_dump())
async def alist_batches(
self,
client: AsyncAzureOpenAI | AsyncOpenAI,
after: str | None = None,
limit: int | None = None,
):
response: Final = await client.batches.list(after=after, limit=limit)
return response
def list_batches(
self,
_is_async: bool,
api_key: str | None,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass an AzureOpenAI or OpenAI (sync) client.
When it happens
Trigger: Thrown at litellm/llms/azure/batches/handler.py:160 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/773c1106671da77c.
Report an issue: GitHub.