Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 32 ยท Getting Started

What Is LangChain?

Learn what LangChain is, which problems it solves for LLM applications, how its packages fit together, and what this course runs live versus shows read-only.

A large language model (LLM) is a function from text to text, and calling one is easy: you send a request to an API and read the reply. Building an application around that call is harder. You must fill prompts with user data, switch between providers, force the model to answer in a fixed format, give it your own documents, let it call tools, keep a conversation going and measure whether any of it works. LangChain is an open-source framework, available for Python and JavaScript, that gives each of those jobs a standard building block.

This course teaches the Python version. It starts with the big picture here, then installs the packages, calls a model, and builds up prompts, parsers, chains, retrieval, agents, memory and LangGraph workflows.

What runs on this site. The real LangChain packages need a network connection and an API key for a model provider, and neither exists inside our in-browser Python. So the real LangChain code in this course is shown read-only, and I only print its output where it is certain. Next to it you get runnable stand-ins: small plain-Python classes that implement the same idea (a prompt template, a pipe operator, a vector store), clearly labelled as stand-ins. You learn the real API from the read-only code and the underlying mechanics by running the stand-ins.

The problems LangChain solves

Imagine a support bot for a shop. Behind one chat box you need all of this:

  • a prompt that mixes fixed instructions with the customer's message;
  • a model call, which might go to one provider today and another tomorrow;
  • a parser that turns the reply into data your program can use;
  • retrieval of the right help-center articles to put in the prompt;
  • tools the model may call, like "look up order status";
  • memory, so the second question knows about the first;
  • tracing and evaluation, so you can tell when a change makes things worse.

You can write all of this with raw HTTP calls and string formatting, and for a tiny script you should. Frameworks pay off when the pieces multiply. LangChain's contribution is a common interface for each piece, so a model, a retriever or a parser from any vendor can be swapped without rewriting your application.

The pieces and the packages

LangChain is split into several Python packages. Knowing which does what saves confusion when you read docs and error messages.

flowchart TB
    A["langchain-core<br/>interfaces: Runnable, messages, prompts, parsers"] --> B["langchain<br/>agents, init_chat_model"]
    A --> C["langchain-openai, langchain-anthropic ...<br/>provider integrations"]
    A --> D["langchain-community<br/>many third-party integrations"]
    B --> E["langgraph<br/>stateful graphs and agent runtime"]
    B --> F["langsmith<br/>tracing, datasets, evaluation"]

The core package defines the interfaces; everything else plugs into them.

Package What it contains
langchain-core Base abstractions: messages, prompt templates, output parsers, the Runnable interface and the pipe syntax called LCEL
langchain High-level pieces such as init_chat_model and create_agent, built on core
Provider packages (langchain-openai, langchain-anthropic, ...) Chat models and embeddings for one vendor each
langchain-community A large collection of loaders, vector stores and tools maintained by the community
langgraph A runtime for stateful, multi-step workflows and agents, modeled as graphs
langsmith A hosted (or self-hosted) service for tracing runs, building test datasets and running evaluations

The version line matters: this course targets the 1.x generation of langchain and langchain-core, where agents are created with create_agent and LangGraph is the runtime underneath. Older tutorials use LLMChain, ConversationChain or initialize_agent; those are deprecated, and we only mention them to warn you away.

The core idea in plain Python

Strip LangChain down and a typical LLM step is three functions in a row: format a prompt, call a model, parse the reply. This runnable stand-in does exactly that with a fake model, so you can see the shape before meeting the real classes.

Python Stand-in: prompt, model, parser as plain functions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

LangChain gives each of those three steps a class with the same method names, so that "prompt template", "chat model" and "output parser" can be glued together with |. The next stand-in shows why a shared interface matters: two different fake providers are interchangeable because both offer invoke.

Python Stand-in: one interface, two interchangeable models

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

That is the whole pitch. The real classes add async variants, streaming, batching, retries and tracing on top of invoke, which you meet in The Runnable Interface.

What the real code looks like

Here is a first taste of real LangChain. It is read-only on this site because it needs an API key and a network. Do not worry about the details; every line is explained in the coming lessons.

Python
from langchain.chat_models import init_chat_model
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

model = init_chat_model("openai:gpt-4o-mini", temperature=0)

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a concise teacher."),
    ("human", "Explain {topic} in one short sentence."),
])

chain = prompt | model | StrOutputParser()
print(chain.invoke({"topic": "recursion"}))

The last two lines are the heart of modern LangChain: a chain built with the pipe operator, and a single invoke call that sends a dictionary in and gets a string out.

What LangChain is not

  • It is not a model. It never generates text itself; it calls models.
  • It is not required. Many production apps use the vendor SDK directly. Reach for LangChain when you benefit from its interfaces, integrations, LangGraph or LangSmith.
  • It is not magic. Every abstraction ends up as prompts, API calls and Python functions. Understanding the plain version, as in this lesson, makes debugging far easier.

When a LangChain app misbehaves, look at the final prompt text and the raw model reply first. Most bugs live there, not in the framework.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main job of the langchain-core package?

    langchain-core holds the abstractions that provider packages and your own code plug into.
  2. 2. Why does this site show real LangChain code read-only?

    Real model calls need a network and credentials. Runnable stand-ins teach the same ideas offline.
  3. 3. Which is NOT something LangChain itself does?

    LangChain orchestrates; the text always comes from a model you call.
  4. 4. Which package provides the stateful graph runtime for agents and workflows?

    LangGraph models workflows as graphs with state; LangSmith is for tracing and evaluation.

Summary

  • LangChain provides standard building blocks (prompts, models, parsers, retrievers, tools, memory) for LLM applications.
  • langchain-core defines the interfaces, provider packages implement them, langgraph runs stateful workflows, langsmith traces and evaluates.
  • A basic app is prompt, model, parser; LangChain lets you join them with |.
  • This course shows real code read-only and runs honest plain-Python stand-ins.

Next: Installing LangChain and Setting Up Keys