Before LCEL, chaining steps in LangChain meant nesting classes and configurations. With the pipe operator, a chain reads left to right, literally the way you think about it.
LCEL is an abstraction of interesting Python concepts into a format that enables a minimalist code layer for building chains of LangChain components. Chains are built by connecting Runnables with the pipe operator `|`, creating a clear left-to-right data flow — the `|` operator composes two Runnables into a RunnableSequence, which is itself also a Runnable, allowing chains of chains to be composed with no conceptual nesting limit.
LCEL supports incremental streaming to enable a faster time-to-first-token from language models, improving perceived responsiveness. LCEL integrates streaming natively and was designed from the start with this in mind — it isn't a layer bolted on afterward, it's part of the base architecture of how a chain works.
Using `.with_fallbacks()` gives you real resilience: if the primary model fails, a backup model automatically takes over. Retry and fallback behavior (`.with_retry()`, `.with_fallbacks()`) and LangSmith tracing apply to the composed chain automatically, without having to touch how the individual steps are written — you add resilience by wrapping the chain, not by rewriting its internal logic.
LCEL simplifies building complex chains of operations, enabling both synchronous and asynchronous execution while supporting advanced features like streaming, retries, and fallbacks — the same chain defined with `.invoke()` works with `.ainvoke()` for the async equivalent, with no need for two separate implementations.
Carlos Montiel is an enterprise AI solutions architect. He implements LLMs, Agents, RAG, and orchestrators for companies across Guatemala and Latin America. Reach out for a consultation.
Contact Carlos Montiel