CTCaliberTek
Course: LangChain: Step by Step (9 Modules) · Lesson 1 of 9Log in to track your progress and earn a certificate when you finish the course.
AI & Machine Learning

LangChain Module 1: Introduction, Setup, and Your First Model Call

Published October 17, 2026·Updated October 29, 2026·8 min read·2 views

Edited by , Senior Data Analyst. How we make our content

Like SaveLog in to like, save, and track progress.

Introduction

LangChain is an open-source framework for building applications and agents powered by language models. Version 1 was a major redesign around a simpler core: a standard interface for chat models and a single create_agent function for building agents. This first module of the nine-module LangChain course explains the moving parts and gets you to a working model call.

Prerequisites

  • Python 3.11 or newer
  • An API key from a model provider such as Anthropic or OpenAI
  • Basic Python and virtual environments

Step-by-Step Guide

Step 1: Understand what LangChain gives you

LangChain provides a common interface across model providers, so changing from one provider to another is mostly a one-line change. It adds tools, structured output, memory, retrieval building blocks, and middleware for agents. Agents built with it run on LangGraph underneath, which is the lower-level runtime you will meet later in this track.

Step 2: Learn the package layout

The langchain package is the main entry point and re-exports pieces of langchain-core, such as messages and tools. Provider support comes in extras like langchain[anthropic] or langchain[openai]. Legacy functionality, including the old chain classes, moved to a separate package called langchain-classic, so older tutorials may not match current imports.

Step 3: Install it

Create a virtual environment and install LangChain with the extra for your provider. Also install python-dotenv so you can keep keys in a .env file.

python3.11 -m venv .venv
# macOS / Linux
source .venv/bin/activate
# Windows
# .venv\Scripts\activate

pip install -U langchain "langchain[anthropic]" python-dotenv

Step 4: Set your API key

Providers read their keys from environment variables: ANTHROPIC_API_KEY for Anthropic and OPENAI_API_KEY for OpenAI. Put the key in a .env file in your project and never commit that file to Git.

# .env
ANTHROPIC_API_KEY=your-key-here

Step 5: Make your first model call

init_chat_model creates a chat model from a provider:model string. Replace the string with another provider's model to switch providers. Setting max_tokens generously matters because some models use tokens for internal reasoning before the visible answer. Model names change often, so check your provider's list.

from dotenv import load_dotenv
from langchain.chat_models import init_chat_model

load_dotenv()

model = init_chat_model("anthropic:claude-opus-5-5", max_tokens=16000)

response = model.invoke("In one sentence, what is LangChain?")
print(response.text)

FAQs

Why do older LangChain tutorials fail with import errors?
Version 1 moved legacy chains and other older features to langchain-classic and replaced agent-building helpers with create_agent. Check the publication date of any tutorial and prefer the current documentation.
Do I have to use LangChain to call a model?
No. A provider's own SDK is simpler for one call. LangChain pays off when you want provider flexibility, tools, memory, retrieval, and agent features without writing the plumbing.

Summary

LangChain v1 centers on init_chat_model and create_agent. Install langchain plus a provider extra, put the key in the environment, and your first call is three lines. Next you will learn the model interface properly.

Related tutorials

Comments

Log in or create a free account to join the discussion.

  • No comments yet. Be the first to comment.