LESSON · 1 OF 4

What is LangChain

What is LangChain

LangChain is a Python framework for building apps around an LLM. You've already sent an API call by hand: build the JSON body, POST it with curl, then dig the reply out of choices[0].message.content. That works, but once an app grows you end up writing the same glue over and over - formatting prompts, calling the API, reading the response, passing the result into the next step. LangChain wraps that glue so you write less of it.

What it handles for you

Three jobs show up in almost every LLM app, and LangChain gives each one a reusable piece:

  • The API call. A chat model object talks to the API for you. You call it like a function and get the reply text back, instead of hand-building JSON and parsing it.
  • The prompt. A prompt template is a string with holes in it. You write the wording once with a variable like {topic}, then fill the hole with a real value each time. No more gluing strings together.
  • The chaining. You pipe the template into the model so the filled-in prompt flows straight into the call as one unit. That combined unit is a "chain", which is where the name comes from.

When to reach for it, when not to

For a single one-off request, raw curl or a plain SDK call is simpler - don't pull in a framework to ask one question. LangChain earns its place when an app has moving parts: reusable prompt templates, several steps feeding into each other, or the same call repeated across many inputs. It gives those apps a common shape so the code stays readable as it grows.

It's a tool on top of the same API you already know. The model, the messages, and the reply haven't changed - LangChain just hides the repetitive wiring. Next you'll see the actual pieces of a chain in code.


Your lab setup

This VM comes preconfigured with your AI keys - just type claude to get started. Your key and URL are already set as $OPENAI_BASE_URL and $OPENAI_API_KEY.

Spin up a fresh environment and practice live.
linux-basic-ai · fresh machine · ready in under a minute