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/openai/fine_tuning/handler.py:132

    ) -> LiteLLMFineTuningJob | Coroutine[Any, Any, LiteLLMFineTuningJob]:
        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(
                "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(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)

    async def acancel_fine_tuning_job(
        self,
        fine_tuning_job_id: str,
        openai_client: AsyncOpenAI | AsyncAzureOpenAI,
    ) -> LiteLLMFineTuningJob:
        response: Final = await openai_client.fine_tuning.jobs.cancel(fine_tuning_job_id=fine_tuning_job_id)
        return _litellm_fine_tuning_job_from_response(response)

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass an AsyncOpenAI client instance.

When it happens

Trigger: Thrown at litellm/llms/openai/fine_tuning/handler.py:132 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/a249ebd0fe152a91. Report an issue: GitHub.