LangChain provider package version drift — langchain-openai, langchain-anthropic, langchain-google-genai (2026) — Fix Guide (2026) | AI Error Hub
Home Providers LangChain Package version drift
LangChain Packaging · Versions Severity: High HTTP n/a

LangChain package version driftlangchain-openai, langchain-anthropic, langchain-google-genai conflicts

The LangChain ecosystem is not one package — it is a family of independently versioned integration packages. Version drift between them and <code>langchain-core</code> causes some of the most confusing errors in the framework.

By Ahmed R. · Senior AI Infrastructure Engineer Published 2026-07-26 Verified 2026-07-26

Quick fix (TL;DR)

Resolution: LangChain splits into langchain-core, langchain, langchain-community, and per-provider integrations (langchain-openai, langchain-anthropic, langchain-google-genai, etc.). Fix version conflicts by (a) pinning exact versions of every LangChain package in a lockfile, (b) upgrading them together, (c) reading the release notes for breaking changes, and (d) using pip install --upgrade langchain-* as a coordinated upgrade.

Real error messages you'll see

These are the exact strings returned by the LangChain framework and its integrations when this error occurs. Copy-paste-searching any of them should land on this page.

ImportError after upgrading one package
ImportError: cannot import name 'ChatOpenAI' from 'langchain_openai'
# langchain-openai 0.3.x has ChatOpenAI in langchain_openai.chat_models
# your code imports from langchain_openai directly — worked in 0.1.x
Pydantic v1/v2 clash between packages
TypeError: BaseModel.__init_subclass__() got unexpected keyword argument
# One package pulled Pydantic v1; another needs v2
Runtime schema mismatch
ValueError: Received unsupported message type. AIMessage.tool_calls field is expected but got AIMessage without tool_calls.
# langchain-core 0.3+ uses new AIMessage shape;
# langchain-openai < 0.2 still emits old shape

Reference

Current LangChain package family (2026)

PackagePurpose
langchain-coreRunnables, prompts, messages, output parsers — the foundation
langchainChains, agents, retrievers, higher-level primitives
langchain-communityCommunity integrations (vector stores, chat message history backends)
langchain-openaiOpenAI + Azure OpenAI chat and embedding models
langchain-anthropicClaude chat models on Anthropic API
langchain-google-genaiGoogle Gemini via Generative AI API
langchain-google-vertexaiGoogle Vertex AI (including Claude on Vertex)
langchain-awsBedrock, DynamoDB history, other AWS services
langchain-chroma, langchain-pinecone, etc.Per-vendor vector store integrations
langgraphStateful agent framework (separate SDK, compatible with LangChain)
langsmithTracing / evals (separate SDK)

Root causes, ranked by frequency

Based on developer reports across LangChain forums, GitHub issues, and Discord community during 2025–2026.

  • 28%
    Uncoordinated upgrade. pip install --upgrade langchain-openai pulls a new version incompatible with your pinned langchain-core.
  • 18%
    Pydantic v1/v2 conflict. A package still on Pydantic v1 in a project with newer packages on v2.
  • 14%
    Import path changed. Classes moved between subpackages between major versions.
  • 10%
    Community package split. What used to be in langchain-community moved to its own package.
  • 8%
    Deprecated compat shim removed. Alias for old class removed in a minor release.
  • 8%
    Missing peer dependency. Provider package needs a specific extra (pip install "langchain-openai[async]").
  • 7%
    Non-LangChain package pulling old versions. A downstream framework transitively pins an old langchain-core.
  • 7%
    Lockfile out of date. requirements.txt regenerated without care; wildly different versions land in prod.

Fixes — copy-paste solutions

Fix #1

Pin every LangChain package to exact versions

The single most important fix.

Use a lockfile (pyproject.toml + pip-compile, or poetry.lock, or uv.lock) that pins every LangChain package to an exact version. Upgrade them together.

pyproject.toml
# ---------------------------------------
# pyproject.toml — pin every langchain-* package
# ---------------------------------------
[project]
name = "myapp"
requires-python = ">=3.11"

dependencies = [
    # Foundation — pin exact
    "langchain-core==0.3.28",
    "langchain==0.3.25",
    "langchain-community==0.3.15",

    # Provider integrations — pin exact
    "langchain-openai==0.2.19",
    "langchain-anthropic==0.2.10",
    "langchain-google-genai==2.0.9",

    # Vector store integration
    "langchain-chroma==0.1.4",

    # LangGraph if used
    "langgraph==0.2.62",

    # LangSmith for tracing (optional but recommended)
    "langsmith==0.2.11",

    # Pydantic — LangChain 0.3+ requires v2
    "pydantic>=2.5,<3.0",
]
coordinated_upgrade.sh
# Coordinated upgrade — all langchain-* packages together
pip install --upgrade \
    langchain-core \
    langchain \
    langchain-community \
    langchain-openai \
    langchain-anthropic \
    langchain-google-genai \
    langchain-chroma \
    langgraph \
    langsmith

# Then re-lock
pip freeze | grep -E "^(langchain|langgraph|langsmith|pydantic)" > current_versions.txt
cat current_versions.txt

# Update pyproject.toml with the new pins, run your test suite,
# then commit both the pyproject.toml and the lockfile together.
Upgrading one LangChain package at a time is the biggest source of subtle runtime errors. Always upgrade the family together, test, then commit.
Fix #2

Audit for compatible versions after an upgrade

Quick sanity check that catches most drift issues.

A small script that instantiates the classes you use with a smoke test. Catches import errors, Pydantic issues, and runtime shape mismatches in seconds.

