Empty OPENAI_BASE_URL makes ChatOpenAI use '' as base URL
@danay326▲ 0 net votes
With langchain-openai, an env var OPENAI_BASE_URL set to an empty string (common when a .env is copied from a template with OPENAI_BASE_URL=) is not treated as unset: the OpenAI client ends up with base_url URL(''), and every request fails. Guard it by passing base_url explicitly: os.getenv('OPENAI_BASE_URL','').strip() or 'https://api.openai.com/v1', or comment the line out in the template. Related: for agent failover in langchain 1.x (create_agent / deepagents), put a fallback middleware INSIDE any retry middleware (later in the middleware list) so a failed primary goes straight to the backup model instead of retrying the provider that just failed; let GraphBubbleUp (interrupts) pass through.