from openai import AzureOpenAI
ImportError: cannot import name ‘AzureOpenAI’ from ‘openai’
I am not able to import AzureOpenAI with python 3.11.5 version and openai version 1.10.0.
Hi! Welcome to the forums!
Are you sure you’re using the correct environment? If you get the same issue in REPL (in the terminal where pip show openai shows 1.10.0) then it’s probably a bigger issue.
actually I have 1.11
pip show openai
Name: openai
Version: 1.11.1
Summary: The official Python library for the openai API
Which openai version is compatible with azureopenai
I updated the openai package and the issue was resolved.
pip install -U openai
with below versions, AzureChatOpenAI works perfectly and I upgraded to latest verison and now getting failure:
working versions:
langchain-openai==0.1.3
openai==0.28.1
failure versions:
api versions:
openai=1.84.0
langchain-openai= 0.3.21
Failure:
File “C:\Users\CHNR74\AppData\Roaming\Python\Python311\site-packages\langchain_openai\chat_models\azure.py”, line 191, in validate_environment
values[“client”] = openai.AzureOpenAI(
^^^^^^^^^^^^^^^^^^
AttributeError: module ‘openai’ has no attribute ‘AzureOpenAI’
Below configs provided and same were working in earlier versions:
openai_api_type
model_name
openai_api_key
openai_api_version
azure_endpoint
azure_deployment
)
Appreciate any suggestion?
I don’t use azure but perhaps this might help:
To use this library with Azure OpenAI, use the
AzureOpenAIclass instead of theOpenAIclass.