version_audit.py
"""Quick smoke test to verify LangChain package compatibility."""
import sys

def check_import(name: str):
    try:
        __import__(name)
        mod = sys.modules[name]
        version = getattr(mod, "__version__", None)
        print(f"{name:35s} {version}")
        return True
    except ImportError as e:
        print(f"{name:35s} ImportError: {e}")
        return False

packages_to_check = [
    "langchain_core",
    "langchain",
    "langchain_community",
    "langchain_openai",
    "langchain_anthropic",
    "langchain_google_genai",
    "langchain_chroma",
    "langgraph",
    "langsmith",
    "pydantic",
]

print("=== Package versions ===")
all_ok = all(check_import(name) for name in packages_to_check)

# Smoke tests: instantiate + basic call for each provider you use
if all_ok:
    print("\n=== Smoke tests ===")

    from langchain_core.prompts import ChatPromptTemplate
    from langchain_core.output_parsers import StrOutputParser
    from langchain_openai import ChatOpenAI
    from langchain_anthropic import ChatAnthropic

    prompt = ChatPromptTemplate.from_template("Say hi in one word.")

    for name, llm_factory in [
        ("openai",     lambda: ChatOpenAI(model="gpt-4o-mini")),
        ("anthropic",  lambda: ChatAnthropic(model="claude-haiku-4-5-20251001")),
    ]:
        try:
            chain = prompt | llm_factory() | StrOutputParser()
            result = chain.invoke({})
            print(f"{name:15s} chain works — got {result[:30]!r}")
        except Exception as e:
            print(f"{name:15s} FAILED — {type(e).__name__}: {e}")

# Verify Pydantic version is 2.x
import pydantic
if pydantic.VERSION.split(".")[0] != "2":
    print(f"\n✗ WARNING: Pydantic is {pydantic.VERSION}; LangChain 0.3+ requires v2")
Run this after every upgrade AND as a CI job. Version drift catches you silently — a smoke test surfaces it immediately.
Fix #3

Read the release notes; watch for breaking changes

Migration guides are published for major changes.

The LangChain team publishes migration guides for major changes (0.1 → 0.2, 0.2 → 0.3). Skim them before upgrading. Some breaking changes are subtle and only surface in production.

known_breaking_migrations.md
# Notable LangChain migrations (as of 2026)

## 0.3 (October 2024)
Breaking: Pydantic v1 no longer supported anywhere
Breaking: `langchain.embeddings.OpenAIEmbeddings` moved to `langchain_openai.OpenAIEmbeddings`
Deprecated: Old memory classes (ConversationBufferMemory, etc.)
Deprecated: LLMChain, ConversationChain
Migration: See our "Deprecated memory migration" page (page 99)

## 0.2 (May 2024)
Breaking: Provider integrations split into separate packages
Breaking: `langchain.chat_models` no longer contains the actual implementations
  - `from langchain.chat_models import ChatOpenAI` STILL WORKS via shim
  - PREFERRED: `from langchain_openai import ChatOpenAI`
Breaking: `LangChainOutputParserException` renamed to `OutputParserException`

## 0.1 (January 2024)
Breaking: LangChain Expression Language (LCEL) becomes the primary API
Legacy: Chain classes still work but no longer the recommended pattern

## Ongoing (0.3.x minor releases)
- New AIMessage tool_calls / usage_metadata field standardisation
- with_structured_output method="json_schema" support expanded to more providers
- Provider-specific betas may add/rename beta headers

## Watch for
- LangGraph 0.x → 1.0 migration (upcoming; watch langgraph release notes)
- LangSmith SDK client rewrites (occasional; usually additive)
- Individual provider SDKs bumping major versions (langchain-openai stays in sync with openai SDK majors)

# Practical approach:
# 1) Subscribe to LangChain GitHub releases
# 2) Follow the LangChain blog for major version launches
# 3) Run version_audit.py after every upgrade
The LangChain project moves fast. Budget ~1 hour per quarter for reading release notes and running an audit — much cheaper than a production incident.

Prevention checklist

Ship these seven safeguards once and this error stops appearing in your logs.

  • Pin every langchain-* package to an exact version in your lockfile.
  • Upgrade the whole family in one coordinated change, then re-test.
  • Run a smoke-test script after every upgrade to catch import and runtime drift.
  • Read release notes on every major bump (0.2 → 0.3, etc.).
  • Ensure Pydantic v2 project-wide; do not mix with v1.
  • Set up CI to catch version conflicts before merge.
  • Watch downstream libraries that pin LangChain — they may drag you backwards.

Frequently asked questions

For runnables, prompts, messages, and parsers: use langchain-core. For agents, chains (deprecated), and higher-level utilities: use langchain. For chat models and embeddings: use the specific provider package (e.g. langchain-openai).
Isolation. Each provider can update independently. You install only what you use — langchain-openai without langchain-anthropic if you do not use Claude. This makes dependency trees cleaner and upgrades safer.
Yes — langchain-community is optional. If your integrations are all in provider-specific packages (openai, anthropic, etc.), you may never need community. For older integrations still there, you do.
Use pipdeptree to see your dep graph, or run python -c "import langchain; help(langchain)" and audit imports. For a cleanup, use pip-uninstall after moving to the specific provider packages.
It is a separate SDK but designed to compose with LangChain runnables. You can use LangChain models and prompts inside a LangGraph workflow. Version compatibility is generally good; still, pin both.

Get the weekly AI-error digest

New fixes, provider status recaps, and one deep tutorial — every Tuesday. 8,400+ engineers.