-
Checked other resources
Commit to Help
Example Codechat_llm = AzureChatOpenAI(
deployment_name=os.environ["azure_deployment"],
model_name=os.environ['azure_deployment'],
api_version=os.environ['openai_api_version'],
api_key=os.environ['api_key'],
azure_endpoint=os.environ['azure_endpoint']
)
llm = AzureOpenAI(
deployment_name=os.environ["azure_deployment"],
model_name=os.environ['azure_deployment'],
api_version=os.environ['openai_api_version'],
api_key=os.environ['api_key'],
azure_endpoint=os.environ['azure_endpoint']
) DescriptionHi All, I am encountering an issue while trying to initialize the AzureOpenAI client. The error message states: "As of openai>=1.0.0, Azure endpoints should be specified via the azure_endpoint parameter, not openai_api_base (or alias base_url). (type=value_error)" Interestingly, I do not face this issue when initializing the AzureChatOpenAI client with similar parameters. It seems the two clients handle the endpoint configuration differently. Could someone please advise on why this discrepancy exists and how to resolve the issue for AzureOpenAI? System Infolangchain==0.2.14 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey there, @toshnav! I'm here to help you with any bugs, questions, or to assist you in becoming a contributor. The From the provided code, the following conditions can trigger a
These validation checks ensure that the parameters are correctly set for the Azure OpenAI client. If these conditions are not met, a To resolve this issue, ensure that:
Here is an example of correct initialization: from langchain_openai import AzureOpenAI
openai = AzureOpenAI(
azure_deployment="your-deployment-name",
azure_endpoint="https://<your-endpoint>.openai.azure.com/",
api_key="your-api-key",
openai_api_version="2023-05-15"
) Ensure that the environment variables or parameters are set correctly to avoid validation errors [1][2][3]. |
Beta Was this translation helpful? Give feedback.
Hey there, @toshnav! I'm here to help you with any bugs, questions, or to assist you in becoming a contributor.
The
ValidationError
when initializing theAzureOpenAI
client is likely due to the validation logic in thevalidate_environment
method of theAzureOpenAI
class. Specifically, the error can occur if theopenai_api_base
(or its aliasbase_url
) is specified incorrectly or conflicts with thedeployment_name
(or its aliasazure_deployment
) parameter.From the provided code, the following conditions can trigger a
ValidationError
:If
openai_api_base
is specified and does not contain/openai
, it will raise aValueError
: