Generative AI & LLMsLesson 4 of 4

What is LangChain?

Lessons 1–3 covered models and websites. LangChain is the library we will use to call those models from Python. Still no coding here — just the idea, with one concrete flow.

Not a chatbot — a toolkit

LangChain is an open-source Python library (there is a JavaScript version too). It is not an LLM like ChatGPT or Claude. You install it in your project, point it at a provider's API, and write a few lines to send prompts and read replies.

Think of it as shared plumbing. Every LLM vendor has slightly different request formats, error codes, and model names. LangChain wraps those differences so you can try OpenAI first and swap later without rewriting the whole script.

An example

Say QList adds a small helper on an HTML tutorial page — next to the HTML/CSS/JS playground. A learner types a question; your Python file forwards it through LangChain to the OpenAI API using the key from Lesson 2. LangChain handles the prompt shape and the HTTP call; you print the text back to the page.

An HTML tutorial helper — one question, one answer:

Your script

html-tutorial-helper.py

"What does the <a> tag do in HTML?"

LangChain

format prompt · call model · return text

Provider

OpenAI API

GPT-4o mini answers from your key

Reply

"The <a> tag creates a hyperlink. Put the URL in the href attribute, e.g. <a href='/playground/html-css-js'>Try it</a>."

LangChain does not host the model. It is the glue between your Python file and whichever API you picked in Lesson 3.

Words you will see in docs

Tutorials jump straight into these terms. A quick map before we open a terminal:

Model — the connection to GPT-4o, Claude, Mistral, or a local Ollama install.

Prompt template — a string with slots, e.g. "Explain this HTML topic for a beginner: {question}".

Chain — two or more steps run in sequence: fill the template, call the model, trim the output.

Memory — optional; stores earlier messages when you need a back-and-forth chat instead of one shot.

🦜LangChain DocsOpen …
Search…Ctrl K
Ask AIGitHubTry LangSmith
Deep AgentsLangChainLangGraphIntegrationsLearnReferenceContribute
🐍Python
Overview

Get started

Core components

LangChain overview

📋 Copy page

Agent = Model + Harness. LangChain provides create_agent: a minimal, highly configurable harness. The harness is everything around the model loop: the prompt, the tools, and any middleware that shapes behavior. Start with the primitives and compose exactly what your use case needs. Supports OpenAI, Anthropic, Google, and more.

💡

LangChain vs. LangGraph vs. Deep Agents

Start with Deep Agents if you want a batteries-included agent with automatic context compression, a virtual filesystem, and subagent-spawning. Deep Agents are built on LangChain agents, which you can also use directly.

Use LangChain (create_agent) when you need a highly customizable harness tailored to your use case and data.

Current docs layout at docs.langchain.com — the Overview page is a good bookmark before you install the package.

Do you need it?

For a single hard-coded question you could call the OpenAI HTTP API directly. LangChain starts to pay off when you have several prompts, might change provider, or want memory and tool hooks without inventing your own structure.

Source and release notes live on GitHub. Module 2 starts with an OpenAI account and API key — then we install the package and run a short script.

What's Next

Module 1 ends here. Next: create your OpenAI platform account and generate an API key.