azure_openai_configTier 1 · 70% confidence

ai-agents-azure-openai-config-using-azurechatopenai-with-openai-1-0-0-when-both--2e529775

agent: ai_agents

When does this happen?

IF Using AzureChatOpenAI with openai>=1.0.0 when both AZURE_OPENAI_ENDPOINT and OPENAI_API_BASE (or openai_api_base) are set results in pydantic validation error: 'base_url and azure_endpoint are mutually exclusive'.

How others solved it

THEN Ensure only one of azure_endpoint or base_url is provided. Set only AZURE_OPENAI_ENDPOINT (and optionally AZURE_OPENAI_API_KEY) and unset any OPENAI_API_BASE or openai_api_base environment variable. In code, pass only azure_endpoint and azure_deployment, avoiding openai_api_base. As a temporary workaround, comment out the client initialization line for base_url in the langchain source file (langchain/chat_models/azure_openai.py).

import os
from langchain.chat_models import AzureChatOpenAI

# Correct: only AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_API_KEY set
# Unset OPENAI_API_BASE if present
model = AzureChatOpenAI(
    openai_api_version="2023-09-01-preview",
    azure_deployment="gpt-35-turbo"
)

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics