Topics in this subject
LangChain 3 min read Updated 11 Aug 2026

LLMs vs Chat Models

Understanding the difference between raw text completion models and conversational Chat Models.

🧑‍🏫 Sabse pehle — simple mein samjho#

Sabse shuru mein AI models (jaise GPT-3) sirf text ko aage badhate the (Text Completion). Tum unhe "The sky is" bolte the, wo "blue" bol dete the. Par ChatGPT ke aane ke baad, sab kuch "Conversational" ho gaya hai. Ab hum AI ko role dete hain ("Tum ek expert coder ho"), uske baad user sawal puchta hai, aur AI jawab deta hai. LangChain mein in naye conversational models ko ChatModels kehte hain, aur ye 3 alag-alag tarah ke messages (SystemMessage, HumanMessage, AIMessage) use karte hain.

1. Standard LLMs (Text Completion - Legacy)#

Standard LLMs take a single string of text as input and return a single string of text as output. They are essentially powerful auto-complete engines. While still used for specific data-processing tasks, they are increasingly considered legacy for user-facing applications.

# Typically, you would set OPENAI_API_KEY in your .env file
from langchain_openai import OpenAI

# Initialize a standard text completion model
llm = OpenAI(temperature=0.7)

response = llm.invoke("Write a catchy slogan for a coffee shop:")
print(response) # " Wake up and smell the magic!"

(Note: temperature controls randomness. 0 is strict and factual, 1 is highly creative and random).

2. Chat Models (The Modern Standard)#

Chat Models (like gpt-4o or claude-3-opus) are specifically fine-tuned for conversation. Instead of taking a single string as input, they take a List of Messages.

LangChain defines three specific message classes to structure this conversation:

  1. SystemMessage: Background instructions for the AI. It sets the behavior, personality, or rules (e.g., "You are a helpful assistant that only speaks French. Do not use Markdown.").
  2. HumanMessage: The actual input, question, or prompt coming from the user.
  3. AIMessage: The response generated by the model. (You can also pass previous AIMessages back to the model to give it "memory" of the conversation).

Using a Chat Model#

from langchain_openai import ChatOpenAI
from langchain_core.messages import SystemMessage, HumanMessage

# Initialize the chat model
chat_model = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)

# Construct the conversation array
messages = [
    SystemMessage(content="You are a sarcastic IT support agent. Answer briefly."),
    HumanMessage(content="My computer screen is completely black. What should I do?")
]

# Invoke the model
response = chat_model.invoke(messages)

# The response is an AIMessage object, we access the text via .content
print(response.content) 
# "Have you considered opening your eyes? Or perhaps turning the monitor on?"

Why this distinction matters#

If you are building an AI application today, you should almost exclusively be using ChatModels (e.g., ChatOpenAI, ChatAnthropic, ChatOllama). They are smarter, better at following complex instructions, and natively support advanced features like "Tool Calling" (which we will cover in the Agents section).

LangChain's unified interface means that if you want to switch your entire application from OpenAI to an open-source model running locally via Ollama, you only need to change one line of code (the initialization of the chat_model object). The rest of your messages and logic remain perfectly intact!