LangChain
LangChain is an orchestration framework for building LLM-powered applications and agents. It provides abstractions for chaining model calls, tool use, memory, and multi-agent coordination. As of v1.0, LangGraph is the foundational runtime for stateful agent execution.
Warnings
- breaking AgentExecutor is removed in v1.0. Use create_agent instead.
- breaking LCEL pipe syntax (prompt | llm | parser) is deprecated. Use explicit chaining.
- breaking langchain-community does not follow semver. Breaking changes can occur in minor releases.
- gotcha pip install langchain alone is insufficient. Provider packages must be installed separately.
- deprecated astream_events(version='v1') uses vulnerable serialization. Use v2.
Install
-
pip install langchain langchain-openai langchain-anthropic -
npm install langchain @langchain/openai @langchain/anthropic
Imports
- ChatOpenAI
from langchain_openai import ChatOpenAI
- ChatAnthropic
from langchain_anthropic import ChatAnthropic
- create_agent
from langchain import create_agent
Quickstart
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model='gpt-4o', temperature=0)
response = llm.invoke('What is the capital of France?')
print(response.content)