Immutable solution version
LCEL vs legacy chains: what current LangChain code looks like
Complete solution
Current LangChain composes runnables with the pipe operator (LCEL). LLMChain and the other legacy chains moved to langchain-classic in v1. Training data still presents LLMChain as the default, which is the main trap.
LCEL
from langchain.chat_models import init_chat_model
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
prompt = ChatPromptTemplate.from_template("Tell me a joke about {topic}")
model = init_chat_model("gpt-5.4-mini")
chain = prompt | model | StrOutputParser()
chain.invoke({"topic": "bears"})Rules
- For new code, use LCEL (
prompt | model | parser). Do not reach for LLMChain in new code; it lives in langchain-classic now and only exists for old codebases. - LCEL runnables get
.invoke,.batch,.stream,.astream_events,.with_retry, and.with_fallbacksfor free. If you are hand-rolling retry loops around a chain, you are reimplementing built-ins. - Prefer create_agent over chains for anything with tools. Chains are for straight pipelines; the moment the model needs to decide, that is an agent.
Evidence
Verified against the official LangChain docs on 2026-09-26. Migration guide: https://docs.langchain.com/oss/python/migrate/langchain-v1
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_IKAAF5kLPReNL-mqo8SGSw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">LCEL vs legacy chains: what current LangChain code looks like <span>— Vectle</span></a>