Skip to main content
This quickstart takes you from a simple setup to a fully functional AI agent in just a few minutes.
LangChain Docs MCP serverIf you’re using an AI coding assistant or IDE (e.g. Claude Code or Cursor), you should install the LangChain Docs MCP server to get the most out of it. This ensures your agent has access to up-to-date LangChain documentation and examples.

Requirements

For these examples, you will need to:
  • Install the LangChain package
  • Set up a Claude (Anthropic) account and get an API key
  • Set the ANTHROPIC_API_KEY environment variable in your terminal
Although these examples use Claude, you can use any supported model by changing the model name in the code and setting up the appropriate API key.

Build a basic agent

Start by creating a simple agent that can answer questions and call tools. The agent will use Claude Sonnet 4.5 as its language model, a basic weather function as a tool, and a simple prompt to guide its behavior.
To learn how to trace your agent with LangSmith, see the LangSmith documentation.

Build a real-world agent

Next, build a practical weather forecasting agent that demonstrates key production concepts:
  1. Detailed system prompts for better agent behavior
  2. Create tools that integrate with external data
  3. Model configuration for consistent responses
  4. Structured output for predictable results
  5. Conversational memory for chat-like interactions
  6. Create and run the agent to test the fully functional agent
Let’s walk through each step:
1

Define the system prompt

The system prompt defines your agent’s role and behavior. Keep it specific and actionable:
2

Create tools

Tools let a model interact with external systems by calling functions you define. Tools can depend on runtime context and also interact with agent memory.Notice below how the get_user_location tool uses runtime context:
Tools should be well-documented: their name, description, and argument names become part of the model’s prompt. LangChain’s @tool decorator adds metadata and enables runtime injection with the ToolRuntime parameter.
3

Configure your model

Set up your language model with the right parameters for your use case:
Depending on the model and provider chosen, initialization parameters may vary; refer to their reference pages for details.
4

Define response format

Optionally, define a structured response format if you need the agent responses to match a specific schema.
5

Add memory

Add memory to your agent to maintain state across interactions. This allows the agent to remember previous conversations and context.
In production, use a persistent checkpointer that saves message history to a database. See Add and manage memory for more details.
6

Create and run the agent

Now assemble your agent with all the components and run it!
To learn how to trace your agent with LangSmith, see the LangSmith documentation.
Congratulations! You now have an AI agent that can:
  • Understand context and remember conversations
  • Use multiple tools intelligently
  • Provide structured responses in a consistent format
  • Handle user-specific information through context
  • Maintain conversation state across interactions

Connect these docs to Claude, VSCode, and more via MCP for real-time answers.