Sitemap
md wasim

md wasim

SRE-2 at Akamai Technologies, Ex- AT&T and Thomson Reuters. Master of Computer Application.

Understanding LangChain

2 min readAug 19, 2026

--

The current LangChain Python ecosystem is centered around a few important ideas: models, messages, prompts, tools, agents, retrieval/RAG, and orchestration. LangChain also provides a standard interface across model providers, which is one of its main benefits.

Learning path

I recommend this order:

  1. What LangChain is
  2. Calling an LLM through LangChain
  3. Messages
  4. Prompt templates
  5. Prompt + model chains
  6. Output parsing / structured output
  7. Conversation history
  8. Tools and tool calling
  9. Agents
  10. Retrieval and embeddings
  11. RAG
  12. Memory and state
  13. LangGraph basics
  14. Build a real project

Lesson 1 — Your first LangChain program

What is LangChain?

Think of it this way:

Without LangChain:

Your Python code → OpenAI API → Model → Response

With LangChain:

Your Python code
↓
LangChain
↓
Model
↓
Response

LangChain gives you reusable abstractions around models and other components so you can later connect prompts, tools, retrieval systems, agents, etc.

For example, today’s LangChain documentation uses ChatOpenAI from the separate langchain-openai integration package for OpenAI chat models.

Step 1: Install LangChain

Create a Python environment and install:

pip install -U langchain langchain-openai

langchain-openai is the integration package that provides ChatOpenAI.

You’ll also need an OPENAI_API_KEY environment variable.

For example:

export OPENAI_API_KEY="your_api_key_here"

On Windows PowerShell:

$env:OPENAI_API_KEY="your_api_key_here"

Step 2: Create your first LangChain model

from langchain_openai import ChatOpenAI
model = ChatOpenAI(model="gpt-5.4-mini")response = model.invoke("What is Python?")print(response.content)

That’s your first LangChain application.

What’s happening?

This line:

from langchain_openai import ChatOpenAI

imports LangChain’s OpenAI chat-model integration.

Get md wasim’s stories in your inbox

Join Medium for free to get updates from this writer.

This:

model = ChatOpenAI(model="gpt-5.4-mini")

creates a model object.

Think of model as:

model = "an object that knows how to communicate with the LLM"

Then:

response = model.invoke("What is Python?")

means:

Send this input → model → receive response

And:

print(response.content)

gets the actual text from the response.

LangChain’s chat models accept messages or simple string input and return message objects rather than just raw strings.

The important concept

For now, remember just this:

Model
↓
invoke()
↓
Response

For example:

response = model.invoke("Hello")

You can think of .invoke() as:

“Run this model with this input.”

You’ll see .invoke() repeatedly throughout LangChain.

One useful experiment

Change:

response = model.invoke("What is Python?")

Your first mental model

Don’t worry about agents, chains, RAG, vectors, or LangGraph yet.

For now:

┌─────────────┐
Input ──────────►│ Model │
└──────┬──────┘
│
▼
Response

That’s the foundation.

Tiny exercise

Write a program that asks the model:

Explain ERP in simple terms for a beginner.

using ChatOpenAI and .invoke().

Once you understand this, the next lesson will be Messages, where you’ll learn why LangChain has concepts like HumanMessage, SystemMessage, and AIMessage. That is the first concept that really starts making LangChain feel different from simply calling an LLM API.

--

--

md wasim

Written by md wasim

SRE-2 at Akamai Technologies, Ex- AT&T and Thomson Reuters. Master of Computer Application.