AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Langchain-Openai Defaults To Retired OpenAI Models Causing API Errors

The OpenAI and ChatOpenAI classes in langchain-openai default to gpt-3.5-turbo-instruct and gpt-3.5-turbo respectively. OpenAI shut down gpt-3.5-turbo-instruct on September 28, 2026, and gpt-3.5-turbo will be shut down on October 23, 2026. Users who do not explicitly pass a model will encounter API errors. The recommended replacement gpt-5.6-terra is a reasoning model and does not support the legacy completions endpoint, requiring a strategic change to defaults.

highConfidence 95%Langchain-OpenaiEmbeddingsVector StoresChat Models

Origin Analysis

The default model_name fields in langchain_openai/llms/base.py and langchain_openai/chat_models/base.py are hardcoded to retired models. There is no dynamic resolution or validation that prevents usage of deprecated endpoints.
from langchain_openai import ChatOpenAI, OpenAI OpenAI().invoke("Say hi") # Uses retired gpt-3.5-turbo-instruct ChatOpenAI().invoke("Say hi") # Uses soon-to-be-retired gpt-3.5-turbo

Fixing Code Block

Edge Case Audit

This fix introduces breaking changes: users who relied on the old default models must now set model names explicitly. For ChatOpenAI, gpt-5.6-terra is a reasoning model that does not accept temperature or max_tokens (use max_completion_tokens); existing code passing these parameters may break. The OpenAI completions class now raises an error if no model is provided, which may require users to migrate to ChatOpenAI. In multi-threaded environments, ensure model validation is thread-safe (pydantic validators are safe but global default mutation is not recommended). Rollback: revert to previous package version and pin model names in application code to avoid unintended model changes.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state