LangChain v1 is under active development and is not recommended for production use.
  • APIs may change without notice
  • The docs are incomplete and subject to change
For the latest stable version, see the v0 LangChain 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 in order to provide durable execution, streaming, human-in-the-loop, persistence. You do not need to know LangGraph for basic LangChain agent usage.

Install

pip install --pre -U langchain

Create an agent

# pip install -qU "langchain[anthropic]" to call the model

from langchain.agents import create_agent

def get_weather(city: str) -> str:
    """Get weather for a given city."""
    return f"It's always sunny in {city}!"

agent = create_agent(
    model="anthropic:claude-3-7-sonnet-latest",
    tools=[get_weather],
    prompt="You are a helpful assistant",
)

# Run the agent
agent.invoke(
    {"messages": [{"role": "user", "content": "what is the weather in sf"}]}
)

Core benefits