> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/langchain-ai/langgraph/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Build your first LangGraph application in under 5 minutes

# Quickstart

This guide will get you up and running with LangGraph in under 5 minutes. You'll create a simple stateful workflow that demonstrates the core concepts of graphs, nodes, edges, and state.

## Prerequisites

Before you begin, make sure you have:

* Python 3.10 or higher installed
* Basic familiarity with Python and type hints

<Tip>
  If you haven't installed LangGraph yet, check out the [Installation Guide](/installation).
</Tip>

## Your First LangGraph Application

Let's build a simple workflow that processes text through multiple nodes.

<Steps>
  ### Define Your State

  First, define the state schema using a TypedDict. The state represents the data that flows through your graph:

  ```python theme={null}
  from typing_extensions import TypedDict

  class State(TypedDict):
      text: str
  ```

  ### Create Node Functions

  Nodes are the building blocks of your graph. Each node is a function that receives the current state and returns an update:

  ```python theme={null}
  def node_a(state: State) -> dict:
      return {"text": state["text"] + "a"}

  def node_b(state: State) -> dict:
      return {"text": state["text"] + "b"}
  ```

  <Note>
    Node functions can return a partial state update. LangGraph automatically merges the update with the existing state.
  </Note>

  ### Build the Graph

  Now create a StateGraph and add your nodes and edges:

  ```python theme={null}
  from langgraph.graph import START, StateGraph

  graph = StateGraph(State)
  graph.add_node("node_a", node_a)
  graph.add_node("node_b", node_b)
  graph.add_edge(START, "node_a")
  graph.add_edge("node_a", "node_b")
  ```

  Here's what's happening:

  * `StateGraph(State)` creates a graph with your state schema
  * `add_node()` registers functions as nodes in the graph
  * `add_edge()` defines the execution flow between nodes
  * `START` is a special constant representing the entry point

  ### Compile and Run

  Compile the graph and execute it with initial state:

  ```python theme={null}
  app = graph.compile()

  result = app.invoke({"text": ""})
  print(result)
  ```
</Steps>

## Complete Example

Here's the full code in one place:

```python theme={null}
from langgraph.graph import START, StateGraph
from typing_extensions import TypedDict


class State(TypedDict):
    text: str


def node_a(state: State) -> dict:
    return {"text": state["text"] + "a"}


def node_b(state: State) -> dict:
    return {"text": state["text"] + "b"}


graph = StateGraph(State)
graph.add_node("node_a", node_a)
graph.add_node("node_b", node_b)
graph.add_edge(START, "node_a")
graph.add_edge("node_a", "node_b")

app = graph.compile()

print(app.invoke({"text": ""}))
# Output: {'text': 'ab'}
```

## Expected Output

When you run this code, you'll see:

```python theme={null}
{'text': 'ab'}
```

The workflow:

1. Starts with an empty string `""`
2. `node_a` appends `"a"` → `"a"`
3. `node_b` appends `"b"` → `"ab"`

## Understanding the Flow

<Steps>
  ### State Initialization

  The graph begins with the initial state you provide: `{"text": ""}`

  ### Node Execution

  Each node receives the current state and returns updates. LangGraph automatically merges these updates.

  ### Sequential Processing

  Edges determine execution order. In this example, `node_a` always runs before `node_b`.

  ### Final State

  The `invoke()` method returns the final state after all nodes complete.
</Steps>

## Building a Conditional Workflow

Let's extend the example with conditional routing:

```python theme={null}
from langgraph.graph import START, END, StateGraph
from typing_extensions import TypedDict


class State(TypedDict):
    text: str
    count: int


def increment(state: State) -> dict:
    return {"count": state["count"] + 1}


def should_continue(state: State) -> str:
    if state["count"] < 3:
        return "increment"
    return END


graph = StateGraph(State)
graph.add_node("increment", increment)
graph.add_edge(START, "increment")
graph.add_conditional_edges("increment", should_continue)

app = graph.compile()

result = app.invoke({"text": "hello", "count": 0})
print(result)
# Output: {'text': 'hello', 'count': 3}
```

This creates a loop that increments `count` until it reaches 3.

## Next Steps

Now that you've built your first LangGraph application, explore more advanced features:

<CardGroup cols={2}>
  <Card title="Core Concepts" icon="book" href="/concepts">
    Learn about state management, reducers, and graph patterns
  </Card>

  <Card title="Checkpointing" icon="database" href="https://docs.langchain.com/oss/python/langgraph/durable-execution">
    Add persistence and enable time-travel debugging
  </Card>

  <Card title="Human-in-the-Loop" icon="user" href="https://docs.langchain.com/oss/python/langgraph/interrupts">
    Pause execution for human approval or input
  </Card>

  <Card title="Examples" icon="flask" href="https://docs.langchain.com/oss/python/langgraph/agentic-rag">
    Explore real-world LangGraph applications
  </Card>
</CardGroup>

<Tip>
  Want to build AI agents quickly? Check out [`create_react_agent`](https://docs.langchain.com/oss/python/langchain/agents) for a high-level API built on LangGraph.
</Tip>

## Troubleshooting

### Import Errors

If you see `ModuleNotFoundError`, ensure LangGraph is installed:

```bash theme={null}
pip install langgraph
```

### Type Errors

Make sure you're using `typing_extensions.TypedDict` (not `typing.TypedDict`) for Python 3.10 compatibility:

```python theme={null}
from typing_extensions import TypedDict
```

### State Not Updating

Remember that node functions should return dictionaries with the keys to update:

```python theme={null}
# Correct
def my_node(state: State) -> dict:
    return {"text": "new value"}

# Incorrect - returns the full state
def my_node(state: State) -> State:
    state["text"] = "new value"
    return state
```

## Get Help

Need assistance? Here are some resources:

* [LangChain Forum](https://forum.langchain.com/) - Community Q\&A
* [GitHub Issues](https://github.com/langchain-ai/langgraph/issues) - Bug reports and feature requests
* [LangChain Academy](https://academy.langchain.com/courses/intro-to-langgraph) - Free structured course
