Alpha Notice: These docs cover the v1-alpha release. Content is incomplete and subject to change.For the latest stable version, see the current LangChain Python or LangChain JavaScript docs.
LangChain is the easiest way to start building with LLMs, letting you get started on building agents with OpenAI, Anthropic, Google and more in under 10 lines of code.LangChain agents are built on top of LangGraph. This is done to take advantage of the capabilities LangGraph provides: durable execution, streaming, human-in-the-loop, persistence. You do not need to know LangGraph for basic LangChain agent usage, but some advanced functionality may require LangGraph knowledge.Install LangGraph:
# pip install -qU "langchain[anthropic]" to call the modelfrom langgraph.prebuilt import create_react_agentdef get_weather(city: str) -> str: """Get weather for a given city.""" return f"It's always sunny in {city}!"agent = create_react_agent( model="anthropic:claude-3-7-sonnet-latest", tools=[get_weather], prompt="You are a helpful assistant")# Run the agentagent.invoke( {"messages": [{"role": "user", "content": "what is the weather in sf"}]})
Standard Model Interface: Different model providers have different APIs for interacting with models, including the format of the messages they return. LangChain standardizes how you call and interact with models. This allows you to seamlessly swap across model providers and avoid lock in.
Easy to use, yet highly flexible agent: LangChain’s agent abstraction is designed to be easy to get started with - letting you build a simple agent in ~10 lines of code. But it also provides enough flexibility to allow you to do all the context engineering your heart desires.
Built on top of LangGraph: LangChain’s agents are built on top of LangGraph. This allows us to take advantage of LangGraph’s durable execution, human-in-the-loop support, persistence, and more.
Debugging with LangSmith: Gain deep visibility into complex agent behavior with visualization tools that trace execution paths, capture state transitions, and provide detailed runtime metrics.