๐Ÿ“˜ Basics

LangChain Basics: Build Your First AI Agent

Get started with LangChain, the most popular framework for building LLM applications. From installation to your first AI agent in 30 minutes.

๐Ÿ“… June 30, 2026 ๐Ÿ“Š Level: beginner ๐Ÿ“ฆ GitHub: langchain/langchain

Sponsored

LangChain Basics: Build Your First AI Agent

LangChain is the most-used framework for building LLM applications. This tutorial walks you through your first AI agent in 30 minutes.

What is LangChain?

LangChain is an open-source framework for building applications with large language models. It provides:

Install

pip install langchain langchain-openai
export OPENAI_API_KEY="sk-..."

Your first chain

from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

llm = ChatOpenAI(model="gpt-4")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant."),
    ("user", "{question}"),
])
chain = prompt | llm
response = chain.invoke({"question": "What is LangChain?"})
print(response.content)

Your first agent

from langchain.agents import create_react_agent
from langchain.tools import Tool

tools = [Tool(name="search", func=search.run, description="Web search")]
agent = create_react_agent(llm, tools)
agent.invoke({"input": "What's the weather in Beijing?"})

Key takeaways

๐Ÿ“ฆ ๅผ€ๆบ้กน็›ฎ

ๆœฌๆ•™็จ‹ๅŸบไบŽๅผ€ๆบ้กน็›ฎ langchain/langchain ๆ•ด็†ใ€‚

โญ View on GitHub โ†’

Sponsored

๐Ÿ› ๏ธ Related Tools & Resources

Mechanical Keyboards โ†’
For coding & writing tutorials
USB-C Hubs โ†’
Multi-monitor dev setup
Noise-Cancelling Headphones โ†’
Focus while learning
Laptop Stands โ†’
Ergonomics for long tutorials