BerriAI/litellm · error · ValueError
OpenAI client is not an instance of AsyncOpenAI. Make sure y
Error message
OpenAI client is not an instance of AsyncOpenAI. Make sure you passed an AsyncOpenAI client.
What it means
Error "OpenAI client is not an instance of AsyncOpenAI. Make sure you passed an AsyncOpenAI client." thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/azure/batches/handler.py:69
client: AzureOpenAI | AsyncAzureOpenAI | OpenAI | AsyncOpenAI | None = None,
litellm_params: dict | None = None,
) -> LiteLLMBatch | Coroutine[object, object, LiteLLMBatch]:
azure_client: AzureOpenAI | AsyncAzureOpenAI | OpenAI | AsyncOpenAI | None = self.get_azure_openai_client(
api_key=api_key,
api_base=api_base,
api_version=api_version,
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(
"OpenAI client is not an instance of AsyncOpenAI. Make sure you passed an AsyncOpenAI client."
)
return self.acreate_batch(create_batch_data=create_batch_data, azure_client=azure_client)
response = cast(AzureOpenAI | OpenAI, azure_client).batches.create(**create_batch_data)
return LiteLLMBatch.model_validate(response.model_dump())
async def aretrieve_batch(
self,
retrieve_batch_data: RetrieveBatchRequest,
client: AsyncAzureOpenAI | AsyncOpenAI,
) -> LiteLLMBatch:
response: Final = await client.batches.retrieve(**retrieve_batch_data)
return LiteLLMBatch.model_validate(response.model_dump())
def retrieve_batch(
self,
_is_async: bool,
retrieve_batch_data: RetrieveBatchRequest,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass an AsyncOpenAI client instance.
When it happens
Trigger: Thrown at litellm/llms/azure/batches/handler.py:69 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/f21f633cbac94c81.
Report an issue: GitHub.