LangGraph Workflow Example¶
Example LangGraph workflows with X402 payment nodes.
Setup¶
-
Install dependencies:
-
Create and fund wallet:
-
Start the FastAPI server (in another terminal):
-
Run the workflow examples:
What it does¶
The examples demonstrate three workflow patterns:
Example 1: Simple Workflow¶
Uses the convenience function to create a basic workflow with payment handling.
Example 2: Custom Workflow¶
Shows how to build a workflow with separate fetch and payment nodes for more control.
Example 3: Multi-Step Workflow¶
Demonstrates a workflow that accesses multiple paid APIs sequentially, handling payments for each.
Key Features¶
- Modular Design: Payment logic is isolated in dedicated nodes
- Conditional Routing: Workflows automatically route to payment nodes when needed
- Error Handling: Graceful handling of payment errors
- Composable: Easy to add payment capabilities to existing workflows