Why LangChain.js? Chat Models and Prompt Templates
Everything LangChain does in Python, standardizing prompts, models, and chains behind one interface, has a first-class TypeScript port: LangChain.js. If you already know TypeScript's type system, this course reuses that strength directly, chains here are typed end to end.
Chat models
This needs a real API key and network access, so it's read-only here. model.invoke(...) is async, every LangChain.js call that talks to a model returns a Promise, matching how you'd already call any other network API in TypeScript.
Prompt templates
{topic} is a placeholder, filled in from whatever object you pass to .invoke(), the same prompt object is reusable with { topic: 'closures' } or any other value, without rewriting the wording.
Why not just template strings yourself?
You could interpolate a plain TypeScript template string instead, and for a single, throwaway prompt, that's fine. ChatPromptTemplate starts paying off once you need to: reuse the same prompt in multiple places, compose it with a model and parser (next lesson), or swap the underlying model without touching the prompt at all.
TIP
.invoke() is the one method every LangChain.js "Runnable" (models, prompts, chains, retrievers) implements. Once you've learned it once, you already know how to call any piece in the library.