What LangChain is, and when it helps
What LangChain actually does for an AI app, what it costs you, and why we rebuild the slide pipeline on it after writing it by hand first.
Your pipeline works with plain API calls through gemini.js. The production PPTX Lab uses instead. This module shows why, by rebuilding the same pipeline on it one piece at a time.
Your pipeline
messages in, messages out
LangChain chat model
invoke()stream()withStructuredOutput()bindTools()usage_metadata
Gemini
@langchain/google-genai
OpenAI
@langchain/openai
Anthropic
@langchain/anthropic
What it gives you
- One interface for every model. Gemini, OpenAI and Anthropic all become a with the same
invoke()andstream(). Switching provider is a different constructor, not a rewrite. - Messages as objects. System, human and AI messages instead of hand-built request bodies.
- Structured output with zod. Describe the shape once and get a checked object back.
- Tools and streaming with the same API across providers, and token usage in the same place every time.
Plain API calls
- —Nothing between you and the API
- —Easy to see every request
- —You write request bodies and parsing
- —Switching model means rewriting calls
LangChain
- —Less boilerplate for messages, schemas and streaming
- —Swap models in one line
- —One more dependency to upgrade
- —Errors pass through an extra layer
What changes in the project
package.json gains three dependencies: @langchain/google-genai (the Gemini chat model), @langchain/core (messages) and zod (schemas). The engine doesn't change at all: LangChain only replaces how we talk to the model.
Going deeper — LangChain's own retries are switched off, on purpose
LangChain can retry failed calls for you. In module 9 you'll see why we don't let it: it can't tell a short rate limit from a used-up daily quota, it doesn't know your serverless time limit, and it can't fall back to another model. So our createModel sets maxRetries: 0 and the pipeline handles failures itself.
Your project so far
15 files · 1 new or changed in this lesson
package.json
{
"name": "slide-generator",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "Generate real PowerPoint decks from a topic with Gemini.",
"scripts": {
"start": "node server.js",
"deck": "node cli.js"
},
"dependencies": {
"@langchain/core": "^1.2.11",
"@langchain/google-genai": "^2.3.2",
"pptxgenjs": "^4.0.1",
"zod": "^4.6.5"
},
"engines": {
"node": ">=20"
}
}Key takeaways
- LangChain is a common interface over many models, plus helpers for messages, structured output, tools and streaming.
- It saves boilerplate and makes switching models cheap; it adds a dependency and a layer to debug.
- You built the pipeline by hand first, so you know exactly what LangChain is doing for you.
Sign in to run the exercise
Reading is free. Writing code here needs an account so we have somewhere to keep your Gemini key and the +15 XP you are about to earn.