Sitemap

Day 212 — Understanding LCEL in LangChain: Guide to Building AI Applications

3 min readOct 9, 2026

--

8th October 2026,Netherlands — Artificial Intelligence is changing how we build software. Today, developers can create chatbots, AI assistants, and Retrieval-Augmented Generation (RAG) applications using Large Language Models (LLMs).

LangChain and LCEL is useful in connecting an LLM with prompts, databases, and other components.

Press enter or click to view image in full size

What is LangChain?

LangChain is an open-source framework that helps developers build applications powered by Large Language Models (LLMs).

Instead of writing everything from scratch, LangChain provides reusable components to connect:

  • LLMs: Generate answers using AI models.
  • Prompt Templates: Structure instructions sent to models.
  • Retrievers: Fetch relevant information from external sources.
  • Output Parsers: Convert model responses into usable formats.
  • Tools: Allow AI applications to interact with external systems.

For example, imagine building an AI chatbot that answers questions using your company’s documents.

LangChain helps connect document retrieval, prompt creation, and answer generation into one workflow.

And LCEL connects these components efficiently?

What is LCEL?

LCEL stands for LangChain Expression Language.

LCEL is a declarative way to connect LangChain components and create execution pipelines called chains.

Think of LCEL as an assembly line in a factory.

Each component performs a specific task and passes its output to the next component.

LCEL uses the pipe operator (|) to connect components.

For example:

chain = prompt | model | output_parser

Here:

  1. The prompt prepares instructions.
  2. The model generates a response.
  3. The output parser formats the result.

Each step automatically receives the previous step’s output.

Building Your First LCEL Chain

Let’s create a simple application that explains technical concepts.

Get Alok Rahul’s stories in your inbox

Join Medium for free to get updates from this writer.

First, install the required packages:

pip install -U langchain-core langchain-openai

Set your OPENAI_API_KEY environment variable, then write:

from langchain_core.prompts import ChatPromptTemplatefrom langchain_core.output_parsers import StrOutputParserfrom langchain_openai import ChatOpenAI# Create a promptprompt = ChatPromptTemplate.from_template(    "Explain {topic} in simple English.")# Initialize the language modelmodel = ChatOpenAI(model="gpt-4.1-mini")# Create the LCEL chainchain = prompt | model | StrOutputParser()# Execute the chainresponse = chain.invoke({"topic": "Kubernetes"})print(response)

The application sends the topic to the prompt, passes the formatted instructions to the LLM, and converts the response into a Python string.

All three components work together through one chain.

Why is LCEL Useful?

LCEL offers several important benefits.

1. Simple and readable code

Developers can connect components without writing complicated orchestration logic.

2. Reusable components

The same prompt, model, or parser can be reused across different applications.

3. Streaming support

Using stream(), applications can display generated output progressively instead of waiting for the complete response.

4. Parallel execution

LCEL supports running independent operations concurrently using components such as RunnableParallel.

5. Asynchronous and batch processing

Developers can process requests using ainvoke() or multiple inputs using batch().

These capabilities make LCEL particularly useful when building RAG pipelines, document-processing systems, and other LLM workflows.

Final Thoughts —

LangChain provides the building blocks for developing AI applications, while LCEL provides a simple way to connect those blocks.

Instead of writing complex code to manage every operation, developers can create readable and reusable pipelines.

For beginners learning AI Engineering, LCEL is an important concept because it introduces how prompts, models, retrievers, and output parsers work together.

Although newer LangChain agent workflows often use LangGraph-based orchestration, LCEL remains useful for composing straightforward chains.

The key takeaway: LangChain gives us the components. LCEL helps us connect them into working AI applications.

--

--

Alok Rahul
Alok Rahul

Written by Alok Rahul

Growth Mindset - Improve 1 percent a day.