{"record":{"id":"773c1106671da77c","repo":"BerriAI/litellm","slug":"azure-client-is-not-an-instance-of-azureopenai-or-773c11","errorCode":null,"errorMessage":"Azure client is not an instance of AzureOpenAI or OpenAI. Make sure you passed a sync client.","messagePattern":"Azure client is not an instance of AzureOpenAI or OpenAI\\. Make sure you passed a sync client\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure/batches/handler.py","lineNumber":160,"sourceCode":"            client=client,\n            _is_async=_is_async,\n            litellm_params=litellm_params or {},\n        )\n        if azure_client is None:\n            raise ValueError(\n                \"OpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment.\"\n            )\n\n        if _is_async is True:\n            if not isinstance(azure_client, (AsyncAzureOpenAI, AsyncOpenAI)):\n                raise ValueError(\n                    \"Azure client is not an instance of AsyncAzureOpenAI or AsyncOpenAI. Make sure you passed an async client.\"\n                )\n            return self.acancel_batch(cancel_batch_data=cancel_batch_data, client=azure_client)\n\n        # At this point, azure_client is guaranteed to be a sync client\n        if not isinstance(azure_client, (AzureOpenAI, OpenAI)):\n            raise ValueError(\n                \"Azure client is not an instance of AzureOpenAI or OpenAI. Make sure you passed a sync client.\"\n            )\n        response: Final = azure_client.batches.cancel(**cancel_batch_data)\n        return LiteLLMBatch.model_validate(response.model_dump())\n\n    async def alist_batches(\n        self,\n        client: AsyncAzureOpenAI | AsyncOpenAI,\n        after: str | None = None,\n        limit: int | None = None,\n    ):\n        response: Final = await client.batches.list(after=after, limit=limit)\n        return response\n\n    def list_batches(\n        self,\n        _is_async: bool,\n        api_key: str | None,","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/batches/handler.py#L142-L178","documentation":"Error \"Azure client is not an instance of AzureOpenAI or OpenAI. Make sure you passed a sync client.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/azure/batches/handler.py:160 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an AzureOpenAI or OpenAI (sync) client."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}