Skip to main content
This tutorial demonstrates how to build a ReAct-style LangGraph agent that uses the Tavily Search API to fetch information and then processes it with either OpenAI or Anthropic models—while instrumenting the entire workflow with Maxim for tracing, spans, and performance insights.

1. Prerequisites

  • Python 3.8+
  • API keys for:
    • OpenAI (OPENAI_API_KEY)
    • Anthropic (ANTHROPIC_API_KEY)
    • Tavily (TAVILY_API_KEY)
    • Maxim (MAXIM_API_KEY)
    • Maxim Log Repository ID (MAXIM_LOG_REPO_ID)
  • Install packages:

2. Imports & Environment

Load your API keys:

3. Initialize Maxim Logger

4. Define Agent State & Tools

5. Model Selection Helper

6. Control Flow: Continue or End

7. Define the Function That Calls the Model

8. Build the LangGraph Workflow

9. Start Tracing Entire LangGraph Agent Using 2 Simple Annotations

10. Get the Response from the Agent

Langgraph Gif

LangGraph integration with decorator (GitHub)